Create a Azure Artifact Feed for private NuGet Packages
If you have ever been part of a company that has a few private dll’s floating around where the only way to get it is to go look on OneDrive, you are in the right place. I had the exact issue and I came up with a solution for the team that stopped them from scurrying around to get the dll’s they needed to get projects up and running on their local development environments. Even though it was documented… its always a thing.
I went searching for a solution and with the fact that we had a Azure DevOps environment, I spent some time to set up a feed to stop the need of this ever happening again. (It still happens :D )
This is going to focus on C# so NuGet Packages but it should be very similar for other packages (NPM). If the dll's you have is not already packaged in a NuGet package, have a look at this Package a DLL as a NuGet Package article where I guide you to get it packaged
Creating the Feed
Creating a feed on Azure DevOps is really a simple thing to do and can be accomplished with a few simple steps. Here are those steps:
- Go to the
Artifactstab on the left hand side - Click on the
+ Create Feedbutton on the right hand top (TheCreate new feedsidebar should be opened) - Complete the
Namefield, for exampleMyCompanyFeed - Under
Visibility, select the option which isMembers of {YourOrgName}, this ensures that all members of your organization can use the packages of the feed. - Tick the checkbox under
Upstream Sourcesto include public sources. I do this because it simplifies the NuGet setup on my project on my development machine, but you can leave this off. Scopelets you set the scope to the project, again this is to contain it within the context of the project
That’s it! Your done, your feed is ready to be used in projects!
Publish the Package to the Feed
Because we are working with NuGet, we will be using that to connect to the feed. Azure DevOps is awesome here where it give quite good instructions on the site itself on how to connect.
After you created the feed there should be a blue button in the middle screen Connect to Feed. On the next screen you will see there are a lot of options on the right-hand side. Select the NuGet.exe option to get good instructions on how to add the feed to the project, restore the project and how to publish the packages.
Now you do need the nuget.exe executable to have this work and Azure DevOps is very kind to give you the links to get the tools, in the right hand top there is a button to the NuGet.exe download page.
To add the feed to our global NuGet sources list, we will be using the following command:
nuget sources add -name MyCompanyFeed -source "https://pkgs.dev.azure.com/yourorgname/yourprojectname/_packaging/yourfeedname/nuget/v3/index.json"The source is the value attribute on the nuget.config file under the Project setup section.
Now, lets push our company packages
Once you have the package, use the command that you see on the page to publish that package to the feed you created.
nuget.exe push -Source "MyCompanyFeed" -ApiKey az PrivateCompany.nupkgFinishing up
Next up is to connect to the feed in your project and do a restore, exactly as is on the Connect to Feed page.
Now commit this and the rest of the team will be eternally grateful to you for removing the hunting session when they need to set up the project on a new development environment or a new team member joins the team.
I hope you like the article and please let me know if you have any comments or ideas how I can improve on this, should it be needed.
Thanks for reading!