[DOTS] Why are you constantly adding and removing Newtonsoft.JSON from the dependencies

Last three version updates my project exploded with errors and requires reimport after that, because Newtonsoft.Json was added or removed from the dependencies of the dots stack. I am using Newtonsoft.Json in my project too and I needed to remove it or add back to the project. This was an intended changes or something wrong is going on on my end? And why this is happening?

Also after update to Entities 10.0 project is not compiled, with following errors:

Assets\Scripts\Services\models\SaveManager.cs(60,15): error CS0012: The type 'JsonReader' is defined in an assembly that is not referenced. You must add a reference to assembly 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed

Assets\Scripts\Services\models\SaveManager.cs(60,15): error CS1674: 'BsonDataReader': type used in a using statement must be implicitly convertible to 'System.IDisposable'

But the problem is, that I referenced Newtonsoft.Json in my assembly:

Looks like the last error is because of com.unity.nuget.newtonsoft-json@2.0.0-preview and AOT changes in it.

Valid question. I had newton json in my project too and when I updated my project, the package manager decided to download its own, breaking my whole project. Since it was the first time dealing with this, it took me several hours to figure out how fix the problem. Can’t the package manager figure out that that dependency is already in the project and link to it instead of downloading a new one? Or at least warn us that updating a package will doom the project into oblivion?

Can you enable Auto Reference on the dll?

No, I can’t, because then my assemblies don’t see Newtonsoft.JSON at all.

I just copied unity’s netwonsoft folder from \Library\PackageCache to \Packages and replaced with other netwonsoft (leaving their package.json). Not sure if that will fix your issues.

up

Looks like Unity’s version of Newtonsoft.JSON is not compatible with Newtonsoft.JSON.Bson, that I am using in the project.

Good think we’ve moved away from using Newtonsoft.JSON to GameDevWare JSON. It’s a great package with a solid suite of extension/customization options. Used it for exporting JSON and for consuming a couple of API’s.
At some point when upgrading to newer Entities package we had the same problem, but luckily Newtonsoft package was used only in a couple of places, so we just switched away from it.

The same thing happened to me, whenever they change the dependency it breaks my whole code.

Does anybody know how to remedy the issue? I tried following some of the comments above but was unsuccessful.

You can get your own: com.newtonsoft.json | com.newtonsoft.json | Unity Package (UPM) | OpenUPM

Thank you so much for the help, that was exactly the solution!

For anyone else that comes across this issue, the solution is to add this line "com.unity.nuget.newtonsoft-json": "2.0.0" to the manifest.json file since Unity doesn’t do it automatically. The manifest.json file is located under the Project folder\Packages. Then you can safely delete the Newtonsoft.Json.dll from your Assets folder and use the Unity’s implementation. The Newtonsoft.Bson.Json.dll no longer complains about lack of Newtonsoft.Json.dll.