-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Labels
Milestone
Description
.NET SDK 5.0.100-rc.2.20473.8
- Include a native library in a .NET project's output:
<ItemGroup> <None Include="..."> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> </ItemGroup>
- Add a P/Invoke:
static void Main(string[] args) { NativeLib.HelloWorld(); } [DllImport("NativeLib")] private static extern void HelloWorld();
- Publish as single file:
dotnet publish -p:PublishSingleFile=true ...- with different combinations of
--self-containedandIncludeNativeLibrariesForSelfExtract
- with different combinations of
- Depending on publish configuration, application fails with
DllNotFoundException--self-contained true -p:IncludeNativeLibrariesForSelfExtract=false(default)- Linux: fails
- Windows: works - directory with the single-file executable ends up on native search path because the native runtime bits are there
--self-contained false -p:IncludeNativeLibrariesForSelfExtract=false- Linux: fails
- Windows: works - default library load logic will look next to the running executable
--self-contained true -p:IncludeNativeLibrariesForSelfExtract=true- Linux: fails
- Windows: works - extraction directory ends up on native search path because the native runtime bits are extracted there
--self-contained false -p:IncludeNativeLibrariesForSelfExtract=true- Linux: fails
- Windows: fails
This works with 3.1 single-file.
Setting IncludeAllContentForSelfExtract=true (with the fix in #42435) works.
cc @vitek-karas