Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Package manager in Visual Studio 2015 "407 (Proxy Authentication Required)"

I understand this is an often asked question, however after days of research I've not found an answer to this particular problem.


I have a new ASP.NET 5 (Core 1.0) MVC template that I'm trying to add a package to however each and every time I get in the Package Manager output:

Response status code does not indicate success: 407 (Proxy Authentication Required). 

and the following at the top of solution explorer:

enter image description here

my settings look fine and I am able to browse packages in the 'Manage Packages for Solution' screen.

I understand I'm being requested to supply credentials so where do I enter them? On the other hand all other applications on my machine have validated internet access, so why should I?

Any ideas / pointers are very welcome.

Visual Studio 2015 - 14.0.24720.00 Update 1
NuGet Package Manager for Visual Studio 2015 - 3.3.0.167


Top section of Package Manager output:

Installing NuGet package AutoMapper.4.2.1.
Successfully installed 'AutoMapper 4.2.1' to CustomerPortal
========== Finished ==========
PATH=.\node_modules.bin;%PATH%;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External\git
C:\Users\medmondson.dnx\runtimes\dnx-clr-win-x86.1.0.0-rc1-update1\bin\dnx.exe "C:\Users\medmondson.dnx\runtimes\dnx-clr-win-x86.1.0.0-rc1-update1\bin\lib\Microsoft.Dnx.Tooling\Microsoft.Dnx.Tooling.dll" restore "M:\visual studio 2015\Projects\CustomerPortal\src\CustomerPortal" -f "C:\Program Files (x86)\Microsoft Web Tools\DNU"
Microsoft .NET Development Utility Clr-x86-1.0.0-rc1-16231
GET https://www.nuget.org/api/v2/
GET http://packages.nuget.org/v1/FeedService.svc/
GET https://www.postsharp.net/nuget/packages/
Restoring packages for M:\visual studio 2015\Projects\CustomerPortal\src\CustomerPortal\project.json
GET https://www.nuget.org/api/v2/FindPackagesById()?id='AutoMapper'
GET http://packages.nuget.org/v1/FeedService.svc/FindPackagesById()?id='AutoMapper'
GET https://www.postsharp.net/nuget/packages/FindPackagesById()?id='AutoMapper'
Warning: FindPackagesById: AutoMapper
An error occurred while sending the request.
GET https://www.nuget.org/api/v2/FindPackagesById()?id='AutoMapper'
GET https://www.nuget.org/api/v2/FindPackagesById()?id='System.Collections.Immutable'
GET http://packages.nuget.org/v1/FeedService.svc/FindPackagesById()?id='System.Collections.Immutable'
GET https://www.postsharp.net/nuget/packages/FindPackagesById()?id='System.Collections.Immutable'
Warning: FindPackagesById: AutoMapper
An error occurred while sending the request.
GET https://www.postsharp.net/nuget/packages/FindPackagesById()?id='AutoMapper'
Warning: FindPackagesById: AutoMapper
Response status code does not indicate success: 407 (Proxy Authentication Required).

Update

I've managed to capture a non-working request (returning 407) and a working request with the only difference being the content of the Proxy-Authorization header which is longer. This would suggest the proxy authentication does exist but it's using a different protocol.

like image 957
m.edmondson Avatar asked Mar 30 '16 13:03

m.edmondson


People also ask

How do I install NuGet packages in Visual Studio 2015?

From Visual Studio, select Tools > NuGet Package Manager > Package Manager Console. After the Package Manager Console pane opens, verify that the Default project drop-down list shows the project in which you want to install the package.

How do I open the package manager console in Visual Studio 2015?

Console controls To open the Package Manager Console in Visual Studio, select Tools > NuGet Package Manager > Package Manager Console from the top menu.

How do I enable manage NuGet packages in Visual Studio?

To find and install a NuGet package with Visual Studio, follow these steps: Load a project in Solution Explorer, and then select Project > Manage NuGet Packages. The NuGet Package Manager window opens. Select the Browse tab to display packages by popularity from the currently selected source (see Package sources).


4 Answers

  1. Updated to latest nuget.exe 1st

    nuget update self
    
  2. Added proxy details to the config file:

    nuget config -Set http_proxy=http://username:[email protected]:port
    
like image 85
Glyn Avatar answered Oct 18 '22 23:10

Glyn


You need to modify file 2 .config files:

for Visual Studio 2015

  • C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\vsn.exe.config
  • C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe.config

for Visual Studio 2017

  • C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\vsn.exe.config
  • C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\devenv.exe.config
<system.net>
  <defaultProxy enabled="true" useDefaultCredentials="true">
    <proxy usesystemdefault="True" bypassonlocal="True" proxyaddress="http://yourproxy:proxyport" />
    <bypasslist>
      <add address="(.*\.)?anyotherdomain\.com?(.*)" />
      <add address="(.*\.)?nuget\.org?(.*)" />
      <add address="192\.168\.\d{1,3}\.\d{1,3}" />
    </bypasslist>
  </defaultProxy>
  <settings>
    <ipv6 enabled="false"/>
    <servicePointManager expect100Continue="false"/>
  </settings>
</system.net>

The bypass for nuget.org will work if, without the proxy, you still can get it's IP from DNS server and nothing else is blocking it.

Also need this to install nuget

Open the file C:\Users\[YOUR_USER_NAME]\AppData\Roaming\NuGet\NuGet.Config and add inside the <configuration> <\configuration> tag the following:

<config>
  <add key="http_proxy" value="http://yourproxy:proxyport" />
</config>

Taken from Marco Mengoli's Blog

like image 44
Rui Caramalho Avatar answered Oct 19 '22 00:10

Rui Caramalho


I had the same problem a few weeks ago. For me it has helped to put in the the following in the machine.config (Windows/Microsoft.NET/Framework64/v4.0.30319/Config)

<system.net>
   <settings>
       <ipv6 enabled="True"/>
   </settings>
   <defaultProxy useDefaultCredentials="True" enabled="True">
       <proxy proxyaddress="http://your.proxyserver.ip:port"/>
   </defaultProxy>
</system.net>
like image 12
user3063127 Avatar answered Oct 19 '22 00:10

user3063127


I had to modify the 32 bit machine.config (assumption being VS runs in 32 bit) to add the <system.net> section but omitting anything within the <defaultProxy> tag:

<system.net>
    <defaultProxy useDefaultCredentials="True" enabled="True" />
</system.net>

According to MSDN:

If the defaultProxy element is empty, the proxy settings from Internet Explorer will be used.

This is perfect for me as every other application on my machine works - including IE.

manchine.config location (Win 7): %SYSTEMROOT%\Microsoft.NET\Framework\v4.0.30319\Config\machine.config


Note

I resolved this thanks to @user3063127 pointing me in the right direction (you have an upvote). As far as I can tell this only affects package restore on DNX projects and may well be fixed when RC2 is released.

like image 9
m.edmondson Avatar answered Oct 19 '22 00:10

m.edmondson