NativeAOT + PublishSingleFile + IncludeNativeLibrariesForSelfExtract #117986
-
Is there a reason the NativeAOT deployment model doesn't support Specifically, these properties don't "work" (it leaves native DLLs next to the EXE): <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<!-- Publishing -->
<CleanBeforeBuild>true</CleanBeforeBuild>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
<PublishAot>true</PublishAot>
<PublishTrimmed>true</PublishTrimmed>
<PublishSingleFile>true</PublishSingleFile>
<!-- Native DLL is 32-bit. -->
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<TrimMode>link</TrimMode>
</PropertyGroup> But if I remove |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Only reason is that it was never implemented. Extacting files to disk is very problematic (it's not reliable and has security implications). PublishSingleFile only has this functionality because when it first started in .NET 5 (or some other old release), it had to extract all managed assemblies to disk and run from there. Eventually the extraction stopped being used but the functionality was left for IncludeNativeLibrariesForSelfExtract. It was never implemented for Native AOT and it likely never will. |
Beta Was this translation helpful? Give feedback.
FWIW, native libraries can be statically linked into the executable. Then no separate files (extracted or not) are necessary.