ASP.Net Core fails to publish in IIS

Error scene

Enter image description

This error is very confusing, and following the prompts to the command line to execute the result is also a failure

Enter image description

I am used to the convenience and great collection of VS. There are all kinds of pits when it is released.

Solution

  1. Add the default Web.config in VS and uncomment the default content.
<?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>

Register the **aspNetCore** module in the configuration file and configure its runtime path.

processPath ="dotnet"

arguments="./Applicationxxx.web.dll" here is your project file

Among them **stdoutLogFile ** can be deleted, here is the configuration of outputting detailed log, the default is in the running directory

If the default configuration file is invalid, try the second step

2. Add a configuration section to the web project file (.csproj)

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

Referenced articles

.Net Core Runtime Installation Instructions

IIS deploys ASP.Net Core 502.5 errors and solutions

ASP.Net Core application If your application is an ASP.Net Core application, you will find that after installing the .net core runtime using the above method, your program still cannot run normally. An error similar to the following will appear:

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

This is because only the .Net Core runtime is installed, not the ASP.NET Core runtime.

Of course, you can also bring it with you when you publish:

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

Or you can add it directly at runtime. Download it, then extract it to the dotnet installation directory

related

There is also an ASP.Net Core project in the website published by IIS. Without inheriting Identity authentication, it can be published and accessed normally. Although adding PropertyGroup to the project solves the problem, it always feels that it is not the real answer.

Or Microsoft.ApplicationInsights.AspNetCore is a package that needs to be referenced when publishing in IIS

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325199623&siteId=291194637