Skip to content

Cannot compile native AoT ASP.NET Core application with latest .NET 9 daily build #100862

Closed
dotnet/sdk
#40106
@martincostello

Description

@martincostello

Description

Using version 9.0.100-preview.4.24209.32 of the .NET SDK from the daily builds, an ASP.NET Core application fails to be published for native AoT due to the following errors:

  API failed with 3 error(s) (56.9s) → artifacts\bin\API\release\API.dll
    /_/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeDescriptor.cs(1569): Trim analysis error IL2026: System.ComponentModel.TypeDescriptor.NodeFor(Object,Boolean): Using member 'System.ComponentModel.TypeDescriptor.ComObjectType.get' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. COM type descriptors are not trim-compatible.
    /_/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeDescriptor.cs(1584): Trim analysis error IL2026: System.ComponentModel.TypeDescriptor.NodeFor(Object,Boolean): Using member 'System.ComponentModel.TypeDescriptor.ComObjectType.get' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. COM type descriptors are not trim-compatible.
    C:\Users\Martin.Costello\.nuget\packages\microsoft.dotnet.ilcompiler\9.0.0-preview.4.24209.5\build\Microsoft.NETCore.Native.targets(310,5): error MSB3073: The command ""C:\Users\Martin.Costello\.nuget\packages\runtime.win-x64.microsoft.dotnet.ilcompiler\9.0.0-preview.4.24209.5\tools\\ilc" @"C:\Coding\martincostello\api\artifacts\obj\API\release\native\API.ilc.rsp"" exited with code -1.

This appears to have been introduced by #100693.

I've never seen this API before, so my guess is that it's used somewhere by my dependency tree in code I'm not aware of. The errors from ILC don't help me identify exactly the call path where this is used from either. My guess would be maybe somewhere via the JSON source generator or maybe Request Delegate Generator. I did a quick search of the aspnetcore repo and here and didn't spot anything obvious to me as to what was using it.

Reproduction Steps

  1. Clone martincostello/api@9ecd932
  2. Run build.ps1 in the root of the repository.

Expected behavior

The application is published successfully using AoT.

Actual behavior

Publish fails with trim errors.

Regression?

Yes.

Known Workarounds

None.

Configuration

.NET SDK version 9.0.100-preview.4.24209.32

Other information

I found this with a private native AoT ASP.NET Core application, so I quickly hacked up a public-facing repo with a branch using the same SDK version to demonstrate the failure.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions