And yes, I have tried all similar QAs and nothing helped.
What I have tried, none helped:
What I know:
WTF? How is this possible? What else can i clean?
Full log:
Rebuild started...
1>------ Rebuild All started: Project: DotNetExtensions, Configuration: Release Any CPU ------
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\NuGet\16.0\Microsoft.NuGet.targets(198,5): error : Your project does not reference ".NETFramework,Version=v4.7.1" framework. Add a reference to ".NETFramework,Version=v4.7.1" in the "TargetFrameworks" property of your project file and then re-run NuGet restore.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
Get a log file and run it through the MSBuild Structured Log Viewer (see the readme for instructions). If things work with one name but not with the other, it sounds like it's either caching or that the name of the project (DotNetExtensions) conflicts with something in the build process. In either case, the log files will contain clues.
It may also be that a dependent NuGet package has been updated to require .NET Framework 4.7.1, in which case actually re-running the NuGet restore in full might be necessary, particularly on old-style .csprojs where changing the target framework still keeps the current package versions around. In that case you have to delete the packages folder, if it exists, or target the previous package version that made everything work.
I had a very similar error except it was:
Your project does not reference ".NETFramework,Version=v4.8" framework. Add a reference to ".NETFramework,Version=v4.8" in the "TargetFrameworks" property of your project file and then re-run NuGet restore.
What worked for me was to use Visual Studio to 1) clean the solution and then 2) delete all obj and bin folders. Then it built without restarting VS.
I think it was a bad cache of the project.assets.json file. It must have gotten corrupt when restoring a stash that required a merge. VS didn't automatically load the projects. It isn't related to the TargetFrameworks because when you add that property to the csproj file, a different build step fails.
I tried to port my projects to .net 5.0 and encountered this problem when reverting back to 4.8. This worked for me:
I got the same problem using .net framework 4.8 and visual studio 16.10.2 and I fixed it using below options
Solved my problem.
If still this not help you then
delete bin and obj folders , then build must solve the problem