8

I'm using .NET core on a mac with Visual Studio Code. i'm trying to install NewtonSoft.Json to use as a Json parser. The command I use is:

nuget install CoreCompat.NewtonSoft.Json -Pre

I use this command in my top level project folder. This leaves me with two problems. Firstly, and most glaring, I am still not able to use the package in my code.

using NewtonSoft.Json;

will not compile. Secondly, although this does download the package, it downloads a whole bunch of other stuff too - files like System.Threading, and puts them in my project directory. There are about 40 of these extra files. I already have these dependencies (which I'm assuming they must be) in my .nuget folder (and I'm able to include them in any project). I don't want to clutter up my project folder. How do I properly use nuget to install this package?

1 Answer 1

18

The command you want is

dotnet add package NewtonSoft.Json

This will add the following to your csproj file, which you could also do manually.

  <ItemGroup>
    <PackageReference Include="NewtonSoft.Json" Version="10.0.2" />
  </ItemGroup>

Then you can use dotnet restore, dotnet build and friends to continue developing.

I also believe that you didn't mean to use the CoreCompat. prefixed package as this is not the original JSON.net library.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.