代理背后的 NuGet

NuGet behind a proxy(代理背后的 NuGet)
本文介绍了代理背后的 NuGet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我发现 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to know if a field is numeric in Linq To SQL(如何在 Linq To SQL 中知道字段是否为数字)
Extract sql query from LINQ expressions(从 LINQ 表达式中提取 sql 查询)
LINQ Where in collection clause(LINQ Where in collection 子句)
Orderby() not ordering numbers correctly c#(Orderby() 没有正确排序数字 c#)
Why do I get quot;error: ... must be a reference typequot; in my C# generic method?(为什么我会收到“错误:...必须是引用类型?在我的 C# 泛型方法中?)
Strange LINQ Exception (Index out of bounds)(奇怪的 LINQ 异常(索引越界))