NuGet配置代理
NuGet behind a proxy
回答1
Here's what I did to get this working with my corporate proxy that uses NTLM authentication. I downloaded NuGet.exe 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 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.
回答2
Maybe you could try this to your devenv.exe.config
<system.net>
<defaultProxy useDefaultCredentials="true" enabled="true">
<proxy proxyaddress="http://proxyaddress" />
</defaultProxy>
<settings>
<servicePointManager expect100Continue="false" />
<ipv6 enabled="true"/>
</settings>
</system.net>
I found it from the NuGet Issue tracker
There are also other valuable comments about NuGet + network issues.
回答3
ust in case you are using the HTTPS version of NuGet, be aware that you have to set the values with HTTPS.
https_proxy
https_proxy.user
https_proxy.password
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):
win10的系统,配置文件在C:\Users\clu\AppData\Roaming\NuGet\NuGet.Config
<add key="http_proxy" value="172.22.33.4:8080" /> 应该是http_proxy,中间是下划线,不是点
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
<config>
<add key="http.proxy" value="sasygsha01prx11_p.asnet.accorservices.net:8080" />
</config>
</configuration>
注意事项:
这个http_proxy的配置,也有可能在系统的环境变量中进行过配置。比如git会依赖