如何在 Windows 机器上为 Linux 编译 .NET Core 应用程序 [英] How to compile .NET Core app for Linux on a Windows machine

查看:42
本文介绍了如何在 Windows 机器上为 Linux 编译 .NET Core 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 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上运行吗?

I'm developing a .NET Core app on a Windows 10 machine (with Visual Studio 2015 update 3 + Microsoft .NET Core 1.0.1 VS 2015 Tooling Preview 2) which should published on an Ubuntu 16 machine. To do that, I have to move my source code to the end machine and compile it there, to get it to run. e.g. I'm not able to compile the code on windows and run it on linux. Question: Is there any way to compile the code on win machine and run it on linux?

推荐答案

使用 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

这篇关于如何在 Windows 机器上为 Linux 编译 .NET Core 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆