Nuget通过构建服务器恢复“无法找到版本”

问题描述 投票:32回答:5

我有一个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配置:enter image description here

c# nuget teamcity
5个回答
35
投票

尝试使用https://www.nuget.org/api/v2instead of https://api.nuget.org/v3/index.json per nuget docs:https://docs.nuget.org/consume/Command-Line-Reference


3
投票

构建失败的原因是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


0
投票

我跟着这个: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包Microsoft.AspNet.WebPages.3.2.3。警告:无法找到包'Antlr'的版本'3.5.0.2'。

我下载了最新的NuGet 4.3.0.4406并将自定义路径设置为NuGet,但也失败了。

令人惊讶的是,当我切换到3.5时它起作用。

enter image description here

如果您确实卡住了,请在命令行提示符中运行该命令,它将起作用:

C:\Program Files (x86)\NuGet\nuget.exe restore -NonInteractive E:\agentXYZPool\_work\1\s\xyz.sln

0
投票

我在使用TFS和Visual Studio的构建从属中遇到了这个问题。

我修复它的方式是,我打开了未在Visual Studio中编译的解决方案,右键单击SLN并选择“启用还原NuGet包”

这会提示您必须接受的对话框。完成后,你可能会很高兴。再次右键单击SLN并运行“Restore NuGet Packages”,如果该操作成功,那么你就是金色的。

您可以在设置从属环境时以编程方式调整某些设置,但这是解决此类问题的直接方法。


0
投票

根据THIS目前的文件,从MS写这篇文章,正确的网址是:https://api.nuget.org/v3/index.json

所以我开始解决这个问题,因为我认为它与URL无关。我做了两件事,不确定是什么解决了这个问题,但是我会在这里发布,以防它帮助某人。

  • 在TFS2018内,在我的构建步骤中安装Nuget I指定版本4.9.3(之所以选择4.9.3是因为我注意到在我的构建过程中使用此版本时查看VS的详细日志)并选择了始终下载最新版本。
  • 我做的第二件事是我从我正在测试的东西遗留下来的项目中删除了一个Nuget.Config文件。然后我重新将我的更改提交给TFS

在我完成上述两个步骤后,我的其余部分开始工作。

© www.soinside.com 2019 - 2024. All rights reserved.