Build error while transitioning between branches: Your project is not referencing the “.NETFramework,Version=v4.7.2” framework

前端 未结 8 1191
暗喜
暗喜 2021-02-01 12:40

We\'re using Git and we have a solution which is targeting the full net framework. A couple of days ago, I\'ve started migrating the solution to .net core. Unfortunately, someth

8条回答
  •  一生所求
    2021-02-01 13:21

    I had a similiar issue when upgrading some projects from 4.6.2 to 4.7.2 - this happened for both our ASP.Net Core solution targetting full framework, and our WPF solution.

    Initially it seemed to be random projects that had this error, other projects with near exact same csproj were building fine and others were failing. The 're-run NuGet restore' in the message sent me down the wrong path aswell (some of these projects didn't even have NuGet references...)

    The issue appears to stem from the projects obj folder containing a project.assets.json file, I'm not sure when this was generated - likely relics from the past, and cleaning the project does not remove this. The file points to the previous framework, in my case 4.6.2 - Manually deleting the bin/obj folders for each project that wouldn't build & then rebuilding resolved this error for me. This would also explain why when I cloned the repo for my sanity, it also built fine.

提交回复
热议问题