[Solved] Package restore failed. Rolling back package changes for ‘Solution name’ Microsoft.AspNetCore.Mvc.NewtonsoftJson 5.0 to .NET Core 3.1

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.10 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

Summery

After all, I downgraded the package version the build is successful for me, I hope you find them helpful

Default image
Shivaraju M
Over 3+ years experience in IT industry, good knowledge in . Net-based Web applications, windows applications, web services, and SPAs. I have played multiple roles related to technical delivery in multiple domains while working on over 10+ technologies. I am currently focused on continuous improvement and agile project management.

Leave a Reply