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

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

问题描述

我正在Windows 10计算机(使用Visual Studio 2015更新3 + Microsoft .NET Core 1.0.1 VS 2015工具预览2)上开发.NET Core应用程序,该应用程序应在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构建命令,您可以指定--runtime标志

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

-r |-运行时< RUNTIME_IDENTIFIER>

-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天全站免登陆