Search code examples
azure-devopsazure-pipelinesazure-pipelines-tasks

I have a build pipeline in Azure DevOps for my github repo - where are the binaries?


Here is the (unedited from template) YAML definition of the pipeline:

# .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)'

This pipeline triggers when code is pushed to the master branch of my repo as intended - however I can't find the binaries that it built! How do I access them so I can share them with folks? Are the binaries unavailable because some of my unit tests failed, causing the build to fail, or something?


Solution

  • You need to publish those somewhere. It's up to you to choose what to keep at what stage of the pipeline. You can copy files into a directory, or just grab the whole $(Build.SourcesDirectory). You can also instruct the VsBuild task to redirect output to a specific directory by passing in the /p:OutputPath=$(Build.ArtifactStagingDirectory) commandline argument.

    You then have a few options:

    • GitHub Release task - Creates a release in GitHub and associates the files you want to it.

      # 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) - Links the selected files to the build as an artifact. You can download them from the pipeline's summary page in Azure DevOps. Works well in both Build and Release pipelines.

      # 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 and TFS) - Similar to Publish Pipeline Artifact, but less efficient in its transfers and specific to build pipelines. Can also publish to a file share instead of an attachment to the pipeline summary.

      # 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