How to disable a Nuget Feed in a .NET project
Most of us use private Feeds in Nuget for storing our Nuget Packages. However, since some projects might have other security restrictions that others, it is possible that we want to disable some Feeds in our project, so that we do not have them as references.
To do this “black-listing” of Feeds you can use the following configuration:
-
First you will have to copy the default NuGet.Config file from C:\Users\XXX\AppData\Roaming\NuGet and paste it inside your Visual Studio Solution folder. Doing this way, the configuration of the new Nuget.Config will overwrite the default one
-
Open the file and remove the URLs of the packageSources you do not want in the project
-
Add the keys from the removed packageSources into a new disabledPackageSources section
The new Nuget.Config file should now look like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<disabledPackageSources>
<add key="XXXX" value="true" />
... Other packageSources you do NOT want
</disabledPackageSources>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
... Other packageSources you want
</packageSources>
... Remaining configuration
</configuration>