简体   繁体   English

dotnet publish --Linux 容器上的自包含选项

[英]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 核心应用程序。

  1. 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 复制代码。

  2. 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.

相关问题 .NET Core 自包含发布引用 - 如何删除未使用的? - .NET Core self-contained publish references - how to remove unused? 在 Windows 中发布便携式和独立的 .NET 应用程序 7 - Publish Portable and Self-Contained .NET Application in Windows 7 尝试发布自包含时出现 VS Studio 2019 错误 - VS Studio 2019 error when trying to publish self-contained “不支持”在不指定 RuntimeIdentifier 的情况下构建或发布自包含应用程序 - It is “not supported” to build or publish a self-contained application without specifying a RuntimeIdentifier .NET 4.8 没有为 Linux 创建一个独立的文件 - .NET 4.8 not creating a self-contained file for Linux 独立的普通纪念品 - Self-contained generic memento dotnet publish -c 发布到自包含的 exe 不起作用 - dotnet publish -c Release to a self contained exe doesn't work error NETSDK1031:不支持在不指定 RuntimeIdentifier 的情况下构建或发布自包含应用程序 - error NETSDK1031: It is not supported to build or publish a self-contained application without specifying a RuntimeIdentifier 发布用于Linux体系结构的.NET Core C#自包含应用程序 - Publishing .NET Core C# self-contained application for linux architecture 引用的项目是一个非独立的可执行文件。 自包含的可执行文件不能引用非自包含的可执行文件 - The referenced project is a non self-contained executable. A non self-contained executable cannot be referenced by a self-contained executable
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM