开发者

Accessing Nuget Official Package Source behind company proxy

I am trying to use Nuget in VS2010 at work. When I try and download packages from the official feed it always fails with a 403.

I've read that Nuget will use the same proxy setti开发者_如何学编程ngs as IE, which is unfortunate for me as my IE is locked down. I can't change the proxy.

I have fiddled the feedservice urls that are getting bounced, in IE I get an error, in Firefox (with a local proxy.pac defined) the urls resolve fine and I can see the feeds.

Is there any way to manually configure Nuget not to use IE's settings?


If you can't get the exception added to your proxy, or just want an immediate solution then edit your Visual studio configuration file (devenv.exe.config) located in your Visual Studio installation directory (eg - C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE) and change/add the <system.net> configuration section to the following, which will let Visual Studio work with the proxy:

<system.net>
    <defaultProxy useDefaultCredentials="true" enabled="true">
        <proxy proxyaddress="http://<Insert proxy address here>" />
    </defaultProxy>
    <settings>
        <servicePointManager expect100Continue="false" />
        <ipv6 enabled="true" />
    </settings>
</system.net>

All you need to do is change the <Insert proxy address here> to your company's proxy address. Also depending on your proxy settings you may be able to use Expect100Continue messages and may not need to change that configuration element. You can find more information here


The following comes from a related question I answered recently.

Here's what I did to get this working with my corporate proxy that uses NTLM authentication. I downloaded NuGet.exe from a link on this page and then ran the following commands (which I found in the comments to this discussion on CodePlex):

nuget.exe config -set http_proxy=http://my.proxy.address:port
nuget.exe config -set http_proxy.user=mydomain\myUserName
nuget.exe config -set http_proxy.password=mySuperSecretPassword

This put the following in my NuGet.config located at %appdata%\NuGet (which maps to C:\Users\myUserName\AppData\Roaming on my Windows 7 machine):

<configuration>
    <!-- stuff -->
    <config>
        <add key="http_proxy" value="http://my.proxy.address:port" />
        <add key="http_proxy.user" value="mydomain\myUserName" />
        <add key="http_proxy.password" value="base64encodedHopefullyEncryptedPassword" />
    </config>
    <!-- stuff -->
</configuration>

Incidentally, this also fixed my issue with NuGet only working the first time I hit the package source in Visual Studio.

Note that some people who have tried this approach have reported through the comments on my other answer that they have been able to omit setting the http_proxy.password key from the command line, or delete it after-the-fact from the config file, and were still able to have NuGet function across the proxy.

If you find, however, that you must specify your password in the NuGet config file, remember that you have to update the stored password in the NuGet config from the command line when you change your network login, if your proxy credentials are also your network credentials.


Well I managed to get the IT department to allow unrestricted access to packages.nuget.org, so that sorted it out. We use sophos here and any web request it doesn't like the look of is blocked. This applied to the nuget urls. A workaround was to use the Library Package Manager to initiate an installation with fiddler running. Then copy the url that was forbidden into my browser and tell sophos it's ok. I could then Install-Package successfully

hope this helps anyone stuck behind a militant firewall


If you don't know the proxy settings and NuGet is asking for a proxy user and password, you could try adding to devenv.exe.config file in your Visual Studio installation directory, between the <system.net> tags :

<defaultProxy useDefaultCredentials="true" enabled="true">
  <proxy usesystemdefault="True"/>
</defaultProxy>

it should look like this, depending on your VisualStudio:

  <system.net>
    <defaultProxy useDefaultCredentials="true" enabled="true">
      <proxy usesystemdefault="True"/>
    </defaultProxy>
    <settings>
      <ipv6 enabled="true" />
    </settings>
  </system.net>

It worked for me without even giving the proxy address :) Really this should be the default behavior, I lost so many days trying to overcome this...


I had a problem with accessing the Nuget site through the Nuget Console. "Received an unexpected EOF or 0 bytes from the transport stream." It ended up being a proxy issue, the difference was my work proxy is 'invisible' and doesn't have configuration options. I solved my problem with the following steps.

  1. Open Visual Studio as Administrator
  2. Open the Visual Studio internal browser ( View | Other Windows | Web Browser )
  3. Go to your banks website - or other site that uses SSL
    Might need to actually log in to the site, I didn't.
  4. Then Run the Install-package command in the Nuget Console.
  5. Command works without error.

This may help with the following issues:

  • https://nuget.codeplex.com/workitem/3176
  • https://nuget.codeplex.com/workitem/3403

I hope this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜