我正在 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/