Publish a NuGet package from the command line

VSTS | TFS 2018 | 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:

  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

You can also manually construct a push command as follows:

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


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

Publishing with upstream sources

There are some important things to consider when publishing packages that involve upstream sources. Check out the documentation on overriding a package from an upstream source for more information.