Disabling custom NuGet feeds

Scenario - You’re trying to build and/or run a Visual Studio type project and it complains about being unable to access a custom (and for this case unnecessary) NuGet feed, something like:

C:\Program Files\dotnet\sdk\3.x.xxx\NuGet.targets(1,1): error : Unable to load the service index for source https://pkgs.dev.azure.com/somecompany/_packaging/project/nuget/v3/index.json. [C:\Users\user\AppData\Local\Temp\yo3lpsj5.fo2\restore.csproj]

Assuming that we might well need this feed again in future, just not right now, then a simple solution is to temporarily disable the feed, do what we need to do, then enable the feed again. This can be done from the Visual Studio UI or from the console.

Using the command line

Type the following to view a list of your current feeds:

dotnet nuget list source

Disable any problematic ones:

dotnet nuget disable source FEED_NAME

And enable them again:

dotnet nuget enable source FEED_NAME
Written on November 2, 2020