We can create three types of deployment package for .NET Core applications. In the upcoming paragraphs, let me explain it one by one.

1. Framework-dependent deployment (FDD)

  • It is the default deployment model for .NET Core applications. It fully relies on the .NET Core framework, which is installed on the target machine.

  • In this approach, the size of the deployment package is very small because it contains only the application code and the third-party libraries.

  • Most importantly, the FDD package can be executed by .NET Core runtime on any operating system.

  • This feature is available from .NET Core 2.0 version and the following command is used to create FDD build artifacts.

    > dotnet publish -c Release

2. Framework-dependent executable (FDE)

  • This approach is almost similar to FDD, but the only difference is that we can create separate build artifacts for each platform.

  • This feature is available from .NET Core 2.2 version and the following command is used to create FDE build artifacts.

    > dotnet publish -c Release -r <RUNTIME_IDENTIFIER> --self-contained false

3. Self-contained deployment (SCD)

  • This model does not rely on the presence of shared components of the .NET Core framework, which is installed on the target machine.

  • The size of the deployment package is relatively very large as it contains .NET Core libraries, application code, and third-party libraries. For example, a simple console application contains more than 100 dlls, and its size comes around 70MB.

  • This feature is available from .NET Core 2.2 version and the following command is used to create SCD build artifacts.

    > dotnet publish -c Release -r <RUNTIME_IDENTIFIER>

  • To merge all libraries in a single file, .NET Core preview 3.5 introduces a new flag called PublishSingleFile. As such, if we set the mentioned flag as true, we will get only one exe file, but the build package size of the simple console application still comes around 70MB.

    > dotnet publish -c Release -r <RUNTIME_IDENTIFIER> /p:PublishSingleFile=true

  • To reduce the build artifacts size, .NET Core preview 3.6 introduces a new flag called PublishTrimmed. As such, if we set the mentioned flag as true, it will remove all unused dll files from the build package. In this approach, the build package size of the simple console application comes around 28 MB.

    > dotnet publish -c Release -r <RUNTIME_IDENTIFIER> /p:PublishSingleFile=true /p:PublishTrimmed=true

Reference: RUNTIME_IDENTIFIER