ASP.Net Core 在 IIS 中发布失败

错误现场

输入图片说明

这个错误让人很迷茫,按照提示去命令行执行结果也是失败

输入图片说明

习惯了 VS 的便利和好大全,发布时是各种坑啊

解决办法

  1. 在VS中添加默认的 Web.config ,取消默认的注释内容。
<?xml version="1.0" encoding="utf-8"?>
<configuration>

  <!-- To customize the asp.net core module uncomment and edit the following section. 
  For more info see https://go.microsoft.com/fwlink/?linkid=838655 -->
  
  <system.webServer>
    <handlers>
      <remove name="aspNetCore"/>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
    </handlers>
    <aspNetCore processPath="%LAUNCHER_PATH%"   arguments="%LAUNCHER_ARGS%"
             stdoutLogEnabled="false"  stdoutLogFile=".\logs\stdout" />
  </system.webServer>
</configuration>

配置文件中注册 **aspNetCore ** 模块,并配置其运行时路径。

processPath ="dotnet"

arguments="./Applicationxxx.web.dll" 这里是你的项目文件

其中 **stdoutLogFile ** 可以删除,这里是输出详细日志的配置,默认在运行目录下

如果默认的配置文件无效,可尝试第二步

2.在Web项目文件(.csproj)中添加配置节

<PropertyGroup>
 <PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest> 
</PropertyGroup>

参考的文章

.Net Core Runtime安装说明

扫描二维码关注公众号,回复: 99922 查看本文章

IIS部署ASP.Net Core 502.5错误和解决

ASP.Net Core应用程序 如果你的是ASP.Net Core应用程序,你会发现使用上述方式安装了.net core运行时之后,你的程序还是无法正常运行。会出现大概类似下面这样的错误:

Error: An assembly specified in the application dependencies manifest (ZKEACMS.WebHost.deps.json) was not found: package: 'Microsoft.ApplicationInsights.AspNetCore', version: '2.1.1' path: 'lib/netstandard1.6/Microsoft.ApplicationInsights.AspNetCore.dll' This assembly was expected to be in the local runtime store as the application was published using the following target manifest files: aspnetcore-store-2.0.0-linux-x64.xml;aspnetcore-store-2.0.0-osx-x64.xml;aspnetcore-store-2.0.0-win7-x64.xml;aspnetcore-store-2.0.0-win7-x86.xml

这是因为只安装了.Net Core运行时,而没有安装ASP.NET Core运行时。

当然,你也可以在发布的时候带上它:

<PropertyGroup>
 <PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest> 
</PropertyGroup>

或者直接在运行时里面补上它就可以了。下载它,然后解压到dotnet的安装目录

相关

在IIS发布的网站里同样还有 ASP.Net Core 项目,没有继承 Identity 身份认证,就可以正常发布和访问,虽然在项目工程中添加 PropertyGroup 解决了问题,但总觉得不是真实的答案

或者 Microsoft.ApplicationInsights.AspNetCore 是在IIS中发布需要引用的包

猜你喜欢

转载自my.oschina.net/HenuToater/blog/1799698