Notes for me

NuGet Packages from Azure DevOps Repository to Azure DevOps Artifacts

As part of our move to Azure DevOps (from BitBucket and our own hosted Jenkins), we needed to host some internally used NuGet packages (packaged up third-party commercial libraries).

To do so, we created a new Project in Azure DevOps. As this project is going to be used for all our common libraries, we’ll also host the NuGet feed under Artifacts of this project as well. Note: you need to you have Artifacts extension enabled in Azure DevOps.

To create the Feed, click on Artifacts, then select New Feed. You’ll be asked for details of the new Feed. Note that the Name is important for later on:

Now that we’ve created the Feed, for each distinct library, we’ll also create a new repository under that project - see end of this post.

And for each repository, we created a new azure-pipelines.yml file like so:

trigger:
- master

pool:
  vmImage: 'VS2017-Win2016'

steps:
- task: NuGetCommand@2
  displayName: 'Build Packages'
  inputs:
   command: pack
   packagesToPack: 'src/*.nuspec'

- task: NuGetCommand@2
  displayName: 'Publish Packages'
  inputs:
   command: push
   publishVstsFeed: '[FEEDNAME]'

Some notes on the above:

  1. The NuGet packages are defined using nuspec files, hence the packagesToPack using src/*.nuspec.
  2. [FEEDNAME] needs to be replaced with the feed name for the NuGet feed we created at the start.
  3. We are not defining the version the generated NuGet packages. For our packages, the version is manually defined in the nuspec file.

Now all you should need to do is commit a change to a repository, and watch Azure DevOps build then publish your NuGet packages.

Appendix A - Create a New Repository Under Azure DevOps Project

To do so, go into Repos. In the breadcrumb at the top of the page, click on the dropdown link, then select “New repository”:

From now on, you can use the same dropdown to to switch the repositories.