azure-devops - 我在 Azure DevOps 中有一个用于我的 github 存储库的构建管道 - 二进制文件在哪里?

标签 azure-devops azure-pipelines azure-pipelines-tasks

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

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

最佳答案

您需要将它们发布到某个地方。您可以选择在管道的哪个阶段保留什么。您可以将文件复制到目录中,或者直接获取整个 $(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
    

enter image description here

  • Publish Pipeline Artifact (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 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
    

enter image description here

关于azure-devops - 我在 Azure DevOps 中有一个用于我的 github 存储库的构建管道 - 二进制文件在哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57740930/

相关文章:

azure-devops - Azure Pipelines - 重新部署相同版本

Azure 自定义任务输入 - 需要有条件

azure-devops - 链接到 Azure DevOps (VSTS) 中文件的特定版本中的一行代码

Azure 开发运营 : release version

Azure DevOps - 服务主体不工作

当我们使用派生列表达式生成器时,Azure 数据工厂管道无法使用 cosmos DB,它的列数不超过 19

azure-pipelines - 具有多个存储库的 VSTS 构建

azure-devops - Azure DevOps 代理没有选择基于 yml 的作业

azure - 有没有办法在 azure 管道构建中查看更多详细信息?

azure - 无法包围 Azure 管道变量中的第一个串联字符串