如何修复由Visual Studio默认项目模板创建的配置错误的web.config

问题描述 投票:0回答:1

我正在尝试设置CI,在部署后,生成的web.config文件出现问题。

我的主要问题是,要解决此web.config问题,我需要对Visual Studio中的项目或服务器执行什么操作。

我已经完成的步骤。

  1. 我已经在Visual Studio中创建了一个ASP.NET Core Web应用程序项目。 (它在使用IIS Express进行调试时运行)
  2. 我将其连接到Azure DevOps中的存储库。
  3. 使用默认的代理程序池构建Web工件
  4. 在将要托管站点的服务器上设置本地代理。
  5. 运行管道并通过。
  6. 已检查站点已部署。
  7. 尝试运行该站点并获得了500.19 Error

在Visual Studio中,我可以使用IIS Express运行该站点的本地主机,并且它可以正常工作。

在我的托管计算机上,它说web.config配置错误。

HTTP Error 500.19 - Internal Server Error

The requested page cannot be accessed because the related configuration data for the page is invalid.

Detailed Error Information:

Module
   IIS Web Core 

Notification
   Unknown 

Handler
   Not yet determined 

Error Code
   0x8007000d 

Config Error

Config File
   \\?\D:\Websites\[My Site Name]\web.config 

Requested URL
   http://[Some IP]:80/ 

Physical Path

Logon Method
   Not yet determined 

Logon User
   Not yet determined 

生成的web.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="dotnet" arguments=".\Web Content.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
    </system.webServer>
  </location>
</configuration>
<!--ProjectGuid: [A Guid]-->

使用'https://elmah.io/tools/configvalidator/'告诉我(8,125) The 'hostingModel' attribute is invalid - The value 'inprocess' is invalid according to its datatype 'String' - The Enumeration constraint failed.

该站点的先前版本有效(在将我的CI连接到它之前)。这是一个只有索引页面的简单网站,它具有以下web.config。

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <defaultDocument>
            <files>
                <clear />
                <add value="index.html" />
                <add value="Default.asp" />
                <add value="iisstart.htm" />
            </files>
        </defaultDocument>
    </system.webServer>
</configuration>

我的主要问题是,要解决此web.config问题,我需要对Visual Studio中的项目或服务器执行什么操作。

Build-YAML

trigger:
- master

pool:
  vmImage: 'windows-latest'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@1

- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: VSTest@2
  inputs:
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
    ArtifactName: 'ResearchWebsite'
    publishLocation: 'Container'

部署-YAML

trigger:
- master

pool: Default

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:



- task: DownloadPipelineArtifact@2
  inputs:
    buildType: 'specific'
    project: '[Some GUID]'
    definition: '8'
    buildVersionToDownload: 'latest'
    artifactName: 'ResearchWebsite'
    targetPath: '$(System.ArtifactsDirectory)'



- task: IISWebAppDeploymentOnMachineGroup@0
  inputs:
    WebSiteName: '[Site Name]'
    Package: '$(System.ArtifactsDirectory)\**\*.zip'
visual-studio continuous-integration web-config web-deployment
1个回答
0
投票

我必须在托管服务器上安装.NET Core 3.1

© www.soinside.com 2019 - 2024. All rights reserved.