Add a reference to ".NETFramework,Version=x" in the "TargetFrameworks" property of your project file and then re-run NuGet restore?
Sometimes when upgrading .NET framework versions you might get this really strange error in Visual Studio:
-"Add a reference to ".NETFramework,Version=v4.8" in the "TargetFrameworks" property of your project file and then re-run NuGet restore?"
Usually Visual Studio is quite helpful and if you click the error message it will point you in the direction of the file and line where this issue occurs. But not in this case.
Ever wiered, if you go to the projects .csproj file and look at the TargetFrameworks property (as suggested by the error message) it matches the correct version number.
And a re-running NuGet retore does not help either (again, as suggested by the error message).
Sometimes Visual Studio gets confused when upgrading .NET versions and in these cases this procedure almost always does the trick:
- Righ-click Solution > "Clean Solution".
- Delete bin folder.
- Delete obj folder.
- Rebuild Solution.
Sometimes it's that easy.
Cheers friends! ❤️