且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 Windows 机器上为 Linux 编译 .NET Core 应用程序

更新时间:2023-10-16 22:10:40

使用 dotnet build 命令,你可以指定 --runtime 标志

Using dotnet build command, you may specify --runtime flag

-r|--运行时

-r|--runtime < RUNTIME_IDENTIFIER >

要为其构建的目标运行时.有关您可以使用的运行时标识符 (RID) 的列表,请参阅 RID 目录.

Target runtime to build for. For a list of Runtime Identifiers (RIDs) you can use, see the RID catalog.

代表具体操作系统的 RID 通常遵循这种模式 [os].[version]-[arch]

RIDs that represent concrete operating systems usually follow this pattern [os].[version]-[arch]

例如,要为 Ubuntu 16.04 运行时使用构建项目及其依赖项:

Fo example, to build a project and its dependencies for Ubuntu 16.04 runtime use:

dotnet build --runtime ubuntu.16.04-x64