How to fix `Your project does not reference ".NETFramework,Version=v4.6.1" framework...`

Luke picture Luke · Jun 10, 2019 · Viewed 8.2k times · Source

I got this 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. after checkout a project from company repository and rebuild on my machine.
When I try to install .Net461 (downloaded from here) they said

.NET Framework 4.6.1 or a later update is already installed on this computer.

This is all .NET framework versions on my machine (Windows 10 1703)

PS C:\Users\longnx\Downloads> & '.\check-dotnet-framework-version (1).ps1'

PSChildName                      Version        Release
-----------                      -------        -------
v2.0.50727                       2.0.50727.4927
v3.0                             3.0.30729.4926
Windows Communication Foundation 3.0.4506.4926
Windows Presentation Foundation  3.0.6920.4902
v3.5                             3.5.30729.4926
Client                           4.7.03062      461814
Full                             4.7.03062      461814
Client                           4.0.0.0


PS C:\Users\longnx\Downloads>

How can I fix this error?


update on 2020-05-26:
for anyone face this problem, I don't suggest this but from my experience, I've uninstalled and reinstall visual studio, and problem gone.

Answer

Henry He  picture Henry He · Sep 4, 2019

I found this link from a google search and tried it and it fixed my issue so I thought I might share that deleting the obj folders seems to work.

As it states in forum:

I had the same with an old project (after using git to move to an old version locally). Deleting the 'obj' folders fixed the issue, clean is insufficient.

Two users found that this fix the issue. Most also found doing a clean and then removing the obj folder by hand then redoing a nuget restore seemed to fix the issue.