2
votes

I am trying to connect to my Azure Devops 2019 NuGet feed from the package manager in Visual Studio 2019. I have added the source https://myurl/tfs/DefaultCollection/_packaging/MyFeed/nuget/v3/index.json but when I try to connect to it in VS I get the following error:

Unable to load the service index for source https://myurl/tfs/DefaultCollection/_packaging/MyFeed/nuget/v3/index.json. Response status code does not indicate success: 401 (Unauthorized).

I followed the instructions here regarding the PAT security token but I am not sure how to use the PAT in VS. https://docs.microsoft.com/en-us/azure/devops/artifacts/nuget/nuget-exe?view=azdevops&tabs=new-nav

How can I use the VS package manager with Azure Devops artifacts?

1
so after nuget add source nuget restore from cmd is working as expected? – Falco Alexander
Hi @FalcoAlexander the restore command is working properly from cmd. But I am unable to connect to the feed within VS. – doorman
Hi @FalcoAlexander thanks for the suggestions. It turns out this works fine in VS2015 where I was prompted for a password. In VS2017 I was not prompet for password. Do you know how I can force it, maybe by clearing some VS specific user settings? – doorman
Ok, it works now both in VS2017 and VS2015. I only tried it in VS2015 and after that it worked in 2017 as well. – doorman
glad, I could help, but no kudos for me 😒 – Falco Alexander

1 Answers

3
votes

Connect to a NuGet feed on Azure Devops 2019 from VS

Just as Falco said, you don not need the PAT with Visual Studio, because that is used for nuget.exe CLI.

When you connect the Azure Devops 2019 NuGet feed with Visual Studio, Visual Studio will prompt you to log in to your personal credential:

enter image description here

According to the error message 401 (Unauthorized), it seems you do not log in Visual Studio with a valid personal credential, to resolve this issue, please try to logout your current account and restart Visual Studio, then reopen Visual Studio, select the Azure Devops 2019 NuGet feed, Visual Studio will prompt you to log in to your personal credential again:

enter image description here

Enter the valid personal credential and make sure this personal credential that can access your Azure Devops 2019 NuGet feed.

Besides, we could also to provide credentials to Visual Studio manually with nuget.config under the folder C:\Users\<UserName>\AppData\Roaming\NuGet:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="AzureDevOpsFeed" value="<ThePackageSourceFeedUrl>/MyCustomFeed/nuget/v3/index.json" />
  </packageSources>


  <packageSourceCredentials>
    <AzureDevOpsFeed>
      <add key="Username" value="<YourUserName>" />
      <add key="ClearTextPassword" value="<YourPassword>" />
    </AzureDevOpsFeed>
</configuration>

Check this similar thread for some more details. Hope this helps.