0

I'm having an issue when I try to build my project, I get this error:

'Newtonsoft.Json' already has a dependency defined for 'Microsoft.CSharp'

Everything I see about this says to update your nuget package manager, so I updated from VS 2015, to 2017 and that didn't work. I update VS2017 to the latest version, still getting that error when I try to build. I tried setting the build dialog verboisty to Diagnostic, but it did not change the text at all. What else can be causing this, because I'm stumped.

The error is accompanied by this error:

The command ""C:\Users\...\NuGet.exe" pack "C:\Users\...\Project.csproj" -Properties "Configuration=Debug;Platform=AnyCPU" -NonInteractive -OutputDirectory "C:\Users\...Debug" -symbols" exited with code 1.

When I run the command manually in the command prompt, it just gives me the dependency already defined error.

EDIT

This was marked as a possible duplicate. It's not, the 3rd paragraph explains why.

Vandel212
  • 1,074
  • 1
  • 13
  • 28
  • Possible duplicate of ['Newtonsoft.Json' already has a dependency defined for 'Microsoft.CSharp'](https://stackoverflow.com/questions/44532170/newtonsoft-json-already-has-a-dependency-defined-for-microsoft-csharp) – Mojtaba Tajik Aug 18 '18 at 02:01
  • This might sound like a stupid unrelated question: Do you have in your folder path the %20 [space]? I had a similair issue (do not recall exact error), after a long time i figured out that nuget does not like %20 in path names. – Aldert Aug 18 '18 at 18:16
  • Is there a .nuget\nuget.exe in your solution? If so, delete it. – jeroenh Aug 18 '18 at 18:34

1 Answers1

0

Assembly dependency already defined error

You should update the nuget.exe version to 2.12 and above in the path "C:\Users\...\NuGet.exe".

According to the error message, that should be use old nuget.exe to pack the project with dependency netstandard.

As test, I used the old nuget.exe (2.8.6) to pack project with dependency Newtonsoft.Json 11.0.2 like your command line, I got the same error. To resolve this issue, you need to update the nuget.exe in the folder "C:\Users\...\NuGet.exe".

That is the reason why you already update the Visual Studio 2015 to 2017 and still have this issue, because you still use the old nuget.exe in the command line.

Hope this helps.

Leo Liu
  • 71,098
  • 10
  • 114
  • 135