2

If I am not wrong, it seems that I can publish an application in a single file, so I can get only only one exe file that contains all the needed to work.

First I have tried the publish wizard, and I check the option self contained, produce single file and ready to run. But I get about 300 files.

Then I have tried this command:

dotnet publish -r win-x64 -p:PublishSingleFile=true --self-contained true -p:IncludeNativeLibrariesInSingleFile=true -c Release -o publish

And I get the same result.

Also I have tried this:

dotnet publish -r win-x64 -p:PublishSingleFile=true true -p:IncludeNativeLibrariesInSingleFile=true -c Release -o publish

In this case I don't set the self contained because in somewhere I have read that is not needed when when single file is set, because if you want a single file, it is imply self contained. Anyway, I get always the same result.

My application is a wpf application in which I get an exe and I am using Net 5.

Which is the correct way to get a single .exe file?

Thanks.

PD: the documentation tells, in the publish wizard, I have to check the 3 checks that I check. But I don't get a unique file.

https://learn.microsoft.com/en-us/dotnet/core/deploying/single-file

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Álvaro García
  • 18,114
  • 30
  • 102
  • 193

1 Answers1

6

Looking at the Microsoft.NET.Publish.targets, it seems that the property got renamed to IncludeNativeLibrariesForSelfExtract and after I set this to True in a simple project, I indeed get a single file.

Other properties in this group, which may interest you are IncludeSymbolsInSingleFile and IncludeAllContentForSelfExtract.

EDIT: Github issue

Daniel Balas
  • 1,805
  • 1
  • 15
  • 20