InnerWorks Logo
Return to main siteReturn to main site

How to Setup a Private NuGet Feed in Azure DevOps Pipelines

How to Setup a Private NuGet Feed in Azure DevOps Pipelines

Greg Margol

27 Aug 2021 • 2 min read

Developer, Greg shares his 4-step process on how to set-up a private NuGet feed in Azure Devops Pipelines

Innerworks is coming soon...

This blog was originally published on our previous Cogworks blog page. The Cogworks Blog is in the process of evolving into Innerworks, our new community-driven tech blog. With Innerworks, we aim to provide a space for collaboration, knowledge-sharing, and connection within the wider tech community. Watch this space for Innerworks updates, but don't worry - you'll still be able to access content from the original Cogworks Blog if you want. 

Cogworks have been working on a way to build a NuGet package that solves one particular issue.

You may have come across "all-in-one" packages that attempt to solve everything at the same time but I've found these are not as effective.

Fragmentation will allow you to include the functionality that you really need in your project so that you don't end up with a library of unnecessary things!

We're using MyGet to host the small internal packages for now. If you're using Azure DevOps Pipelines (as we do for CI/CD), you might need to use packages from your private NuGet feed to build projects; this post will guide you through the pipeline configuration for this setup. 

1. In the Azure DevOps portal, add a new service connection for your private NuGet feed.


This is the only thing you need to do manually in the Azure DevOps portal UI.


- Head to your project page and select project settings in the bottom left-hand corner.

- Select service connections.

Below shows the username and password approach to set it up. 



- Add a new NuGet service connection (don’t forget to copy its’ll need this later).




2. Create NuGet.config file in your project code repository.


- Keep files related to continuous integration in the Deployment directory; you can place them anywhere in the solution structure that matches your needs.

- Keep the relative solution path to this file on-side, you will also need this for a later step...




3. Set up your NuGet feeds here.


   <?xml version="1.0" encoding="utf-8"?>    <configuration>        <packageSources>            <add key="" value="" protocolVersion="3" />            <add key="Myget feed" value="" />        </packageSources>    </configuration>

4. Update your azure-pipelines.yaml

- Here we're showing part of azure-pipelines.yaml file responsible for restoring NuGet packages. Make sure you use the correct path to NuGet.config file.



   steps:    - task: NuGetToolInstaller@1    - task: NuGetCommand@2        inputs:        restoreSolution: '$(solution)'


   steps:    - task: NuGetAuthenticate@0      inputs:        nuGetServiceConnections: 'MyGet feed'    - task: NuGetToolInstaller@1    - task: NuGetCommand@2      inputs:        restoreSolution: '$(solution)'        feedsToUse: 'config'        nugetConfigPath: 'Deployment/NuGet.config'        externalFeedCredentials: 'MyGet feed'


That's it, now just push your changes to your repository and trigger a build

Community tech aid

Innerworks and Cogworks are proud to partner with Community TechAid who aim to enable sustainable access to technology and skills needed to ensure digital inclusion for all. Any support you can give is hugely appreciated.