我正在开发Windows WPF应用程序,该应用程序已在Azure Devops中建立了构建管道。我的问题是,在成功完成构建之后,我似乎找不到任何方法来下载工件。
是否有可能以某种方式获得包含所有已构建文件的zip链接。如何获取文件?我不想发布到NPM或NuGet或类似的东西,只需立即下载到我的桌面即可。
谢谢!
编辑:这是我的构建配置
trigger:
- master
pr:
- master
pool:
vmImage: 'VS2017-Win2016'
variables:
solution: '**/*.sln'
buildPlatform: 'x64'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller@0
displayName: 'NuGet Tool Installer'
- task: NuGetCommand@2
displayName: 'Restore NuGet dependencies'
inputs:
restoreSolution: '$(solution)'
- task: VSBuild@1
displayName: 'Build $(buildConfiguration) $(buildPlatform)'
inputs:
solution: '$(solution)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: CopyFiles@2
displayName: 'Copy files'
inputs:
Contents: '_buildOutput\\**\\*.dll'
TargetFolder: $(Build.ArtifactStagingDirectory)
- task: PublishBuildArtifacts@1
displayName: 'Publishing artifact drop'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: 'drop'
publishLocation: 'filePath'
targetPath: '$(Build.ArtifactStagingDirectory)\\outdir\\$(Build.DefinitionName)\\$(Build.BuildNumber)'
- task: DownloadBuildArtifacts@0
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'drop'
downloadPath: '$(System.ArtifactsDirectory)'
答案 0 :(得分:2)
您可以使用2种方式:
您需要知道构建的ID。
然后,您可以使用以下格式的下载链接(默认为删除):
https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}/artifacts?artifactName=drop&api-version=5.0&%24format=zip
更新(如果您使用yaml):
如果要处理构建结果并具有“工件”按钮,则必须使用“发布工件”任务。
您可以将其发布到Azure DevOps(默认情况下):
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: drop'
inputs:
PathtoPublish: 'Your folder with build results'
您还可以将结果发布到某些文件共享中:
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: drop'
inputs:
PathtoPublish: 'Your folder with build results'
publishLocation: FilePath
TargetPath: '\\my\share\$(Build.DefinitionName)\$(Build.BuildNumber)'
更新2:
如果尝试以以下格式下载您的文件:
https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}/artifacts?artifactName=drop&api-version=5.0
您将获得带有url的json:
您可以在网址末尾添加“&%24format = zip”并获取一个zip文件:
更新3
这是我的Yaml构建定义的一部分,是从标准构建转换而来的:
- task: CopyFiles@2
displayName: 'Copy Files to: $(build.artifactstagingdirectory)'
inputs:
SourceFolder: '$(build.sourcesdirectory)'
Contents: '**\bin\$(buildConfiguration)\**'
TargetFolder: '$(build.artifactstagingdirectory)'
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: drop'
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)'