If you've stumbled upon this post, it most likely means that you've switched the .NET Runtime Framework of your ASP.NET project(s) to a newer 4.x version, such as .NET Framework 4.7.2...
... And, right after changing that setting, getting the following error:
Your project does not reference ".NETFramework,Version=v4.7.2" framework. Add a reference to ".NETFramework,Version=v4.7.2" in the "TargetFrameworks" property of your project file and then re-run NuGet restore.
I had to deal with such issue today and I was kind of lost, since the error message gives no indication at all regarding the configuration file containing that wrong reference.
StackOverflow to the rescue
Eventually I had the luck to find this StackOverflow thread that told me what to do. The issue was due to the presence of an odd project.assets.json file in the /obj/ folder, which pointed to the previous framework version (in my case 4.6.2) instead of the one I've selected for the update (4.7.2):
It seems like this project.assets.json file file is a leftover of some previous .NET Framework versions, most likely < than 4.7.2: oddly enough, such file is not removed or updated when the .NET Framework version of the project change or by the Build, Rebuild or Clean commands.
Anyway, once the root of the issue became clear, the fix was very simple: manually deleting the /obj/ folder of each affected project made the error disappear and allowed Visual Studio to build the project successfully. While I was there, I also took the chance to delete the /bin/ folder as well. Luckily enough these two folders are automatically re-created upon the first successful build, hence they can be both safely deleted to fix these kind of issues.
That's it, at least for the time being: I hope that this small guide will help other ASP.NET developers who'll stumble upon this issue in the future. See you next time and... happy building!