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

余生长醉 提交于 2019-12-10 17:12:09

问题


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.


回答1:


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:

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.




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




回答3:


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




回答4:


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.



来源:https://stackoverflow.com/questions/32393443/tfs-build-2015-failing-because-of-incorrect-nuget-version-even-when-the-required

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!