Pushing NuGet Packages to an Azure DevOps private feed

Posted written by Paul Seal on July 25, 2024 Azure

Today I was struggling with pushing some pre-existing NuGet packages to a private Azure DevOps NuGet feed. I asked my colleague Sai for help and he taught me how to do it.

First you need to create a personal access token in the user settings. Give it permissions to read, write and manage packages.

You need to make a note of the name of that token, keep it simple, don't use spaces or special characters as you will use it in the command line.

Then get a copy of the token.

Now you can use this name and token as the username and password for connecting to the NuGet feed.

Lets say the name of my personal Access Token was PS and the Token value was 123456abc

Next, download the NuGet.exe from https://www.nuget.org/downloads and put it in the folder where the NuGet package is on your machine.

To connect to the NuGet feed we enter this in the command line:

.\nuget.exe sources add -Name FeedNameHere  -Source "https://pkgs.dev.azure.com/OrganisationNameHere/ProjectNameHere/_packaging/FeedNameHere/nuget/v3/index.json" -username PS -password 123456abc

Connect to the NuGet feed

Once that has worked we will have a new NuGet source to push to.

Now we just run this command to push our package up to NuGet.

.\nuget.exe push -Source "LocalFeedNameHere" -ApiKey thisCanBeAnyText MyPackage.1.0.0.nupkg

Push the package to the private NuGet feed