Repository navigation
Description
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
- Clone martincostello/api@9ecd932
- Run
build.ps1in 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.
Activity
dotnet-policy-service commentedon Apr 10, 2024
Tagging subscribers to this area: @dotnet/area-system-componentmodel
See info in area-owners.md if you want to be subscribed.
vitek-karas commentedon Apr 10, 2024
@LakshanF
MichalStrehovsky commentedon Apr 10, 2024
FWIW, these are just warnings, but your publish has warnings as errors enabled.
martincostello commentedon Apr 15, 2024
Confirmed this as resolved with the original repo that I found the issue with using the
9.0.100-preview.4.24215.2SDK.