Publish packages to

Azure DevOps Services | Azure DevOps Server 2022 - Azure DevOps Server 2019 | TFS 2018 is a package manager that enables developers to share reusable code. A NuGet package is a compressed file with .nupkg extension that contains compiled code that can be consumed in other projects. Packages hosted in are available to all developers around the world.


  • Any version of Visual Studio 2019 and the .NET Core workload.
  • dotnet CLI. If you don't have it already, install the .NET Core SDK.
  • Register for a free account on if you don't have one already.

Create a project

You can use your own .NET project to build and generate a NuGet package, or create a new basic .NET class library as follows:

  1. In Visual Studio, select File, New, then Project.

  2. Select the Class Library (.NET Standard) template and select Next.

  3. Name your project and your solution then select a location to save the project locally. Select Create when you are done.

    Create a class library project

The template class library is sufficient to create a NuGet package so for this tutorial we will use the existing template and we won't be writing any additional code.

Set up and generate a package

  1. Select your project from the solution explorer, right-click and select properties then Package.

  2. Fill out the form and make sure that your package id is unique otherwise it may conflict with existing packages on A common naming convention is something like: Company.Product.Feature. If you want to generate your package every time you build your project, select the Generate NuGet package on build checkbox.

    Configure package properties

  3. Select your project from the solution explorer, right-click then select Pack to generate your .nupkg package.

    Generate package

  4. Check the status of the pack command in the output window.

    Pack output

Generate an API key

Now that we created our nupkg package, we are almost ready to publish it, but first we need to generate an API key to connect to the API.

  1. Sign in to your account or create one if you haven't.

  2. Select your user name icon then select API Keys.

  3. Select Create then enter a name for your key. Give your key a Push new packages and package version scope, and enter * in the glob pattern field to select all packages. Select Create when you are done.

    Create API key

  4. Select Copy and save your API key in a secure location. We will need this key to publish our NuGet package.

    Copy API key

Publish a package to

You can publish your package using the web UI, dotnet CLI, or nuget.exe CLI. We are going to focus on publishing packages by using the command line in this section. You will need the name of your package, an API key, and the source URL to do so.

  1. In an elevated command prompt, navigate to the folder containing your nupkg package.

  2. Run the following command to publish your package to Replace the placeholders with your package name and API key.

    dotnet nuget push <packageName> --api-key <APIKey> --source
  3. The output of the previous command should look something like this.

    Publish package output