Skip to content

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

Closed
dotnet/sdk
#40106

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.

Activity

  1. dotnet-policy-service commented on Apr 10, 2024

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @dotnet/area-system-componentmodel
    See info in area-owners.md if you want to be subscribed.

  2. added
    untriaged
    on Apr 10, 2024
  3. vitek-karas commented on Apr 10, 2024

    @vitek-karas
    Member
  4. self-assigned this
    on Apr 10, 2024
  5. MichalStrehovsky commented on Apr 10, 2024

    @MichalStrehovsky
    Member

    Publish fails with trim errors.

    FWIW, these are just warnings, but your publish has warnings as errors enabled.

  6. removed
    untriaged
    on Apr 11, 2024
  7. martincostello commented on Apr 15, 2024

    @martincostello
    MemberAuthor

    Confirmed this as resolved with the original repo that I found the issue with using the 9.0.100-preview.4.24215.2 SDK.

  8. locked and limited conversation to collaborators on May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions