.NET SDK Version: 5.0.100
When publishing a single-file, self-contained .NET 5 executable, the resulting published files are not a true single-file output. Rather, the native assemblies (clrcompression.dll, clrjit.dll, etc) are placed next to the published executable, and must be copied along with it for it to properly run. This runs against the concept of a single-file publication, where this should not be needed - nor was it needed in .NET Core 3.1.
To reproduce,
dotnet new consoledotnet publish -c Release -r win-x64 --self-contained true -p:PublishSingleFile=truels bin/Release/net5.0/win-x64/publish/Observe the results. The native binaries that are published into this directory also include any native binaries that come from nuget packages, or part of the build.
Add a -p:IncludeNativeLibrariesForSelfExtract=true to your cli parameters and you end up with a single exe and single pdb file.
Per https://github.com/dotnet/designs/blob/main/accepted/2020/single-file/design.md#user-experience / Self-Contained Publish / Single-file publish Windows with Extraction
Thanks, that worked. It should probably be made a bit more obvious.
On Wed, 11 Nov 2020 at 07:30, Eric Williams notifications@github.com
wrote:
Add a -p:IncludeNativeLibrariesForSelfExtract=true to your cli parameters
and you end up with a single exe and single pdb file.Per
https://github.com/dotnet/designs/blob/main/accepted/2020/single-file/design.md#user-experience
/ Self-Contained Publish / Single-file publish Windows with Extraction—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/dotnet/sdk/issues/14489#issuecomment-725230086, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AAR3MTHA2SHRM226D4XKATDSPIVQ3ANCNFSM4TRDQBOA
.
I came here, because I had exactly the same problem and did not know what was going on. Maybe @motowilliams's link should somehow be added to https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-publish. Certainly, the IncludeNativeLibrariesForSelfExtract option should be mentioned there.
I'm trying to figure this out for a Blazor Server app. I raised the issue here but they directed me to the dotnet SDK tracker. I've tried adding the InlcudeNativeLibrariesForSelfExtract flag and it does reduce the list of files that don't get packed into the single-file extractor. 
So I run the following:
dotnet publish Damselfly.Web -r osx-x64 -c Release --self-contained true /p:PublishSingleFile=true 
          /p:PublishTrimmed=true /p:Version=$version /p:IncludeNativeLibrariesForSelfExtract=true
But there's still content being missed out - I get multiple files and the wwwroot folder not included. The expected behaviour is that there should be a single file (Damselfly.Web) with everything included in it.
Damselfly.Core.pdb
Damselfly.Web
Damselfly.Web.Views.pdb
Damselfly.Web.pdb
appsettings.Development.json
appsettings.json
libSkiaSharp.dylib
wwwroot