2

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?

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
ekolis
  • 6,270
  • 12
  • 50
  • 101

2 Answers2

1

You are missing the task of "copy and publish artifact" task. This task will copy the resulting compiled binaries as artifact to be downloaded later.

For more information about this copy and publish artifact, visit the official documentation: https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/copy-and-publish-build-artifacts?view=azure-devops

UPDATE: the copy and publish artifact task is deprecated in Azure DevOps, please use the newest one: https://learn.microsoft.com/en-us/azure/devops/pipelines/artifacts/build-artifacts?view=azure-devops&tabs=yaml

Use this in your YAML: PublishBuildArtifacts@1

Eriawan Kusumawardhono
  • 4,796
  • 4
  • 46
  • 49
1

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

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
  • Thanks! I had to change the targetPath of the publish pipeline artifact to limit it to only including the binaries I want; it was including the whole solution folder by default. So now I have a build being generated - is there any easy way to link the latest build so folks can download it without having to click around a bunch in Azure DevOps? – ekolis Aug 31 '19 at 22:08
  • You can publish it as a Universal Package in Package management, that way you can redirect folks to a single page that shows all successfully generated packages. Or publish them to GitHub as a release. – jessehouwing Sep 01 '19 at 06:52
  • I'd rather not clutter up github with a bunch of releases every time I push changes - what's a universal package and how do I create it? – ekolis Sep 01 '19 at 15:25
  • https://learn.microsoft.com/en-us/azure/devops/pipelines/artifacts/universal-packages – jessehouwing Sep 01 '19 at 19:38
  • That looks really confusing, I think I'll just go with the github option... – ekolis Sep 01 '19 at 19:47
  • It basically creates a nuget package feed where you can push any (hence universal) package to. But, as I said before. You have options! – jessehouwing Sep 01 '19 at 19:51