5

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.

8
  • I've hit this one as well today. Commented Jun 19, 2017 at 22:32
  • What're detail steps to reproduce this issue? Do you use Hosted agent? What's the project type you used? What's the result if you package it through NuGet.exe tool manually? Commented Jun 20, 2017 at 6:57
  • 1
    You can specify Nuget.exe tool path for NuGet Package task (Advanced) Commented Jun 20, 2017 at 6:58
  • I am building with Hosted Visual Studio 2017 agent and packaging using the nuget packager. I managed to solve it by using powershell to download nuget.exe and pointing the packager to this new instance.
    – ruffen
    Commented Jun 20, 2017 at 7:24
  • 1
    @FIL I added TFS tag back and changed my answer to reflect that my solution is for VSTS and not recommended for TFS.
    – ruffen
    Commented Nov 30, 2017 at 10:01

3 Answers 3

4

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

2
  • Hello and thanks for this since it addresses the issue I'm having. Still I've never worked with powershells. Could you tell me or share a link so I know how to add a powershell step and how to alter the Nuget build so I can replicate what you did? Thanks in advance.
    – Daniel Sh.
    Commented Jun 29, 2017 at 12:25
  • You pretty much just replicate what I added in the picture. I used the "Inline powershell" build script. Followed by the nuget packager build step, here you can just replicate what is in the second image.
    – ruffen
    Commented Jun 29, 2017 at 18:12
2

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.

1
  • 1
    This would work as well, I resolved it by using powershell to download the latest nuget and use this.
    – ruffen
    Commented Jun 20, 2017 at 8:51
1

To anyone getting this in 2018, Microsoft have created a new version of the NuGet task that fixes this issue. No need for powershell install steps.

enter image description here

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

This caused some breaking changes for me, that I resolved with the following advanced settings

Nuget Restore

enter image description here

Nuget Pack

enter image description here

Nuget push

enter image description here

1
  • Are you using VSTS or a local TFS installation? Commented Apr 5, 2018 at 7:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.