Publish a NuGet package from the command line

Last Update: 3/6/2017

Team Services | TFS 2017

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