question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PublishSingleFile=true does not result in a true single-file publish

See original GitHub issue

General

.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,

  1. dotnet new console
  2. dotnet publish -c Release -r win-x64 --self-contained true -p:PublishSingleFile=true
  3. 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:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

9reactions
svdHerocommented, Nov 23, 2020

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.

9reactions
motowilliamscommented, Nov 11, 2020

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found