TFS Nuget Restore步骤无法访问代理



我们最近升至TFS 2017,我正在尝试使现有的构建从基于XAML的构建到新的构建系统。这都是公司防火墙的背后。

我的测试项目(dotnet core(失败了,错误...

Assets file '<snip>project.assets.json' not found. Run a NuGet package restore to generate this file. 

...所以我在构建中添加了nuget还原步骤。这导致构建日志中出现以下错误...

<snip>
Starting: NuGet restore   
**************************************************************************
==========================================================================
Task         : NuGet Restore
Description  : Restores NuGet packages in preparation for a Visual Studio 
Build step.
Version      : 1.0.1
Author       : Microsoft Corporation
Help         : [More Information](https://go.microsoft.com/fwlink/?
LinkID=613747)
==========================================================================
C:Windowssystem32chcp.com 65001
Active code page: 65001 

...在这里等待30秒...

connect ETIMEDOUT 117.18.232.200:443
**************************************************************************
Finishing: NuGet restore
<snip>

但是,与提琴手和网络人员一起检查,在显示在显示的点大约30秒的时候,框中没有(相关的(网络活动。

显然,Nuget Restore步骤正在尝试访问Internet,但由于无法访问代理而无法访问Internet(我们最初设置了构建服务器,而不是被阻止,这将显示在网络日志。

如果我使用与构建服务相同的凭据登录,我可以成功地使用VS构建测试项目,但显然它使用IDE配置文件来到达代理人。我在devenv.exe.config和%appdata% nuget nuget.config中配置了代理。

任何人都可以建议我在哪里设置它,以便nuget还原步骤可以找到并使用它,请?

尝试下面的步骤:

  • 下载Nuget的命令行版本
  • 将其添加到路径env var
  • nuget.exe config -set http_proxy = http://proxy:port
  • nuget.exe config -set http_proxy.user = domain username
  • nuget.exe config -set http_proxy.password = mypassword

更新:

使用PackAgeReference Management格式时,project.assets.json文件将维护项目的依赖图,该格式用于确保所有必要的软件包都安装在计算机上。由于此文件是通过软件包还原生成的,因此通常不会将其添加到源控件中。结果,当使用不自动还原软件包的msbuild等工具构建项目时,会发生此错误。

在这种情况下,运行msbuild /t:restore,然后运行msbuild,或使用dotnet build(自动恢复包(。

更多详细信息,请参阅下面的链接:https://learn.microsoft.com/en-us/nuget/consume-packages/package-restore-troubleshooting

最新更新