Developer, Greg shares his 4-step process on how to set-up a private NuGet feed in Azure Devops Pipelines
Hello, youve stumbled into the old Cogblog archives
We've switched our blogging focus to our new Innerworks content, where tech community members can share inspiring stories, content, and top tips. Because of this, old Cogworks blogs will soon be deleted from the site, so enjoy it while you can. A few of these might refer to images in the text, but those have been deleted already sorry. Some of these subjects will return, some aren't relevant anymore, and some just don't fit the unbiased community initiative of Innerworks.
If you'd like to take on this subject yourself please submit a new blog!
Farewell Cogworks Blog 💚
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 name...you’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="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" /> <add key="Myget feed" value="https://www.myget.org/F/cogworks/api/v3/index.json" /> </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.
Before:
steps: - task: NuGetToolInstaller@1 - task: NuGetCommand@2 inputs: restoreSolution: '$(solution)'
After:
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
- nuget
- packages
- feed
- task
- file
- solution
- project
- devops
- Azure DevOps
- MyGet
- private nuget feed
- umbraco gold partner
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.