Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nuget Restore via build server "unable to find version"

Tags:

c#

nuget

teamcity

I have a VS solution and as part of a TeamCity Build, we restore packages from both a private NuGet feed (myget) and the public feed (nuget.org). Most packages restore fine, but it hangs on the ones below for WebApi and Mono.Security. This is all working locally in 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 config: enter image description here

like image 762
Chris Kooken Avatar asked Sep 02 '15 18:09

Chris Kooken


People also ask

How do I force a NuGet package to restore?

Enable package restore by choosing Tools > Options > NuGet Package Manager. Under Package Restore options, select Allow NuGet to download missing packages. In Solution Explorer, right click the solution and select Restore NuGet Packages.

How do I fix NuGet recovery failed?

Quick solution for Visual Studio usersSelect the Tools > NuGet Package Manager > Package Manager Settings menu command. Set both options under Package Restore. Select OK. Build your project again.

How do I get a new NuGet version?

Visit nuget.org/downloads and select NuGet 3.3 or higher (2.8. 6 is not compatible with Mono). The latest version is always recommended, and 4.1. 0+ is required to publish packages to nuget.org.

How do I find NuGet Package Manager version?

In Visual Studio, use the Help > About Microsoft Visual Studio command and look at the version displayed next to NuGet Package Manager. Alternatively, launch the Package Manager Console (Tools > NuGet Package Manager > Package Manager Console) and enter $host to see information about NuGet including the version.


2 Answers

Try using https://www.nuget.org/api/v2instead of https://api.nuget.org/v3/index.json per the nuget docs: https://docs.nuget.org/consume/Command-Line-Reference.

like image 176
rarrarrarrr Avatar answered Oct 13 '22 09:10

rarrarrarrr


The reason why the build failed, was an old version of nuget.exe. I finally solved this problem by downloading the latest version and put this executable in the Program Files x86 folder. Then I created a new system variabele to point to this executable. After that I add a NuGetInstaller package in my TFS Build Definition to let me configure TFS using this new NuGet.exe. This link helped me to let TFS use this new NuGet version

like image 41
Marcel Beeker Avatar answered Oct 13 '22 10:10

Marcel Beeker