Describe the bug
As discussed here, publishing a single-file application for osx-x64/osx-arm64 with -p:IncludeNativeLibrariesForSelfExtract=true doesn't embed libsodium.dylib in the executable as of v1.0.19.1+ of the libsodium NuGet package. The same issue occurs with libsodium.a for linux-musl-x64/linux-musl-arm64. This wasn't a problem with v1.0.19. win-x64, win-x86, win-arm64, linux-x64, linux-arm64, and linux-arm don't seem to be affected.
As it's unclear why this is happening, I'm opening an issue here to try and get some help from .NET maintainers.
To reproduce
- Download the latest .NET 8 SDK installer.
- Create a folder to house the project and navigate to it in the terminal.
- Create a new console project with
dotnet new console --framework net8.0.
- Install the libsodium NuGet package with
dotnet add package libsodium --version 1.0.19.1.
- Do a self-contained, single-file publish for macOS with
dotnet publish -c Release -r osx-x64 -p:PublishSingleFile=true -p:PublishTrimmed=true -p:PublishReadyToRun=true -p:IncludeNativeLibrariesForSelfExtract=true --self-contained true. The extra options are just what I normally use.
- Navigate to the printed path (
bin\Release\net8.0\osx-x64\publish\), and you'll see there's a libsodium.dylib file.
- Delete the files in this folder and return to the original project directory.
- Change the libsodium package version with
dotnet add package libsodium --version 1.0.19.
- Use
dotnet publish again as before.
- Navigate to the printed path again, and you'll see there's no
libsodium.dylib file. This is what you want.
Further technical details
Tried on a Windows machine with the latest .NET 8/9 SDKs and on a macOS machine with the latest .NET 8 SDK.
.NET SDK:
Version: 9.0.101
Commit: eedb237549
Workload version: 9.0.100-manifests.3068a692
MSBuild version: 17.12.12+1cce77968
Runtime Environment:
OS Name: Windows
OS Version: 10.0.22631
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\9.0.101\
.NET workloads installed:
There are no installed workloads to display.
Configured to use loose manifests when installing new manifests.
Host:
Version: 9.0.0
Architecture: x64
Commit: 9d5a6a9aa4
.NET SDKs installed:
8.0.404 [C:\Program Files\dotnet\sdk]
9.0.101 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
None
Environment variables:
Not set
global.json file:
Not found
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
Describe the bug
As discussed here, publishing a single-file application for
osx-x64/osx-arm64with-p:IncludeNativeLibrariesForSelfExtract=truedoesn't embedlibsodium.dylibin the executable as of v1.0.19.1+ of the libsodium NuGet package. The same issue occurs withlibsodium.aforlinux-musl-x64/linux-musl-arm64. This wasn't a problem with v1.0.19.win-x64,win-x86,win-arm64,linux-x64,linux-arm64, andlinux-armdon't seem to be affected.As it's unclear why this is happening, I'm opening an issue here to try and get some help from .NET maintainers.
To reproduce
dotnet new console --framework net8.0.dotnet add package libsodium --version 1.0.19.1.dotnet publish -c Release -r osx-x64 -p:PublishSingleFile=true -p:PublishTrimmed=true -p:PublishReadyToRun=true -p:IncludeNativeLibrariesForSelfExtract=true --self-contained true. The extra options are just what I normally use.bin\Release\net8.0\osx-x64\publish\), and you'll see there's alibsodium.dylibfile.dotnet add package libsodium --version 1.0.19.dotnet publishagain as before.libsodium.dylibfile. This is what you want.Further technical details
Tried on a Windows machine with the latest .NET 8/9 SDKs and on a macOS machine with the latest .NET 8 SDK.