0

I am setting up Visual Studio 2022 Community Edition on a new workstation. I have instructions for connecting to an Azure DevOps artifact feed that worked on my previous workstations. Despite following the same instructions, I can't restore NuGet packages from the Azure DevOps artifact feed.

I configure the artifact feed manually by editing %APPDATA\NuGet.config and adding an element to the packageSources element just below the entry for nuget.org.

<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="azure-devops-feed" value="https://pkgs.dev.azure.com/xxxxxxxxxxxxxx/_packaging/xxxxxxxxxxxxxx-feed/nuget/v3/index.json" protocolVersion="3" />
<add key="Microsoft Visual Studio Offline Packages" value="C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\" />

Note the protocolVersion="3" on the new element; this is needed because Visual Studio 2022 was using protocol version 2 which is not supported by the artifact feed.

When I try to run the build, I get the output

NU1301: Unable to load the service index for source https://pkgs.dev.azure.com/xxxxxxxxxxxxxx/_packaging/xxxxxxxxxxxxxx-feed/nuget/v3/index.json.

I opened https://pkgs.dev.azure.com/xxxxxxxxxxxxxx/_packaging/xxxxxxxxxxxxxx-feed/nuget/v3/index.json in an Incognito tab in my browser to verify that, once I authenticated using the same Windows account that I use to log in to Visual Studio, the index.json is accessible and contains the expected contents.

Update

This was solved by copying the NuGet.config file from my old workstation. The only difference is that the protocolVersion="3" attribute was removed from the private feed element. When I was setting this up previously I had to add that attribute, as otherwise Visual Studio used Protocol Version 2 which got 404 errors.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
    <add key="azure-devops-feed" value="https://pkgs.dev.azure.com/xxxxxxxxxxxxxx/_packaging/xxxxxxxxxxxxxx-feed/nuget/v3/index.json" />
    <add key="Microsoft Visual Studio Offline Packages" value="C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\" />
  </packageSources>
  <packageRestore>
    <add key="enabled" value="True" />
    <add key="automatic" value="True" />
  </packageRestore>
  <bindingRedirects>
    <add key="skip" value="False" />
  </bindingRedirects>
  <packageManagement>
    <add key="format" value="0" />
    <add key="disabled" value="False" />
  </packageManagement>
</configuration>
Karl Dickman
  • 43
  • 1
  • 6

1 Answers1

0

NU1301: Unable to load the service index for source https://pkgs.dev.azure.com/xxxxxxxxxxxxxx/_packaging/xxxxxxxxxxxxxx-feed/nuget/v3/index.json.

The cause of the issue is that the Private Nuget source miss Credentials in Nuget.config file.

To solve this issue, you can use the following command to add the Credentials to the Nuget.config file.

nuget sources update -name azure-devops-feed -username 123 -password <PAT>

Then you can check if the Nuget.config file has added the Credentials.

For example:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
    <add key="Microsoft Visual Studio Offline Packages" value="C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\" />
    <add key="test1" value="https://pkgs.dev.azure.com/xx/xx/_packaging/xx/nuget/v3/index.json" />
  </packageSources>


  <packageSourceCredentials>
    <test1>
        <add key="Username" value="123" />
        <add key="Password" value="based64PAT" />
      </test1>
  </packageSourceCredentials>
</configuration>

For more detailed info, you can refer to this doc: packageSourceCredentials

Kevin Lu-MSFT
  • 20,786
  • 3
  • 19
  • 28