Publishing a Single-File App
Learn about publishing a .NET application as a single-file, including specifying flags, handling file extensions on macOS, managing dependencies, and reducing app size.
To publish as a “single” file, we can specify flags when publishing. With .NET 5, single-file apps were primarily focused on Linux because there were limitations in Windows and macOS that meant true single-file publishing was not technically possible. With .NET 6 or later, we can create proper single-file apps on Windows.
Publishing on systems with .NET already installed
Suppose we can assume that .NET is already installed on the computer on which we want to run our app. In that case, we can use the extra flags when we publish our app for release to say that it does not need to be self-contained and that we want to publish it as a single file (if possible), as shown in the following command (which must be entered on a single line):
dotnet publish -r win10-x64 -c Release --no-self-contained /p:PublishSingleFile=true
This will generate two files: DotNetEverywhere.exe
and DotNetEverywhere.pdb
. The .exe
file is the executable. The .pdb
file is a program debug database file that stores debugging information. ...