PublishSingleFile=true does not result in a true single-file publish
See original GitHub issueGeneral
.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 console
dotnet publish -c Release -r win-x64 --self-contained true -p:PublishSingleFile=true
ls 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.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:10 (2 by maintainers)
Top Results From Across the Web
PublishSingleFile does not produce a single executable
I have a .Net Core 3 console application that i'm trying to publish as a self contained single executable. I've been able to...
Read more >Create a single file for application deployment - .NET
Publish a single file application using the dotnet publish command. Add <PublishSingleFile>true</PublishSingleFile> to your project file.
Read more >Self-Contained Single-File does not produce a single file
I have a small .Net 5 console application with no dependencies on third party components. I have set it up to publish as...
Read more >Publishing a self-contained single-file .NET 5 executable
Assuming you want to target Windows: dotnet publish -c Release -r win-x64 --self-contained true -p:PublishSingleFile=true ...
Read more >Too many dlls when publishing dotnet
If you want a single file, you should use the PublishSingleFile option which will merge all the dependency DLLs into the output .exe....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.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