1

这是管道的(未经模板编辑)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)'

当代码按预期推送到我的仓库的主分支时,此管道会触发 - 但是我找不到它构建的二进制文件!我如何访问它们以便与人们分享它们?二进制文件是否不可用,因为我的一些单元测试失败,导致构建失败,还是什么?

4

2 回答 2

1

您缺少“复制和发布工件”任务的任务。此任务会将生成的编译二进制文件复制为稍后下载的工件。

有关此复制和发布工件的更多信息,请访问官方文档:https ://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/copy-and-publish-build-artifacts?view =天蓝色devops

更新:复制和发布工件任务在 Azure DevOps 中已弃用,请使用最新的:https ://docs.microsoft.com/en-us/azure/devops/pipelines/artifacts/build-artifacts?view=azure- devops&tabs=yaml

在您的 YAML 中使用它:PublishBuildArtifacts@1

于 2019-08-31T19:41:56.077 回答
1

您需要在某处发布这些内容。您可以选择在管道的哪个阶段保留什么。您可以将文件复制到目录中,或者只获取整个$(Build.SourcesDirectory). /p:OutputPath=$(Build.ArtifactStagingDirectory)您还可以通过传入命令行参数来指示 VsBuild 任务将输出重定向到特定目录。

然后你有几个选择:

  • GitHub 发布任务- 在 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
    

在此处输入图像描述

  • 发布管道工件 (Azure DevOps) - 将选定文件作为工件链接到构建。你可以从 Azure DevOps 中管道的摘要页面下载它们。在构建和发布管道中运行良好。

    # 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 Pipeline Artifact,但其传输效率较低且特定于构建管道。还可以发布到文件共享而不是管道摘要的附件。

    # 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
    

在此处输入图像描述

于 2019-08-31T19:43:09.517 回答