Importing a NuGet package to Azure DevOps

Sometimes, when first adopting Azure DevOps, you might find out about Azure Artifacts. With Azure Artifacts, you can host your NuGet packages (along with other package types) securely and easily. You end creating a feed. Then, it’s also easy to restore packages from your Azure DevOps pipelines.

Pre-Requisites

The Work

Once you have the NuGet CLI, upload a test package. Borrowing the instructions from this MSFT doc with a small modification for Azure DevOps.

nuget install HelloWorld -ExcludeVersion
nuget push -Source {NuGet package source URL} -ApiKey key HelloWorld\HelloWorld.nupkg

NuGet will probably ask you to login so that it can authenticate against Azure AD to use Azure DevOps. Once authenticated, you’ll see the package in the feed.

Lastly, you want to find the .nupkg file for the package you want to upload. On older .NET Framework projects, there’s usually a packages folder next to the solution file. If you’re moving from a self-hosted NuGet server, you might be able to fish the package from there.

Once you find the .nupkg, you can upload the package to Azure DevOps using the same method.

nuget push -Source {NuGet package source URL} -ApiKey az {your .nupkg file}