Conversation
|
There is no public API to detect whether the app has been published with NativeAOT is a collection of individual behaviors (single-file, no dynamic code, AOT pre-compilation, trimming, IL trimmed from the final binary, ...). We recommend that libraries check for these individual behaviors. |
|
Maybe just add the |
There are no plans to add one. We have capability checks: for example, when accessing If one is just curious if PublishAot was in the project for informational purposes like it seems here (not for <ItemGroup>
<AssemblyMetadata Include="BuildProperties.PublishAot" Value="$(PublishAot)" />
</ItemGroup>to the project file, and using: foreach (var a in Assembly.GetEntryAssembly().GetCustomAttributes<AssemblyMetadataAttribute>())
if (a.Key == "BuildProperties.PublishAot")
Console.WriteLine($"PublishAot: '{a.Value}'");to check for it. I'd remove the |
I meant the If I don't think we can do that Anyways, @kasperk81 hasn't even described the problem that this code produced. |
Assembly.Location is true for PublishSingleFile as well |
Right, and it looks like we incorrectly check that for |
|
Superseded by #2799. |
current detection fails to differentiate between PublishSingleFile and PublishAot because they both return null from Assembly.Location.
@adamsitnik @jkotas is there any existing app model API available to make this detection less fragile?