Publish a NuGet package from the command line

Azure DevOps Services | TFS 2018 | TFS 2017

Publish NuGet packages to a feed in Azure Artifacts to share them with your team and your organization. First, get the tools and your feed URL:

  1. Go to your feed (or create a feed if you haven't).

  2. Select Connect to feed:

    Connect to feed button on the upper right of the page

  3. Select NuGet.exe under the NuGet header

  4. Select Get the tools in the top right corner

  5. Follow steps 1 and 2 to download the latest NuGet version and the credential provider.

  6. Follow the instructions in the Project setup, Restore packages, and Publish packages sections to publish.

    NuGet publish instructions in the Connect to feed

  1. Go to your feed (or create a feed if you haven't).

  2. Select Connect to feed:

    Connect to feed button on the upper right of the page

  3. Follow steps 1 and 2 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

Note

Get or create a sample package to push

Get

If you don't have a package but want to try this out, Microsoft provides a sample package in the public NuGet gallery.

  • Run these two commands:

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

Create

If you want to create your own NuGet package to push, follow the steps in Creating NuGet packages

  • Run the following command:

    nuget.exe push -Source {NuGet package source URL} -ApiKey key {your_package}.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.