NuGet无法恢复代理

时间:2017-08-11 14:27:58

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

因此,我们一直在努力解决NuGet在企业代理背后无法恢复软件包的问题。我会回顾一下我们的设置。

硬件/软件:

WinServer 2012 R2 已加入域名并位于公司代理

之后

2017年TFS与Update2

NuGet恢复错误

基本上我们所做的就是尝试为我们的环境设置构建自动化。现在我们只是在试验它,并在构建定义中创建了一个带有NuGet Restore步骤的基本Visual Studio App。

Sady NuGet Restore步骤失败,出现以下错误。日志中的相关文件如下:

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.

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

其他人是否遇到过同样的问题?我们的代理配置是否正确?任何帮助都会非常感激。

谢谢。

1 个答案:

答案 0 :(得分:1)

解决方案是您必须将VSTS Build Agent配置为在域用户帐户下运行。