从 VS 2017 发布 .net 核心应用程序

问题描述:

我正在 Visual Studio 2017 Community Edition 下创建一个新的解决方案,它主要是一个 .net 核心 Web 应用程序.

I am creating a new solution under Visual Studio 2017 Community Edition, it's mainly a .net core web application.

它完美运行,完全没问题,但我们想将它部署到 Debian 机器上并独立运行,因此我们将运行时标识符添加到项目中.到目前为止一切顺利,当我们想要为我们拥有的任何平台发布应用程序(到目录)时,问题就出现了,没有指定目标平台的选项,创建的发布文件只是 .net 程序集,没有原生模块.

It works perfectly, no problem at all, but we want to deploy it to a Debian machine and to be self contained, so we added the runtime identifiers to the project. So far so good, the problem comes when we want to publish the application (to a directory) for any of the platforms we have, there is no option to specify the target platform and the publish files created are just the .net assemblies, no native modules.

当然,如果我们使用 dotnet publish -r (platform) 它会按预期工作,它会创建正确的平台文件,一切似乎都没有问题,但是必须去命令非常烦人行编译它.

Of course if we use dotnet publish -r (platform) it works as expected, it creates the correct platform files and everything seems to be ok, but is very annoying to have to go to command line to compile it.

那么问题是,如何使用 Visual Studio 2017 为具体平台发布自包含应用程序?它甚至可能还是仍然缺失?

So the question is, how can be published a self-contained application for a concrete platform using Visual Studio 2017? Is it even possible or this is still missing?

目前 VS2017 不会这样做,所以你必须放到命令行并运行它.

Currently VS2017 won't do this so you have to drop to the command line and run this.

dotnet publish -c release -r ubuntu.14.04-x64

显然是为了你的 debian 风格替换 ubuntu.

Obviously replacing ubuntu for your debian flavour.

这也在我的 csproj 文件中,您可能也需要它.

Also this is in my csproj file and you might need it too.

<OutputType>Exe</OutputType>