Use NuGet with Team Services feeds

Last Update: 4/25/2017

Availability
NuGet Package Management is available with Visual Studio Team Services and TFS 2017 and newerTFS 2017.

The Package Management service recommends NuGet 3.5 and NuGet 4. However, Package Management also supports legacy NuGet 2.x clients. For a complete list of the latest clients, see the NuGet distribution page.

Note: this page covers interactive scenarios. For help using NuGet.exe in builds, see the builds section.

Add a feed to NuGet 3

NuGet 3 supports the Credential Provider, which automatically acquires feed credentials when needed.

Navigate to your feed (or create a feed if you haven't). Then, select Connect to feed:

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

Next, follow steps 1 and 2 to get the tools and add the feed to your local NuGet configuration.

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:

Navigate to your feed (or create a feed if you haven't). Then, select Connect to feed:

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

Next, 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 Team 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.

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-Team Services 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.