Get started with NuGet Package Management in Team Services and TFS

Last Update: 4/25/2017

Before you start

This guide assumes you've already set up Package Management. You can check out how to install and license the extension in the Install and license Package Management guide, or go directly to the Extensions Marketplace listing to install.

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

Create a feed

Already have a feed? Skip to the next step.

A feed is a container for packages. You consume and publish packages through a particular feed.

To get started, navigate to the Package hub in the Build & Release hub group:

Go to Package hub

If you don't see the Package hub, then ask your account owner to install the Package Management extension from the Visual Studio Marketplace.

Click the dropdown in the top left and select New feed:

New feed button

In the dialog:

  • Give the feed a name and a description (optional).
  • Choose who can read and contribute (or update) packages in your feed. The default selections give Team Build access so that continuous integration builds can add and update packages.
  • When you're done, choose Create.

New feed dialog

You can change these settings later by editing the feed.

Publish a package

Publish NuGet packages to a feed in Package Management to share them with your team and your organization.

First, get the tools and your 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, 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, use the push command in step 3 above. You can also manually construct a push command as follows:

nuget.exe push -Source {NuGet package source URL} -ApiKey key {your_package}.nupkg`

Notes:

  1. The NuGet client's push command requires an API key. You can use any non-empty string you want; in this example, we used key.
  2. If you're prompted for credentials in the command line, ensure that the credential provider downloaded is in the same folder as NuGet.exe. For more help using credential providers with NuGet, see here.

Get a sample package to push

If you don't have a package but want to try this out, Microsoft provides a sample package on the public NuGet gallery. Run these two commands:

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

Consume your package in Visual Studio

To consume NuGet packages from a feed, add the feed's NuGet endpoint as a package source in Visual Studio.

Package Management feeds work seamlessly with the NuGet Package Manager for Visual Studio 2015 extension as of Visual Studio 2015 Update 1. If you haven't installed Update 1 or later, you can update to the latest version of the NuGet Package Manager extension directly. Using Visual Studio for Mac? See this guidance.

Get your feed's NuGet package source 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

Windows: Add the feed to your NuGet configuration

  1. On the Tools menu, select Options....
  2. Expand NuGet Package Manager and select Package Sources.
  3. Click the green plus in the upper right corner.
  4. At the bottom of the dialog, enter the feed's name and the URL you got in the last step.
  5. Select Update and then OK.

Add new NuGet source

Then click here to continue.

Mac: Add the feed to your NuGet configuration

  1. Get a Personal Access Token (PAT) and make a note of it.
  2. Open the Preferences dialog from the Visual Studio menu in the menu bar.
  3. Select NuGet -> Sources.
  4. Click Add then enter your feed's name, URL, any username, and your PAT as the password.
  5. Click OK, then OK again.

Visual Studio for Mac preferences window with VSTS feed added

Consume packages

You can now discover and use packages in this feed. To add a package reference to a project:

  1. Find your project in Solution Explorer.
  2. Right-click References.
  3. Select Manage NuGet Packages....
  4. In the Package source dropdown, select your feed.
  5. Look for your package in the list.

Select feed source

Using Visual Studio 2015 or earlier?

You may need to download and install the latest NuGet Package Manager extension.

Using Visual Studio 2013 or earlier?

You'll need to get a Personal Access Token. When you're prompted for a username and password, use any username and your PAT as the password.

Automate the process with continuous integration

You can use continuous integration systems like Team Build to automate the packing and publishing of your packages. To get started with continuous integration, see the Continuous delivery overview

What's next?

For more advanced topics, check out the content summary.