【发布时间】:2021-11-06 15:23:18
【问题描述】:
我正在尝试将 ASPNET Core 应用程序的发布管道设置到本地 IIS 虚拟机 (VM)。
除了将文件部署到 IIS 服务器之外,一切都按预期工作,但它没有提取文件,而是将 zip 文件放在错误的文件夹位置。例如,应用程序文件应该部署到%SystemDrive%\sites\{mysite} - 这是在 IIS Web 应用程序管理部分下的发布管道中设置的(如下所示)。
在服务器上,这是部署到正确的位置,但不是将所有应用程序文件部署到 \sites\{mysite},而是创建两个额外的文件夹,然后像这样删除一个名为“WebApp.zip”的 zip 文件,( %SystemDrive%\sites\{mysite}\{artifactName}\{artifactName}\WebApp.zip)
我如何才能真正将网站应用程序文件部署到\sites\{mysite} 目录?
我确实有一个 yaml 文件,如下所示。任何帮助将不胜感激。
trigger:
- development
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:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest@2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: DotNetCoreCLI@2
displayName: Build
inputs:
command: build
projects: '**/*.csproj'
arguments: '--configuration $(buildConfiguration)'
- task: DotNetCoreCLI@2
inputs:
command: publish
publishWebProjects: True
arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)'
zipAfterPublish: True
- task: PublishPipelineArtifact@1
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)'
artifactName: '{artifactName}' #removed the name for this post
- task: IISWebAppDeploymentOnMachineGroup@0
displayName: 'IIS Web App Deploy'
inputs:
WebSiteName: '{removed}' #removed the name for this post
Package: '$(System.DefaultWorkingDirectory)'
RemoveAdditionalFilesFlag: true
XmlVariableSubstitution: True
编辑:
我已将我的 yaml 更新为如下所示。如果我不包含PublishPipelineArtifact@1 任务,则不会将任何文件复制到 IIS 服务器。现在也部署到这样的文件夹结构:{artifact}\{artifact}\(all of the files),这是一个改进,但我仍然不需要两个 {artifact} 文件夹,我只需要部署在网站根目录中的文件。
非常感谢任何帮助,因为到目前为止我已经在这方面花费了相当多的时间。
更新的 Yaml:
trigger:
- development
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
- task: DotNetCoreCLI@2
displayName: Build
inputs:
command: build
projects: '**/*.csproj'
arguments: '--configuration $(buildConfiguration)'
- task: PublishPipelineArtifact@1
inputs:
targetPath: $(System.DefaultWorkingDirectory)/bin/Release/net5.0
artifact: {artifactName}
【问题讨论】:
标签: asp.net-core azure-devops azure-pipelines devops