doorman
doorman

Reputation: 16959

Connect to a NuGet feed on Azure Devops 2019 from VS

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://learn.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?

Upvotes: 3

Views: 2502

Answers (1)

Leo Liu
Leo Liu

Reputation: 76976

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.

Upvotes: 4

Related Questions