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

Assembly packaging uses Nuget Packager in VSTS, and I get an error:

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

Most of the tips that solve this include updating nuget, but since I am building Team Services, I cannot do this.

+5
source share
3 answers

We had the same problem today.

Using your own build agent

If you use your own build agents (rather than a hosted agent), you can manually upgrade the version of NuGet to the latest version. In my case, it solved my problems.

eg. C: \ agent \ physical \ NuGet \ nuget.exe

Using Hosted Agent

It's a little dirty, but you can just load the latest nuget.exe into the repo and install NuGet Packager to use this.

+2
source

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

Inline powershell build step - downloads nuget.exe

This script loads the nuget.exe file into the artifact directory (and displays the path to the nuget.exe file so you can see where it is placed.).

Then I changed the build step of Nuget Packager to use the just downloaded nuget.exe file. Nuget Packager build step with custom path for nuget.exe

+4
source

For everyone who gets this in 2018, Microsoft has created a new version of the NuGet task that fixes this problem. No need for powershell installations.

enter image description here

Change the version of the NuGet task in the build step version to 2. *

This caused some changes for me that I allowed using the following additional settings

Nuget Recovery

enter image description here

Nuget pack

enter image description here

Injection

enter image description here

+1
source

Source: https://habr.com/ru/post/1268986/


All Articles