如何将 .NET Core 2 MVC Web 应用程序编译为 EXE? [英] How to compile a .NET Core 2 MVC web app to an EXE?

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

问题描述

我想在 Visual Studio 2017 中创建独立的 Kestrel .exe DotNetCore 2.0 MVC Web API 应用程序,但是我找不到任何文档.关于如何将其编译为自包含的 .exe(不使用 dotnet run).

I want to create Kestrel stand alone .exe DotNetCore 2.0 MVC Web API application in Visual Studio 2017, however I can't find any documentation. On how to compile it as a self contained .exe (not using dotnet run).

此处的 Microsoft 文档:https://docs.microsoft.com/en-us/dotnet/articles/core/deploying/deploy-with-vs 只涵盖了一个控制台应用程序,对 .csproj 进行修改后没有任何区别

The Microsoft documentation here: https://docs.microsoft.com/en-us/dotnet/articles/core/deploying/deploy-with-vs only covers a console application, and following the modifications to the .csproj makes no difference

<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>

(注意这不是 .NET Core 1.x 问题)

(note this is not a .NET Core 1.x question)

推荐答案

dotnet publish 命令负责打包可部署的 .Net Core 应用程序.它将构建应用程序并将其所有依赖项复制到输出目录.

dotnet publish command is responsible for packing deployable .Net Core application. It will build the application and copy all its dependencies to the output directory.

最简单的运行方式是切换到项目目录(csproj所在的目录)执行:

The easisest way to run it is to switch to the project directory (the one where csproj resides) and execute:

dotnet publish --configuration Release --runtime win-x64

dotnet publish --configuration Release --runtime win-x64

根据您的需要更改构建配置和运行时版本.您可以在我参考的文档中了解其他命令行设置.

Change the build configuration and runtime version accoring to your needs. You could learn other command line settings on the doc I have referenced.

这篇关于如何将 .NET Core 2 MVC Web 应用程序编译为 EXE?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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