[英]dotnet publish --self-contained option on Linux container
There are two ways to run a dot .net core application on a Linux based container.有两种方法可以在基于 Linux 的容器上运行点 .net 核心应用程序。
Getting a base image which has .net core framework install (on top of Linux image) & then copy code using dotnet publish.获取安装了 .net 核心框架的基础镜像(在 Linux 镜像之上),然后使用 dotnet publish 复制代码。
Use a Linux base image and then copy the dot net runtime & code using dotnet publish --self-contained
option.使用 Linux 基础映像,然后使用
dotnet publish --self-contained
选项复制 dot net 运行时和代码。
--self-contained [true|false] --自包含 [true|false]
Publishes the .NET runtime with your application so the runtime doesn't need to be installed on the target machine.与您的应用程序一起发布 .NET 运行时,因此不需要在目标计算机上安装运行时。 Default is true if a runtime identifier is specified and the project is an executable project (not a library project).
如果指定了运行时标识符并且项目是可执行项目(不是库项目),则默认值为 true。
Is there any advantage of using one option over other?使用一个选项比其他选项有什么优势吗?
Basically, you don't want self-contained as long as you don't need to.基本上,只要您不需要,您就不会想要自给自足。 The package will stay as small as possible which is what you want.
package 将尽可能小,这是您想要的。 Only when you're not sure the targeting platform will be able to host your system because of missing runtime components, you can add these runtime components with the self-contained option.
只有当您由于缺少运行时组件而不确定目标平台是否能够托管您的系统时,您才可以使用自包含选项添加这些运行时组件。
You can install the dotnet runtime on several platforms including Linux.您可以在多个平台上安装 dotnet 运行时,包括 Linux。 If you have control over doing so, I'd go for that option.
如果您可以控制这样做,我会选择 go 作为该选项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.