In a previous post we saw how to use NuGet Package Explorer to create a NuGet package. There are several different ways to distribute your packages between your development teams. You could use a USB drive or send it by email (just kidding). The easiest way would probably be to use a file share on some server in your on-premise network. These days however everything is moving to the cloud. So, let’s see how we can create our own NuGet feed with Azure DevOps. 

This assumes you have an Azure account, you can get one for free at https://dev.azure.com/. Select the project in your organization where you want to host the NuGet feed.  

Azure Artifacts are used to host package feeds. In the Artifacts tab, create a new feed. Choose a name, set visibility and if you want to include public sources. 

Connect to the feed and select “NuGet.exe” in the next screen. This will show you steps required for when you build NuGet packages directly from your solution. We’ll be pushing package from our drive with the NuGet.exe tool. You can get it through the “Get the tools” button or from https://www.nuget.org/downloads. Save the nuget.exe in the directory of your packages on your drive or make it available through your Windows PATH variables.  

Note: When ‘Upstream sources’ is checked, any packages downloaded from these sources will be copied to your personal feed. The reasoning behind this is, if for some reason the upstream source is down, your development teams can still download the packages from your personal feed.
However these copied packages do count for your storage billing. Free tiers get 2GB of storage, which is probably more then you’ll need, but it’s important to keep an eye on. 

Copy the feed url from the “Project setup” and the command line string from the “Publish packages” to a notepad. In the publish string replace the Source by the url and <packagePath> by the location of your NuGet package.  

nuget.exe push -Source
“https://pkgs.dev.azure.com/BlogDemos/NuGetDemo/_packaging/DemoFeed/nuget/v3/index.json” -ApiKey az “eu.allphi.company.style.1.0.0.nupkg”

Run it from a command prompt, you’ll be asked to login (once) and your package will be pushed. 

Now you can add this NuGet feed in Visual Studio as a package source in the NuGet package manager using the same url. 

It’s that simple. You can host any NuGet package in your own personal feed. 

Written by Bruno Latte

Overzicht