.NET CLI - dotnet publish: framework-dependent vs self-contained
Автор: Mohammad Sahebhonar
Загружено: 2022-01-08
Просмотров: 2067
Описание:
https://msahebhonar.com/CSharp/Progra...
Up to now, we saw how to develop, build, test, and run a project using .NET CLI. Now, we want to publish our application and its dependencies for deployment to a hosting system. In the finale of .NET CLI, we are going to use the .NET command-line interface to publish our application.
Based on how we want to run the app, we can publish the application in two different modes. If the hosting machine has .NET runtime, we can choose the framework-dependent mode to publish the app. The output includes only the application itself and its dependencies.
For .NET Core 3.1 or higher, the framework-dependent executable is the default mode for the dotnet publish command. The publish folder contains a cross-platform dll which is named after our project. The dotnet publish command also creates an executable for the current operating system and CPU architecture.
We can publish an app as framework-dependent that targets a specific platform. In this case, we need to use the runtime identifier along with the --no-self-contained option.
The framework-dependent mode has several advantages. Only the app and its dependencies are distributed, so the size of the deployment is small. We can run the app on different platforms. And the app uses the latest runtime installed on the target platform. However, the framework-dependent mode requires pre-installing of the .NET runtime on the host machine.
In the second mode, we can publish the app as a self-contained executable. The output includes the application, its dependencies, as well as the .NET runtime and libraries. So, we can run the application on a machine that doesn’t have the .NET runtime installed. In this mode, we need to specify the target runtime identifier as well as --sc option.
Since our app includes the .NET runtime and all of its dependencies the download size is greater than a framework-dependent version. Also, in the self-contained mode, greater hard drive space is required. As a caveat in this mode, the .NET Runtime can only be upgraded by releasing a new version of our app.
We can run the platform-specific executable directly. However, to run the cross-platform dll, we need to call the dotnet command.
00:00 - framework-dependent mode
01:54 - framework-dependent targets runtime
02:55 - advantages of framework-dependent mode
03:25 - self-contained mode
04:55 - run app.dll
Повторяем попытку...
Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: