Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TFS Build 2015 failing because of incorrect NuGet version even when the required one is present in the build machine

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.

like image 284
Matías Fidemraizer Avatar asked Sep 04 '15 08:09

Matías Fidemraizer


2 Answers

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.

like image 154
Yan Sklyarenko Avatar answered Oct 05 '22 12:10

Yan Sklyarenko


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...

like image 28
Matías Fidemraizer Avatar answered Oct 05 '22 11:10

Matías Fidemraizer