我正在尝试设置CI,在部署后,生成的web.config文件出现问题。
我的主要问题是,要解决此web.config问题,我需要对Visual Studio中的项目或服务器执行什么操作。
我已经完成的步骤。
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'
我必须在托管服务器上安装.NET Core 3.1。