'.Net 6 publish produces both an exe and a dll and self-contained does too much
I'm publishing a .Net 6 application for win-x64 with many dependencies, and i notice the publish generates two files: a MyApp.exe and MyApp.dll. From what i understand it's a choice that comes from the multi-platform nature of .Net, but in my scenario i now have two files to deploy and update instead of one.
I've tried self-contained publish, but it bundles also the dependencies and bugfix updates will have to download many MB for just the main exe change.
Is there a way to bundle together only MyApp.exe and MyApp.dll without the dependencies?
Solution 1:[1]
You can add PublishSingleFile true in your .csproj
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<PublishSingleFile>true</PublishSingleFile>
<SelfContained>true</SelfContained>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<PublishReadyToRun>true</PublishReadyToRun>
</PropertyGroup>
Or pass it in during the command line publish
dotnet publish -r win-x64 p:PublishSingleFile=true --self-contained true
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Zach Sexton |
