我有一个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
Teamcity配置:
4 回答
根据nuget文档尝试使用
https://www.nuget.org/api/v2
而不是https://api.nuget.org/v3/index.json
: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
我跟着这个:https://blogs.msdn.microsoft.com/tfssetup/2017/04/18/tfs-2017-update-1-nuget-restore-task-always-fails-trying-to-find-packages-even-though-they-exist-on-the-feed/
我试过3.3并得到了这个错误:
我下载了最新的NuGet 4.3.0.4406并将自定义路径设置为NuGet,但也失败了 .
Surprisingly when I switched to 3.5 it worked.
如果您确实卡住了,请在命令行提示符中运行该命令,它将起作用:
我利用TFS和Visual Studio的一个构建从属器遇到了这个问题 .
我修复它的方式是,我打开了未在Visual Studio中编译的解决方案,右键单击SLN并选择“启用还原NuGet包”
这会提示您必须接受的对话框 . 完成后,你可能会很高兴 . 再次右键单击SLN并运行“Restore NuGet Packages”,如果该操作成功,那么你就是金色的 .
您可以在设置从属环境时以编程方式调整某些设置,但这是解决此类问题的直接方法 .