Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Packaging nuget package on VSTS 'Newtonsoft.Json' already has a dependency defined for 'NETStandard.Library'

Packaging a build use Nuget Packager in VSTS and i get the error:

[error]'Newtonsoft.Json' already has a dependency defined for 'NETStandard.Library'.

Most of the hints that solves this involves updating nuget, but since I am building on Team Services I can't really do this.

like image 345
ruffen Avatar asked Jun 19 '17 13:06

ruffen


2 Answers

It seems that the nuget used by nuget packager is not the latest. After testing locally with latest nuget.exe everything worked so I added a new powershell release step. This solution is appropriate for VSTS, for TFS where you have access to the server I recommend upgrading nuget.exe on the server itself:

Inline powershell build step - downloads nuget.exe

This script downloads nuget.exe into the artifacts directory (and outputs the path to the nuget.exe so you can see where it is put.).

I then altered the Nuget Packager build step to use the freshly downloaded nuget.exe. Nuget Packager build step with Custom path to nuget.exe

like image 70
ruffen Avatar answered Nov 03 '22 01:11

ruffen


Had the same issue today.

Using your own build agent

If you are using your own build agents (rather than the hosted agent) you can manually update the version of NuGet to the latest version. In my case, this has resolved my problems.

e.g. C:\agent\externals\nuget\nuget.exe

Using the hosted agent

It's a bit messy but you could just upload the latest nuget.exe into the repo and set the NuGet Packager to use this.

like image 44
Tim Porter Avatar answered Nov 03 '22 02:11

Tim Porter