【问题标题】:NuGet can't restore packages behind the proxyNuGet 无法还原代理后面的包
【发布时间】:2017-08-11 14:27:57
【问题描述】:

因此,我们一直在努力解决 NuGet 在公司代理后面无法恢复包的问题。我将检查我们的设置。

硬件/软件:

WinServer 2012 R2 加入域并在公司代理后面

带有 Update2 的 TFS 2017

NuGet 恢复错误

基本上,我们所做的只是尝试为我们的环境设置构建自动化。现在我们只是在试验它,并在构建定义中创建了一个基本的 Visual Studio 应用程序,其中包含 NuGet 还原步骤。

遗憾的是,NuGet 还原步骤失败并出现以下错误。日志中的相关文件如下:

2017-08-11T13:49:41.7282874Z     Unable to find version '1.5.2' of package 'WebGrease'.
2017-08-11T13:49:41.7282874Z       https://api.nuget.org/v3/index.json: Unable to load the service index for source https://api.nuget.org/v3/index.json.
2017-08-11T13:49:41.7282874Z       An error occurred while sending the request.
2017-08-11T13:49:41.7282874Z       Unable to connect to the remote server
2017-08-11T13:49:41.7282874Z       A socket operation was attempted to an unreachable network [2606:2800:11f:17a5:191a:18d5:537:22f9]:443
2017-08-11T13:49:41.7282874Z 
2017-08-11T13:49:41.7282874Z NuGet Config files used:
2017-08-11T13:49:41.7282874Z     C:\Windows\ServiceProfiles\NetworkService\AppData\Roaming\NuGet\NuGet.Config
2017-08-11T13:49:41.7282874Z 
2017-08-11T13:49:41.7282874Z Feeds used:
2017-08-11T13:49:41.7282874Z     https://api.nuget.org/v3/index.json
2017-08-11T13:49:41.8064377Z ##[error]Error: C:\agent\_work\_tasks\NuGetInstaller_333b11bd-d341-40d9-afcf-b32d5ce6f23b\0.2.31\node_modules\nuget-task-common\NuGet\4.0.0\NuGet.exe failed with return code: 1
2017-08-11T13:49:41.8064377Z ##[error]Packages failed to install
2017-08-11T13:49:41.8064377Z ##[section]Finishing: NuGet restore **\*.sln

我们尝试了什么

从日志中可以看出,NuGet.config文件位于此处:

C:\Windows\ServiceProfiles\NetworkService\AppData\Roaming\NuGet\NuGet.config

当我们修改 NuGet.config 文件以包含代理设置时:

<?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="http://MY_USER_NAME:MY_PASSWORD@OUR_DOMAIN.com" />
  </config>
</configuration>

那么错误就变得不一样了:

 Unable to find version '1.5.2' of package 'WebGrease'.
      https://api.nuget.org/v3/index.json: Unable to load the service index for source https://api.nuget.org/v3/index.json.
      An error occurred while sending the request.
      The remote server returned an error: (400) Bad Request.

如果服务器不通过代理连接到互联网,一切正常。

有没有其他人遇到过同样的问题?我们的代理配置看起来正确吗?任何帮助将不胜感激。

谢谢。

【问题讨论】:

  • 根据错误信息,应该是您的代理服务器有问题。它无法连接到“api.nuget.org”站点。请检查代理服务器是否可以访问互联网。并确保没有策略/防火墙设置来限制代理服务器访问“api.nuget.org”站点。参考:codesteer.com/blog/nuget-work-behind-proxy
  • 安迪,感谢您的回复。我与我们的 IT 人员进行了交谈,他们建议将 VSTS 构建代理配置为在域用户帐户下运行,并且成功了,因为代理允许域用户通过。以前我已经将 VSTS 构建代理配置为在网络服务和本地系统帐户下运行,但这些都不起作用。
  • 那么,您已经通过将 VSTS 构建代理配置为在域用户帐户下运行解决了这个问题,对吧?如果是,您可以将您的解决方法作为答案和Accept it as an Answer 发布,这可能对阅读此主题的其他社区成员有益。
  • 安迪,出于某种原因,我无法将此答案标记为已接受。没有任何类型的复选标记按钮......太奇怪了。可以标记一下吗?
  • 那是评论,我们不能将评论标记为答案,我已经在下面为您发布了答案,您暂时可以接受。

标签: tfs http-proxy nuget-package-restore


【解决方案1】:

解决方案是您必须将 VSTS 构建代理配置为在域用户帐户下运行。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-04
    • 1970-01-01
    • 1970-01-01
    • 2018-09-05
    • 1970-01-01
    • 1970-01-01
    • 2023-03-22
    相关资源
    最近更新 更多