In this article, I am going to explain – the Configuration steps for NuGet to work behind a proxy.
What is NPM?
NuGet is the package manager for the Microsoft development platform including .NET.
When you use NuGet to install a package, it copies the library files to your solution and automatically updates your project (add references, change config files, etc.). If you remove a package, NuGet reverses whatever changes it made so that no clutter is left.
If you work behind a proxy, when you try to add a NuGet package to your Visual Studio project, probably this message will compare in the output tab:
error: Failed to retrieve information from remote source …
error: Response status code does not indicate success: 407 (Proxy Authentication Required).
It means that NuGet is trying to download the package, but the proxy is blocking.
Open the file C:\Users\[YOUR_USER_NAME]\AppData\Roaming\NuGet\NuGet.Config and add inside the <\configuration> tag the following:
<?xml version="1.0" encoding="utf-8"?>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="Microsoft and .NET" value="true" />
<add key="http_proxy" value="[YOUR_PROXY_ADDRESS]:[YOUR_PROXY_PORT]" />
[YOUR_USER_NAME] with your Windows account name
[YOUR_PROXY_ADDRESS] with the address of the proxy
[YOUR_PROXY_PORT] with the port of the proxy
Open Visual Studio and NuGet should automatically restore the packages.