这是管道的(未经模板编辑)YAML定义:
# .NET Desktop
# Build and run tests for .NET Desktop or Windows classic desktop solutions.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/apps/windows/dot-net
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)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest@2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
当代码按预期被推送到我的仓库的主分支时,该管道触发-但是我找不到它构建的二进制文件!如何访问它们,以便与人们共享?由于我的某些单元测试失败,导致构建失败或其他原因,二进制文件不可用吗?
答案 0 :(得分:1)
您缺少“复制和发布工件”任务的任务。此任务将复制生成的已编译二进制文件作为工件,以供以后下载。
有关此副本和发布工件的更多信息,请访问官方文档:https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/copy-and-publish-build-artifacts?view=azure-devops
更新:Azure DevOps中不推荐使用复制和发布工件任务,请使用最新版本:https://docs.microsoft.com/en-us/azure/devops/pipelines/artifacts/build-artifacts?view=azure-devops&tabs=yaml
在您的YAML中使用它:PublishBuildArtifacts@1
答案 1 :(得分:1)
您需要将这些内容发布到某个地方。由您决定在管道的哪个阶段保留什么内容。您可以将文件复制到目录中,也可以仅抓取整个$(Build.SourcesDirectory)
。您还可以通过传递/p:OutputPath=$(Build.ArtifactStagingDirectory)
命令行参数来指示VsBuild任务将输出重定向到特定目录。
然后您有一些选择:
GitHub Release task-在GitHub中创建一个发行版,并将您想要的文件与之关联。
# GitHub Release
# Create, edit, or delete a GitHub release
- task: GitHubRelease@0
inputs:
gitHubConnection:
#repositoryName: '$(Build.Repository.Name)'
#action: 'create' # Options: create, edit, delete
#target: '$(Build.SourceVersion)' # Required when action == Create || Action == Edit
#tagSource: 'auto' # Required when action == Create# Options: auto, manual
#tagPattern: # Optional
#tag: # Required when action == Edit || Action == Delete || TagSource == Manual
#title: # Optional
#releaseNotesSource: 'file' # Optional. Options: file, input
#releaseNotesFile: # Optional
#releaseNotes: # Optional
#assets: '$(Build.ArtifactStagingDirectory)/*' # Optional
#assetUploadMode: 'delete' # Optional. Options: delete, replace
#isDraft: false # Optional
#isPreRelease: false # Optional
#addChangeLog: true # Optional
#compareWith: 'lastFullRelease' # Required when addChangeLog == True. Options: lastFullRelease, lastRelease, lastReleaseByTag
#releaseTag: # Required when compareWith == LastReleaseByTag
Publish Pipeline Artifact(Azure DevOps)-将所选文件作为工件链接到构建。您可以从Azure DevOps中管道的摘要页面下载它们。在Build和Release管道中都可以很好地工作。
# Publish pipeline artifact
# Publish (upload) a file or directory as a named artifact for the current run
- task: PublishPipelineArtifact@1
inputs:
targetPath: '$(Pipeline.Workspace)'
artifact: 'Output'
Publish Build Artifact(Azure DevOps和TFS)-与发布管道工件相似,但传输效率较低,并且特定于构建管道。也可以发布到文件共享而不是管道摘要的附件。
# Publish build artifacts
# Publish build artifacts to Azure Pipelines or a Windows file share
- task: PublishBuildArtifacts@1
inputs:
#pathtoPublish: '$(Build.ArtifactStagingDirectory)'
#artifactName: 'drop'
#publishLocation: 'Container' # Options: container, filePath
#targetPath: # Required when publishLocation == FilePath
#parallel: false # Optional
#parallelCount: # Optional