# Shared vs. Self-Contained .NET Deployments .NET Core and .NET applications (not Framework) can be deployed using two different methods. They can be self-contained, or use the shared framework. Self-contained applications are deployed with all the necessary .NET dlls, while the shared-framework deployments reply on the already installed .NET. Similarly to the traditional .NET Framework applications, shared-framework deployments cannot be started unless the required framework is already installed. **The obvious benefit of a self-contained application is that the user doesn't have to install any extra runtime, one drawback is that the deployment is much bigger (around 100 MiB for hello world as opposed to around 300 KiB)**. To reduce the size one can resort to [[Trimming Compiler Output in Dotnet|Trimming Compiler Output in .NET]]. **Another less obvious drawback is that with self-contained applications the developer is responsible for releasing a new version whenever a .NET security patch is released.** **Self-contained deployments have to be runtime specific, and require setting the `RuntimeIdentifier`** (see [[#MSBuild Properties]]). Note that an executable (.exe on Windows) is published whenever a `RuntimeIdentifier` is specified. Executables are not cross-platform (as opposed to the dll binaries which are, and are ran using the dotnet tool which, obviously, needs to be installed. Executables can be generated for both deployment scenarios, but are always generated for self-contained applications. For a list of runtime identifiers see the [RID Catalog](https://docs.microsoft.com/en-us/dotnet/core/rid-catalog). ## MSBuild Properties | Property | Description | | ------------------- | ------------------------------------------------------------------------------------------------------------ | | `RuntimeIdentifier` | Makes a deployment runtime specific. Sets `SelfContained` to true unless it isexplicitly set to false. | | `SelfContained` | Makes a deployment self-contained. This required specifying a `RuntimeIdentifier` | | `RollForward` | Determines which framework the app should run in when in shared-framework mode. See [[#RollForward Options]] | ### `RollForward` Options The `RollForward` property can be set to one of these values: - `LatestPath`, `LatestMinor`, and `LatestMajor` run the app using the latest framework available, even if the explicitly defined framework is present. - `Minor` (default) will run the application in the lowest higher minor version, if the explicitly specified version is not available. - `Major` will run the application in the lowest higher major version, if the explicitly specified version is not available. - `Disable` will cause the runtime to fail unless the explicitly specified version is available. ## Sources - [[Deep-Dive Into .NET Core Primitives, Part 2 The Shared Framework]] - [[Deep-Dive Into .NET Core Primitives, Part 3 runtimeconfig.json in Depth]] - [[Application Publishing - .NET]]