我有一个VS解决方案,作为TeamCity Build的一部分,我们从私有NuGet提要(myget)和公共提要(nuget.org)恢复包。大多数软件包都可以恢复正常,但它依赖于下面的WebApi和Mono.Security。这都在Visual Studio中本地工作。
[restore] NuGet command: C:\TeamCity\buildAgent\plugins\nuget-agent\bin\JetBrains.TeamCity.NuGetRunner.exe C:\TeamCity\buildAgent\tools\NuGet.CommandLine.DEFAULT.nupkg\tools\NuGet.exe restore C:\TeamCity\buildAgent\work\953bd084b49f7d88\DataFinch.Web.sln -Source https://www.myget.org/F/datafinch/auth/<hidden>/api/v2 -Source https://api.nuget.org/v3/index.json
[11:41:35][restore] Starting: C:\TeamCity\buildAgent\temp\agentTmp\custom_script473789219385667038.cmd
[11:41:35][restore] in directory: C:\TeamCity\buildAgent\work\953bd084b49f7d88
[11:41:35][restore] JetBrains TeamCity NuGet Runner 8.0.37059.9
[11:41:35][restore] Registered additional extensions from paths: C:\TeamCity\buildAgent\plugins\nuget-agent\bin\plugins-2.8
[11:41:35][restore] Starting NuGet.exe 2.8.50926.602 from C:\TeamCity\buildAgent\tools\NuGet.CommandLine.DEFAULT.nupkg\tools\NuGet.exe
[11:41:43][restore] Unable to find version '5.2.3' of package 'Microsoft.AspNet.WebApi.Client'.
[11:41:43][restore] Unable to find version '5.2.3' of package 'Microsoft.AspNet.WebApi.Core'.
[11:41:43][restore] Unable to find version '3.2.3.0' of package 'Mono.Security'.
[11:41:43][restore] Unable to find version '6.0.4' of package 'Newtonsoft.Json'.
[11:41:43][restore] Process exited with code 1
尝试使用https://www.nuget.org/api/v2
instead of https://api.nuget.org/v3/index.json
per nuget docs:https://docs.nuget.org/consume/Command-Line-Reference。
构建失败的原因是nuget.exe的旧版本。我终于通过下载最新版本解决了这个问题,并将此可执行文件放在Program Files x86文件夹中。然后我创建了一个新的系统varbele来指向这个可执行文件。之后,我在我的TFS Build Definition中添加了一个NuGetInstaller包,让我使用这个新的NuGet.exe配置TFS。 This link helped me to let TFS use this new NuGet version
我试过3.3并得到了这个错误:
恢复NuGet包Microsoft.AspNet.WebPages.3.2.3。警告:无法找到包'Antlr'的版本'3.5.0.2'。
我下载了最新的NuGet 4.3.0.4406并将自定义路径设置为NuGet,但也失败了。
令人惊讶的是,当我切换到3.5时它起作用。
如果您确实卡住了,请在命令行提示符中运行该命令,它将起作用:
C:\Program Files (x86)\NuGet\nuget.exe restore -NonInteractive E:\agentXYZPool\_work\1\s\xyz.sln
我在使用TFS和Visual Studio的构建从属中遇到了这个问题。
我修复它的方式是,我打开了未在Visual Studio中编译的解决方案,右键单击SLN并选择“启用还原NuGet包”
这会提示您必须接受的对话框。完成后,你可能会很高兴。再次右键单击SLN并运行“Restore NuGet Packages”,如果该操作成功,那么你就是金色的。
您可以在设置从属环境时以编程方式调整某些设置,但这是解决此类问题的直接方法。
根据THIS目前的文件,从MS写这篇文章,正确的网址是:https://api.nuget.org/v3/index.json
所以我开始解决这个问题,因为我认为它与URL无关。我做了两件事,不确定是什么解决了这个问题,但是我会在这里发布,以防它帮助某人。
在我完成上述两个步骤后,我的其余部分开始工作。