[NU1605] Detected package downgrade: … Reference the package directly from the project to select a different version.
This happened to me recently and I’m going to describe how I fixed it. If you don’t use Paket you may need to adapt these instructions or look elsewhere as there are plenty of nuget specific suggestions online.
For me the Solution it happened with had a number of projects, it also had a packages folder. The first step was to delete all of the files in the packages folder.
The next step was to delete all the bin and obj folders from all of the projects in the solution.
There is a minor Gotcha here which is that paket still thinks that the last restore is up to date. All you have to do is to force it with
paket restore --force
or if you prefer
paket update --force
Which forces all of your dependencies to download. It can take a little while but for me at least it solved the problem.
When this happened the second time, after I did the force I got the following error
Microsoft.PackageDependencyResolution.targets(267, 5): [NETSDK1004] Assets file ‘C:\MyProj\obj\project.assets.json’ not found. Run a NuGet package restore to generate this file.
A simple dotnet clean resolved this.