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

查看:75
本文介绍了如何将.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/zh-cn/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发布命令负责打包可部署的.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发布-配置发布--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天全站免登陆