代理背后的 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

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

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)