Microsoft.AspNetCore.Mvc.NewtonsoftJson 5.0.11 is not compatible with netcoreapp3.1
Problem
I’m getting below error when I trying to add NewtonsoftJson
package to asp.net web API core 3.1 project
NU1202: Package Microsoft.VisualStudio.Web.CodeGeneration 5.0.0 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package Microsoft.VisualStudio.Web.CodeGeneration 5.0.0 supports: net5.0 (.NETCoreApp,Version=v5.0)NU1202: Package Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore 5.0.0 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore 5.0.0 supports: net5.0 (.NETCoreApp,Version=v5.0)NU1202: Package Microsoft.VisualStudio.Web.CodeGeneration.Utils 5.0.0 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package Microsoft.VisualStudio.Web.CodeGeneration.Utils 5.0.0 supports: net5.0 (.NETCoreApp,Version=v5.0)NU1202: Package Microsoft.VisualStudio.Web.CodeGeneration.Contracts 5.0.0 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package Microsoft.VisualStudio.Web.CodeGeneration.Contracts 5.0.0 supports: net5.0 (.NETCoreApp,Version=v5.0)NU1202: Package Microsoft.VisualStudio.Web.CodeGenerators.Mvc 5.0.0 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package Microsoft.VisualStudio.Web.CodeGenerators.Mvc 5.0.0 supports: net5.0 (.NETCoreApp,Version=v5.0)Package restore failed. Rolling back package changes for 'SolutionName'.
Solution
To resolve the below error, I tried the following approach, If you found the same error, please try to clear the NuGet package manager cache.
Package restore failed. Rolling back package changes
Downgrade the NewtonsoftJson After I failed to install the NewtonsoftJson package to the application and to get rid of this error Microsoft.AspNetCore.Mvc.NewtonsoftJson 5.0.11 is not compatible with netcoreapp3.1
, I have installed the NewtonsoftJson
3.1.1
0 version
for asp.net core 3.1 version apps, It looks compatibility issue, because the latest NewtonsoftJson 5.0.1 is not compatible with netcoreapp3.1
Summary
After all, I downgraded the package version the build is successful for me, I hope you find them helpful