After long time waiting since dotnet5.0, the dotnet6.0 is generatring the true single file if wanted. That means, developers can build the application as a self-contained (that worked also before dotnet5.0) and all framework dependent assemblies can be compiled into the single file. Previous version of dotnet (and core) have been collecting the application intyhe single executable host file, the framework in another dll and the runtime in another dll. Now, all of them are linked together and if wanted trimmed.
Following figure shows all modules loaded by the application that is built as a single file. The fine on the top is the application that contains all required code linked and trimmed in the single file. Note, all other loaded DLLs are Operative System DLLs that are not a part of dotnet runtime.
To create a such build, developers can use Visual Studio 2022 or to use the project file. Following figure shows all required settings in the VS.
Following snippet shows the configuration of the project file that can be used to produce the single file.
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>net6.0</TargetFramework> <PublishSingleFile>true</PublishSingleFile> <SelfContained>true</SelfContained> <RuntimeIdentifier>win-x64</RuntimeIdentifier> <PublishReadyToRun>true</PublishReadyToRun> </PropertyGroup> </Project>
You can also take a look on this article: https://docs.microsoft.com/en-us/dotnet/core/deploying/single-file