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):

Get hands-on with 1400+ tech skills courses.