問題描述
我發現 NuGet 允許配置代理設置,因為 1.4版本(2011 年 6 月).但是,我找不到任何命令行示例.
I figure out that NuGet allows proxy settings configuration since 1.4 version (June 2011). But, I can't find any command line example.
我正在嘗試運行一些構建,但 NuGet 無法連接.
I'm trying to run some build and NuGet can't connect.
如何在命令行配置代理設置?
How do I configure the proxy settings on the command line?
推薦答案
這是我為使用 NTLM 身份驗證的公司代理所做的工作.我下載了 NuGet.exe 然后運行以下命令(我在CodePlex 上本次討論的評論):
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=mydomainmyUserName
nuget.exe config -set http_proxy.password=mySuperSecretPassword
這將以下內容放在位于 %appdata%NuGet
的我的 NuGet.config
中(映射到 C:UsersmyUserNameAppDataRoaming 在我的 Windows 7 機器上):
This put the following in my NuGet.config
located at %appdata%NuGet
(which maps to C:UsersmyUserNameAppDataRoaming on my Windows 7 machine):
<configuration>
<!-- stuff -->
<config>
<add key="http_proxy" value="http://my.proxy.address:port" />
<add key="http_proxy.user" value="mydomainmyUserName" />
<add key="http_proxy.password" value="base64encodedHopefullyEncryptedPassword" />
</config>
<!-- stuff -->
</configuration>
順便說一句,這也解決了我的問題,即 NuGet 僅在我第一次點擊 Visual Studio 中的包源時才工作.
Incidentally, this also fixed my issue with NuGet only working the first time I hit the package source in Visual Studio.
請注意,一些嘗試過這種方法的人通過評論報告說他們已經能夠省略從命令行設置 http_proxy.password
鍵,或者在之后刪除它 -配置文件中的事實,并且仍然能夠跨代理使用 NuGet 功能.
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.
但是,如果您發現必須在 NuGet 配置文件中指定您的密碼,請記住,您必須從命令行更新存儲在 NuGet 配置中的密碼.更改您的網絡登錄,如果您的代理憑據也是您的網絡憑據.
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.
這篇關于代理背后的 NuGet的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!