Understanding Self Contained Vs Framework Dependent Deployment
Today in this article we shall learn the differences between Self Contained Vs Framework Dependent Deployment i,e, SCD and FDD deployment methodologies. These deployment techniques are generic and can be used for Console or ASP.NET API or WebAPI or any MVC project.
Today we will cover below aspects in the article,
Applications created using the .NET framework can be published in two different modes, and the mode affects how a user runs your app.
When installing the application to the new environment, if the target machine has the required .NET version already installed then the application built using .NET should work without any issue.
If the required .NET core SDK/runtime is not installed then one can follow any of the below approaches discussed. An approach using Self-content deployment doesn’t require a .NET Core SDK/Runtime to be installed on the target machines.
Let’s see both the approaches in detail,
FDD- Build Application as FDD- Framework-dependent deployment
If you are building an application using Framework dependent deployment (FDD) approach, then it is expected that the target server or environment has the .NET Core SDK and runtime installed.
Publishing an app as FDD produces a cross-platform binary as a DLL file, and a platform-specific executable.
Deployable mainly consist of below,
- Application-specific DLLs or EXE
- Dependencies like NUGET or Third party references
- Resource files if any
Example of Framework-dependent deployment
Below FDD deployment has produced below binaries,
As shown above, my deployable consist of Dlls like ExternalDLL1, ExternalDLL2, and Nuget packages like Newtonsoft, etc
All the system DLLs and supported Runtime/SDK will be used from the below folder on the target machine,
.NET Runtime
C:\program files\dotnet\shared\{runtime-type}\{version}\ C:\program files\dotnet\host\
Example: runtime framework DLLs like hostfxr.dll can be found in the below-shared location depending on the target .NET version used,
Advantages of Framework-dependent deployment
There are below advantages of using this approach,
- Small deployment – With this option, you create your deployable consisting of the actual app and its dependencies i.e mainly these part libraries or NuGet package used by your application.
- Leverage the latest patched runtime.
Disadvantages of Framework-dependent deployment
There are below disadvantages of using this approach,
- .NET Core installation needed – Prior installation of the required .NET Core runtime is needed.
- .NET version may change the behavior of the app – With this option, it is possible that the application will use the latest available version on the target machine which could affect application behavior to some extent.
Example :
Your application target and uses the 5.0.0 version then let’s say your machine gets patched with the 5.0.1 version. In such cases, your application will start using the 5.0.1 version, since it’s the highest patch and the runtime available for the given major version of 5.0.x.
The above behavior can be changed by using a custom configuration like app roll forward settings.
SCD- Build Application as Self-contained Deployment
If you are building an application using an approach, then you are making your application deployable is self-content, and can run on its own.
This can be achieved by building your application using the below build command,
Self-contained Deployment For Linux
Sample command for self Content Deployment for Linux
dotnet publish -r linux-x64 --self-contained true -c release
Self-contained Deployment For Windows10
Sample command for self Content Deployment
dotnet publish -r win10-x64 --self-contained true -c release
OR
For Windows Server
dotnet publish -r win-x64 --self-contained true -c release
Deployable mainly consist of below,
- Application-specific DLLs or EXE
- Dependencies like NUGET or Third party references
- Resource files if any
- System DLLs
- Runtime/SDK
The user of your app isn’t required to download and install it. NET, as your application, will now have everything to run as self-content.
Self-contained Deployable Example
Below SCD deployment has produced below binaries,
Size of my application deployable now increased to 64 MB due to all application,System DLLS and Runtime/SDK are packaged together.
Advantages of Self-contained Deployable Example
With this approach, you achieve the below advantages,
- The app doesn’t required to download and install. NET.
- Application is isolated from other .NET apps
- The application doesnt use a locally installed shared runtime even if available
- You are able to control which target version you want to use.
Disadvantages of Self-contained Deployable Example
- The large size of deployment -The app includes the .NET runtime and all the dependencies making your deployable size tune to the maximum.
- .NET version compatibility – For any specific framework version-related chnages including major, minor versions require new deployment.
References:
Do you have any comments or ideas or any better suggestions to share?
Please sound off your comments below.
Happy Coding !!
Please bookmark this page and share it with your friends. Please Subscribe to the blog to receive notifications on freshly published(2024) best practices and guidelines for software design and development.