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
This is a useful troubleshooting note for developers working with Visual Studio and .NET Framework projects. When the target framework is configured correctly but NuGet still reports a missing framework reference, stale intermediate build files can be the cause. Manually deleting the obj folders and recompiling is a practical workaround when a standard Clean and Rebuild does not resolve the issue.
ReplyDeleteFor developers building application-based solutions, understanding these environment-specific issues is just as important as writing code. Exploring Web Development Projects can provide opportunities to apply development concepts while learning to troubleshoot real-world build and configuration problems.
This is also relevant to anyone learning the Microsoft development ecosystem. A Dot Net Full Stack Developer Course can help developers build a stronger foundation in application development, project configuration, and debugging techniques that are valuable when resolving issues like this.
ReplyDelete