The best solution in this case is probably Fody as mentioned by Sorashi, but if you don't want to use it Visual Studio has another trick up its sleeve; the poorly-documented IncludeAllContentForSelfExtract
property (in addition to everything from Option 1 in Sorashi's Answer).
This allows you to include any dll
dependencies from other projects in the same solution, as well as any external DLLs.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<!-- ...other properties... -->
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
</PropertyGroup>
</Project>
This is an easy way to produce a single executable for a multi-project solution; but it isn't suitable for CLI applications so keep that in mind.
Note that if you aren't using the dotnet
CLI tool, you'll have to create a publish profile to use this.
- R-Click on the project that produces the
exe
, and select the Publish... option.
- When prompted to choose a 'target', choose Folder.
On the next page you'll be prompted for a filepath; you can just use publish
if you don't want to dig through the bin
directory.
- Now that you have a publish profile, you should make sure that the configuration is correct.
Click More actions -> Edit OR Show all settings.
- Make sure that Deployment Mode is set to Self-contained, and that Produce single file is enabled.

- You can now click Publish in the top-right to create the executable.
If you want to use this publish profile in a CI script or something, you can use the /p:PublishProfile
option with dotnet publish
like this: dotnet publish /p:PublishProfile="<PUBXML>"
where <PUBXML>
is the path to your profile's pubxml
file, which is usually located in <PROJECT>/Properties/PublishProfiles/FolderProfile.pubxml