Use NuGet with VSTS feeds

VSTS

Note

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

Note

The Package Management service recommends NuGet 3.5 or later. However, Package Management 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 3 or later

NuGet 3 and later supports the 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

  3. 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

  3. Copy the NuGet package source URL:

    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 account(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 VSTS 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.

Download the credential provider directly

You can download the credential provider directly from this link: https://{account}.pkgs.visualstudio.com/_apis/public/nuget/client/CredentialProviderBundle.zip

Advanced credential provider scenarios

Install the credential provider

By default, the credential provider works alongside NuGet.exe.

For advanced scenarios, you can choose where to install the provider:

  • Projects with a developer command prompt or enlistment: Use the provider from an environment variable by copying CredentialProvider.Vss.exe to any folder, then run this command in PowerShell: $env:NUGET_CREDENTIALPROVIDERS_PATH = {your folder}
  • Projects using a non-VSTS CI server: Use the provider from an environment variable
  • Work on an individual machine: Install the provider globally by copying CredentialProvider.Vss.exe to $env:LOCALAPPDATA\NuGet\CredentialProviders

Bootstrap into your workflow

You can also add the provider to your enlistment or developer command prompt using our bootstrap tools. This is recommended if you're using the provider in a multi-engineer development environment.