简体   繁体   中英

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.

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:

内联powershell构建步骤 - 下载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构建步骤,使用nuget.exe的自定义路径

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.

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

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.

在此输入图像描述

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

在此输入图像描述

Nuget Pack

在此输入图像描述

Nuget push

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM