3

Attempting to install a package via Nuget into VS2012 and am encountering the following error.

PM> install-package microsoft.rest.clientruntime
Attempting to resolve dependency 'Newtonsoft.Json (≥ 6.0.8)'.
Install-Package : 'Microsoft.Rest.ClientRuntime' already has a dependency defined for 'Newtonsoft.Json'.
At line:1 char:16
+ install-package <<<<  microsoft.rest.clientruntime
    + CategoryInfo          : NotSpecified: (:) [Install-Package], InvalidOperationException
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand

This issue is referenced in many locations, including here, but without exception the recommendation is to update to the latest version of Nuget.

I am running the latest version and have not been able to resolve this. Nuget Version: 2.8.60318.667

I also tried to create a brand new solution and install the same package with the same results so it definitely is related to Nuget and not the project.

Community
  • 1
  • 1
McArthey
  • 1,614
  • 30
  • 62

3 Answers3

4

The problem is that the version of NuGet you are using is too old. You need at least NuGet version 2.12.

Visual Studio 2012 does not support NuGet 2.12 which is required by the latest Microsoft.Rest.ClientRuntime since it has dependency groups that target .NETStandard which are unknown by older versions of NuGet and result in the already has a dependency defined for error.

So you would need to upgrade your Visual Studio version, or try using an older version of the Microsoft.Rest.ClientRuntime NuGet package, or not use NuGet and download the Microsoft.Rest.ClientRuntime NuGet package directly from nuget.org and extract the required assemblies.

Matt Ward
  • 47,057
  • 5
  • 93
  • 94
  • I looked for dependencies on NuGet versions but wasn't able to find it. Thanks very much. This was very helpful. – McArthey Jul 14 '16 at 17:47
  • For those looking, I was able to successfully compile after executing "install-package microsoft.rest.clientruntime -Version 1.8.2" – McArthey Jul 15 '16 at 17:48
0

I had this issue recently when creating a private nuget feed within Visual Studio Team Services.

It turns out that after removing a Nuget package it hadn't updated the packages.config correctly and there was an orphaned reference which wasn't part of the .csproj file.

Removing the reference did the trick!

JConstantine
  • 3,980
  • 1
  • 33
  • 46
0

I had this problem using a NGet Package step in VSTS and creating the PowerShell step at this link fixed it:

https://github.com/Microsoft/vsts-tasks/issues/3756#issuecomment-288185011

Adam Hems
  • 121
  • 1
  • 5