9
votes

when I change the targetting from .net 4.6.1 to .net 4.7 .

I get this error when build , but there is no project .json , how can I pass this? project cannot compile now. Severity Code Description Project File Line Suppression State Error `

Your project is not referencing the ".NETFramework,Version=v4.7" framework. Add a reference to ".NETFramework,Version=v4.7" in the "frameworks" section of your project.json, and then re-run NuGet restore.

`

6

6 Answers

27
votes

Delete /bin and /obj and rebuild your solution.

1
votes

Faced the same issue when building the solution which was accidentally created in .NetStandard.

When we changed the project file everything was working fine on one developer machine but the others were facing the exactly same issue.

"Your project is not referencing the ".NETFramework,Version=v4.7" framework. Add a reference to ".NETFramework,Version=v4.7" in the "frameworks" section of your project.json, and then re-run NuGet restore."

To fix this:

  • Clean the solution
  • See if there is anything left in the /bin /obj folder if there then delete them.
  • Rebuild the solution

In our case the obj and the bin files were not cleared by the Clean action.

Hope this helps.

0
votes

Just chiming in here. I applied the same fix as above, which worked. However, when I rebased my changes up a few commits to keep pace, it had the same quibble. Second time around I simply tried remove the bin / obj directories under the offending project and that also seemed to work.

Hate these faffy issues.

0
votes

I have resolve this issue by converting all the referenced project to the same .net framework version. I have changed the project from 4.0 to 4.7 for using ManagementObjectSearcher and ManagementObjectCollection libraries.

-1
votes

I have fixed it by create brand new project with .net 4.7 and then copy the files from old project.

this works but not a good solution , as I should be able to just right click the project and change it from 4.6.1 to 4.7