我发现自 1.4 version (June 2011) 起 NuGet 允许代理设置配置.但是,我找不到任何命令行示例。
我正在尝试运行一些构建,但 NuGet 无法连接。
如何在命令行上配置代理设置?
最佳答案
以下是我为使它与使用 NTLM 身份验证的公司代理一起工作所做的工作。我下载了 NuGet.exe 然后运行以下命令(我在 CodePlex 上对 this discussion 的评论中找到):
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
这将以下内容放入我位于 %appdata%\NuGet
的 NuGet.config
(映射到 C:\Users\myUserName\AppData\Roaming 在我的 Windows 7 机器上):
<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>
顺便说一句,这也解决了我的问题,即 NuGet 仅在我第一次访问 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.
但是,如果您发现您必须在 NuGet 配置文件中指定您的密码,请记住,当您执行以下操作时,您必须从命令行更新存储在 NuGet 配置中的密码如果您的代理凭据也是您的网络凭据,请更改您的网络登录。
关于c# - 代理背后的 NuGet,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9232160/