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>