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

标签 c# linux .net-core asp.net-core-webapi

我正在 Windows 10 机器上开发一个 .NET Core 应用程序(使用 Visual Studio 2015 更新 3 + Microsoft .NET Core 1.0.1 VS 2015 Tooling Preview 2),它应该在 Ubuntu 16 机器上发布。为此,我必须将我的源代码移动到终端机器并在那里编译,以使其运行。例如我无法在 Windows 上编译代码并在 Linux 上运行它。问:有什么办法可以在win机上编译代码,在linux上运行?

最佳答案

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

-r|--runtime < RUNTIME_IDENTIFIER >

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

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

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

dotnet build --runtime ubuntu.16.04-x64

关于c# - 如何在 Windows 机器上为 Linux 编译 .NET Core 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41533592/

相关文章:

linux - Crontab 没有运行

linux - 在 Linux 中阻塞 UART 串​​口的 I/O 写操作

c# - log4net-RollingFileAppender-XmlLayoutSchemaLog4j 未登录 .Net Core 3

c# - 在 Powershell 中运行时与在 Visual Studio 中运行时的 HttpClient 并发行为不同

c# - 委派任务并在任务完成时收到通知(在 C# 中)

c# - 如何覆盖 DataGridRow 模板中的 AlternatingRowBackground?

linux - 在ss -s中,内核计数器实际计数的是什么?

c# - 在 ServiceStack 应用程序中使用时,Application Insights 不跟踪异常

c# - try-catch block

c# - Excel - 列宽与多个相加不匹配