Use a private Azure DevOps/VSTS NuGet package feed with the .NET Core CLI

July 28, 2018, (updated on October 22, 2018), 1 comment, Software Development

If you have a .NET Core project which references a NuGet package from a private VSTS package feed, you cannot just build the project in CLI because you are not authorized to access the feed: When running dotnet restore, you’ll end up with this error message:

error: Response status code does not indicate success: 401 (Unauthorized).

To fix this problem, you can register the private NuGet feed with a VSTS personal access token (PAT). This article shows how to do that.

1. Create personal access token (PAT) on VSTS

Navigate to your VSTS site, go to the “Security” settings (top right), click on “Personal access tokens” and click on the “Add” button:

Select only “Packaging (read)” and create a token, then copy the generated token into your clipboard for later use (after closing this page, you can no longer access the token).

2. Download nuget.exe

Go to the NuGet page and download nuget.exe:

3. Register package feed with personal access token

After generating a token and downloading nuget.exe, register the private NuGet feed with the following command:

nuget.exe sources Add -Name "MyFeedName" -Source "https://myfeedurl" -username unused -password MyAccessToken

The source URL can be found on the VSTS site under “Packages” > “Connect to feed”.

Keep in mind, that the PAT is locally stored without encryption in the machine’s NuGet.config file.

Tags: , , , ,

One response to “Use a private Azure DevOps/VSTS NuGet package feed with the .NET Core CLI”

  1. Damian says:

    Thanks, this saved my day! Good you mentioned that the PAT is unencrypted as this means I had to use the “ClearTextPassword” in my NuGet.config instead of the regular “Password” key 😉

    Have a good day!

Leave a Reply

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    Markdown is turned off in code blocks:
     [This is not a link](

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see

This site uses Akismet to reduce spam. Learn how your comment data is processed.