使用exe在IIS上部署ASP.NET Core

3
ASP.NET Core似乎将Kestrel服务打包在.exe文件中。
我查看了所有有关在IIS中托管ASP.NET Core应用程序的说明,似乎都提到在DLL中有一个入口点(Main()方法)。
我该如何分阶段设置.exe文件,以便IIS识别它?
我没有看到发布过程的这一部分,并且我认为这应该是ASP.NET Core的默认输出,因此这应该是非常常见的步骤。
2个回答

5
我们通过在web.config文件中添加以下内容来实现这一点。请注意processPath属性。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath=".\MyDotNetCoreApp.exe" />
  </system.webServer>
</configuration>

1
首先创建一个不带托管代码的 AppPool:

enter image description here

然后在IIS中创建一个网站,我将其设置为端口8888(因为默认网站使用端口80),将其指向Web发布目录:

enter image description here

该网站使用没有托管代码的AppPool:

enter image description here

在Web.Config文件中:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath="dotnet" arguments=".\AdviserPaymentList.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
  </system.webServer>
</configuration>

然后浏览到 http://localhost:8888/Home,如果有问题,请查看日志。


谢谢!我注意到你的参数引用了一个.dll文件,而ASP.NET Core默认输出一个exe。你刚刚改变了你的项目为DLL吗?有没有一种方法来托管一个exe? - micahhoover
你实际上没有回答关于托管已发布的_exe_文件的问题 :) - asgerhallas

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接