Your project does not reference error!


The error "Your project does not reference ".NETFramework,Version=v4.6.1" framework. Add a reference to ".NETFramework,Version=v4.6.1" in the "TargetFrameworks" property of your project file and then re-run NuGet restore" troubled me a bit at work today.

The target framework was set correctly and I had 4.6.1 on my dev machine. IDE was VS 2019. So what was the problem? 

Good old fashioned googling helped me to resolve the issue and so adding this note here as a reference for myself. It turns out the solution was to delete the obj folders and just recompile.

Just doing a clean and rebuild did not help. I had to delete the obj folder manually and then recompile worked.

The link that helped me with this is in the reference below.  It seems like lot of people have come across this same problem. Latest comment on that thread is from Jan 2020 and looks like the issue is still unresolved from VS team. This is at least one of the workarounds that solves this issue.

Reference:
https://developercommunity.visualstudio.com/content/problem/312180/projects-fail-to-build-in-1580-due-to-errors-from.html

Comments

Popular posts from this blog

How to enable elasticsearch access from remote machines

Add co-administrators for your azure subscription