Open cfbao opened 1 month ago
Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas See info in area-owners.md if you want to be subscribed.
Cc @sbomer FYI - I believe this is caused by ILCompiler package carrying its own copy of inbox assemblies and replacing everything with them. We run the usual .NET SDK assembly resolution that comes up with everything correctly, and then run ILCompiler targets logic that replaces every assembly that has a copy in the ILCompiler package with the ILCompiler version.
Bugs like this are the reason why we'd like to switch PublishAot to using the NativeAOT runtime pack (because then we get out of the business of replacing pieces of runtime pack with assemblies that are in the ILCompiler package). But this is blocked on SDK for reasons described in https://github.com/dotnet/sdk/pull/37872#issuecomment-1935428434 and numerous emails with the SDK team.
Description
Native AOT builds don't include new APIs in core .NET libraries that are provided by NuGet packages.
Reproduction Steps
Minimal repro repo: https://github.com/cfbao/dotnet-native-aot-bug
Expected behavior
Published native executables can run successfully.
Actual behavior
Exception thrown at runtime, e.g.
Regression?
No response
Known Workarounds
Updating the project to target .NET 9 resolves this issue, but this may not be viable for all projects.
Configuration
Reproduced with
Unclear if specific to the OS.
Other information
This issue only happens with native AOT. A self-contained and fully trimmed (but not native AOT compiled) build doesn't have this same issue, and can use the new APIs at runtime successfully.