我正在尝试配置一个 CI,它将生成 NuGet 包作为 Azure DevOps 上的工件(稍后将推送到我的 NuGet 服务器)。
为此,我在 Azure DevOps(YAML 版本)上使用了 Builds Pipelines。
我有 3 个应该构建包的项目。我正在使用 NuGetCommand@2完成这项任务:
- task: NuGetCommand@2
inputs:
command: pack
packagesToPack: $(Build.SourcesDirectory)/src/HTS_MessageEngine.Communication/HTS_MessageEngine.Communication.csproj
majorVersion: $(majorVersion)
minorVersion: $(minorVersion)
patchVersion: $(patchVersion)
versioningScheme: byPrereleaseNumber
但是,对于每个项目,我必须将这个块复制 3 次。有没有办法在 packagesToPack 参数中指定项目数组?到目前为止,每个包的版本都相同,所以我不需要三个不同的块......
注意:这3个项目都是3个NetStandard,包构建的属性直接存储在csproj中
最佳答案
您可以使用每个功能(如果此时它完全可用):
# my-template.yml
parameters:
steps:
- ${{ each project in parameters.projects }}:
- task: PublishBuildArtifacts@1
displayName: 'Publish ${{ project }}
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)/${{ project }}.zip'
# ci.yml
steps:
- template: my-template.yml
parameters:
projects:
- test1
- test2
此功能的 Github PR:https://github.com/Microsoft/azure-pipelines-yaml/pull/2#issuecomment-452748467
关于continuous-integration - 将数组作为输入传递给 Azure DevOps YAML 任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54541602/