5

I'm configuring a TFS 2015 build using the new scriptable system. During the build, when NuGet is retoring some packages, it fails with the following error:

The 'System.Collections 4.0.10' package requires NuGet client version '3.0' or above, but the current NuGet version is '2.8.60318.667'.

The 'System.Diagnostics.Debug 4.0.10' package requires NuGet client version '3.0' or above, but the current NuGet version is '2.8.60318.667'.

The 'System.Globalization 4.0.10' package requires NuGet client version '3.0' or above, but the current NuGet version is '2.8.60318.667'.

The 'System.Linq 4.0.0' package requires NuGet client version '3.0' or above, but the current NuGet version is '2.8.60318.667'.

The 'System.Resources.ResourceManager 4.0.0' package requires NuGet client version '3.0' or above, but the current NuGet version is '2.8.60318.667'.

The 'System.Runtime 4.0.20' package requires NuGet client version '3.0' or above, but the current NuGet version is '2.8.60318.667'.

The 'System.Runtime.Extensions 4.0.10' package requires NuGet client version '3.0' or above, but the current NuGet version is '2.8.60318.667'.

The 'System.Threading 4.0.10' package requires NuGet client version '3.0' or above, but the current NuGet version is '2.8.60318.667'.

BTW, I've installed Visual Studio 2015 in the whole build machine and I've checked that NuGet 3.1 is present in the extensions manager menu.

I guess TFS Build is using a different NuGet installation location, but I can't figure out where's looking for it and how do I update it from 2.8.x to 3.x.

Matías Fidemraizer
  • 63,804
  • 18
  • 124
  • 206

4 Answers4

6

There's a workaround to this problem.

By default, if you use VSBuild/MSBuild tasks, you can only choose whether to run nuget restore or not via the appropriate checkbox. But there is a separate task called NuGet Installer (it lives in the Package section). It exposes an optional field for the custom path to the NuGet.exe:

enter image description here

So, here is the idea:

  • Schedule NuGet Installer step before the appropriate VSBuild/MSBuild step
  • Specify correct custom path to NuGet.exe
  • Make sure Restore NuGet packages flag is off for the VSBuild/MSBuild step

NOTE: Your solution with replacing the physical executable directly in the build agent internals might work well up until the agent is updated (either on purpose, or somehow automatically) and overwrites NuGet.exe with newer, but still outdated version.

Yan Sklyarenko
  • 31,557
  • 24
  • 104
  • 139
2

It was easier than I thought...

After checking the TFS build log I found the following string:

X:\TfsBuild\Agents\project\agent\worker\tools\NuGet.exe restore "X:\TfsBuild\Agents\project\c57207ab\path\to\solution\whatever.sln" -NonInteractive

That is, when TFS build agent ZIP is downloaded from the TFS Web Access, it includes an outdated NuGet executable.

The worst part that there's no publicly available NuGet Command-Line 3.x executable, and I needed to use Google once I've found a post in the official NuGet blog pointing to a NuGet Command-Line 3.1 beta version executable I've replaced the one in the build agent tools location with the beta one, and the error got fixed.

The issue also affects XAML builds

If you want to work with XAML builds, you'll need to download the same NuGet Command-Line executable and copy it to C:\Program Files\Microsoft Team Foundation Server 14.0\Tools\nuget.exe and replace existing one...

Matías Fidemraizer
  • 63,804
  • 18
  • 124
  • 206
0

I had the same problem. You need to use more recent version of nuget.exe. Version 3.5.0 soved my problem.

You can download Nuget distributions here: https://dist.nuget.org/index.html

Lubos
  • 125
  • 2
  • 10
  • This post isn't an actual attempt at answering the question. Please note [StackOverflow doesn't work like a discussion forum](http://stackoverflow.com/tour), it is a Q&A site where every post is either a question or an answer to a question. Posts can also have [comments](http://stackoverflow.com/help/privileges/comment) - small sentences like this one - that can be used to critique or request clarification from an author. This should be either a comment or a [new question](http://stackoverflow.com/questions/ask) – ρяσѕρєя K Jan 11 '17 at 15:20
0

There should be a .NuGet folder at the top of your solution. TFS will use the nuget.exe in this folder for package restore operations.

  • Visit this URL: https://dist.nuget.org/index.html
  • Download the latest nuget.exe
  • Delete the existing nuget.exe from the .nuget folder.
  • Use add/existing item to add the new nuget.exe to this folder.
  • Check in the change.

You should now be able to queue a build and have it restore packages successfully.

Justin Gould
  • 691
  • 5
  • 9