Sunday, November 6, 2016

Configuring Visual Studio To Work With a Proxy

By default, Visual Studio and Nuget use your proxy settings from IE.  However, I work for a corporation that insists on continually reverting my IE proxy settings every 15 to ones that do not work with Visual Studio, meaning that I need to continually update them just to do my job.  The solution is to configure Visual Studio and Nuget directly to use your proxy so they do not rely on IE.

This post outlines how to configure the many components of VS to work with a proxy, however for Nuget it instructs to use the nuget.exe, which requires finding it.  An easier way is to edit the Nuget configuration file directly.  Also for most people you don't need to specify your credentials as the proxy is usually configured to use integrated authentication by default.  Below is a summarised version of the steps required to get VS and Nuget to work:


  • Open the VS configuration file located at "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe.config".  Change the path appropriately depending on your version of Visual Studio and whether you are using the x64 or x86 variant.
  • Update the configuration section to look as follows:
<system.net>
<settings>
<ipv6 enabled="true"/>
</settings>
<defaultProxy useDefaultCredentials="true" enabled="true">
<proxy bypassonlocal="true" proxyaddress="http://address:port" />
</defaultProxy>
</system.net>
  • Open the Nuget configuration file located at "%AppData%\NuGet\NuGet.Config"
  • Update the configuration section to look as follows:
<configuration>
...
<config>
<add key="http_proxy" value="http://address:port" />
</config>
...
</configuration>
  • Restart (or start) Visual Studio and confirm that you can restore and browse for packages successfully
Thanks to the this answer on SO for the location of the Nuget config file