Azure DevOps 任务,用于在 IIS Web 应用部署过程中将证书放置到特定目录



我已经为.Net解决方案实现了Azure DevOps Pipeline。管道很简单,是构建并将解决方案放在"$(build.artifactstagingdirectory(">

在发布下,我正在从构建中获取Artifice并将其推送到开发阶段,这是结构:

IIS Deployment (tasks)
1. IIS Web App management
2. Extract file solution (Cos i have to do few Replace token in few files)
- $(System.DefaultWorkingDirectory)/_App-ASP.NET-CI/drop/Web.zip
- $(System.DefaultWorkingDirectory)/_App-ASP.NET-CI/Web-unzip
3. Download .cer files (download certificate from secure location under library)
- $(System.DefaultWorkingDirectory)/_App-ASP.NET-CI/Web-unzip
4. IIS Web App Deploy
- $(System.DefaultWorkingDirectory)/_App-ASP.NET-CI/Web-unzip

问题是: 目前,.cer文件放置在 Web 部署过程的根目录中。

预期: 放置在"证书"文件夹中而不是根文件夹中

我可以看到在部署过程中,解决方案首先部署在目标计算机上,然后将.cer文件放置在根目录中。我不确定为什么以及如何将它们移动到所需的目录。

以下是 YAML 代码:

steps:
- task: ExtractFiles@1
displayName: 'Extract files '
inputs:
archiveFilePatterns: '$(System.DefaultWorkingDirectory)_DevOpsTestProject-ASP.NET-CIdropWeb.zip'
destinationFolder: '$(System.DefaultWorkingDirectory)_DevOpsTestProject-ASP.NET-CIWeb-unzip'

steps:
- task: mattlabrum.build-task.custom-build-task.downloadsSecureFile@0
displayName: 'Download Certs'
inputs:
fileInput: 'certnew_64.cer'
targetPath: '$(System.DefaultWorkingDirectory)_DevOpsTestProject-ASP.NET-CIWeb-unzip'

steps:
- task: CopyFiles@2
displayName: 'Copy Files to: $(System.DefaultWorkingDirectory)_DevOpsTestProject-ASP.NET-CIWeb-unzip'
inputs:
SourceFolder: '$(System.DefaultWorkingDirectory)_DevOpsTestProject-ASP.NET-CIWeb-unzip'
Contents: '*.cer'
TargetFolder: '$(System.DefaultWorkingDirectory)_DevOpsTestProject-ASP.NET-CIWeb-unzipCertificates'

steps:
- task: ArchiveFiles@2
displayName: 'Archive $(System.DefaultWorkingDirectory)_DevOpsTestProject-ASP.NET-CIWeb-unzip'
inputs:
rootFolderOrFile: '$(System.DefaultWorkingDirectory)_DevOpsTestProject-ASP.NET-CIWeb-unzip'
includeRootFolder: false
archiveFile: '$(System.DefaultWorkingDirectory)_DevOpsTestProject-ASP.NET-CIdropWeb-unzip.zip'

steps:
- task: IISWebAppDeploymentOnMachineGroup@0
displayName: 'IIS Web App Deploy'
inputs:
WebSiteName: '$(Parameters.WebsiteName)'
Package: '$(System.DefaultWorkingDirectory)_DevOpsTestProject-ASP.NET-CIdropWeb-unzip.zip'
TakeAppOfflineFlag: True
XmlVariableSubstitution: true

在库存溢出上遇到了这个解决方案,解决了这个问题。

Azure DevOps Build Task:创建一个 zip 文件,其中包含与 Visual Studio Publish 相同的内容

我必须简化 Pipeline 中的构建输出目录,以便在发布过程中轻松地将重构文件和目录作为目标。

最新更新