Use NuGet with Azure DevOps Services feeds

Azure DevOps Services

Note

This page covers interactive scenarios. In Azure Pipelines, use the NuGet step to restore and publish packages.

Note

The Azure Artifacts service recommends NuGet 4.8.2 or later. However, Azure Artifacts also supports legacy NuGet 2.x clients. For a complete list of the latest clients, see the NuGet distribution page.

Add a feed to NuGet 4.8.2 or later

NuGet 4.8.2 and later supports the Azure Artifacts Credential Provider, which automatically acquires feed credentials when needed.

  1. Navigate to your feed (or create a feed if you haven't).

  2. Select Connect to feed:

Connect to feed button in the upper-right of the page

  1. Select NuGet.exe under the NuGet header

  2. Select Get the tools in the top right corner

  3. Follow steps 1 and 2 to download the latest NuGet version and the credential provider.

  4. Follow the instructions in the Project setup, Restore packages, and Publish packages sections to publish.

    NuGet publish instructions in the Connect to feed

    Note

    You can also paste the Project setup XML snippet in your default nuget.config file to use outside of a project.

Connect to feed button in the upper-right of the page

  1. Follow steps 1, 2, and 3 to get the tools, add the feed to your local NuGet configuration, and push the package.

    NuGet publish instructions in the Connect to feed dialog

Then, run any nuget command.

Add a feed to NuGet 2

NuGet 2 uses Personal Access Tokens to access feeds.

To use a 2.x client, first get the v3 feed URL:

  1. Navigate to your feed (or create a feed if you haven't).

  2. Select Connect to feed:

Connect to feed button in the upper-right of the page

Connect to feed button in the upper-right of the page

  1. Copy the NuGet package source URL:

NuGet Package source URL in the Connect to feed dialog

NuGet Package source URL in the Connect to feed dialog

Then, at the end of the URL, replace /v3/index.json with /v2.

Generate a Personal Access Token (PAT) using the instructions here. Scope your PAT to the organization(s) you want to access and to one of the following scopes: Packaging (read), Packaging (read and write), or Packaging (read, write, and manage).

We strongly recommend not checking your PAT into source control; anyone with access to your PAT can interact with Azure DevOps Services as you.

Run

nuget.exe sources add -name {your feed name} -source {your feed URL} -username {anything} -password {your PAT}

Then, run any nuget command.