Your project does not reference “.NETFramework,Version=v4.6.2” framework. Add a reference to “.NETFramework,Version=v4.6.2” in the “TargetFrameworks”

风格不统一 提交于 2019-12-05 08:24:19

问题


I can't run my unit tests.

I have the next error:

Your project does not reference ".NETFramework,Version=v4.6.2" framework. Add a reference to ".NETFramework,Version=v4.6.2" in the "TargetFrameworks" property of your project file and then re-run NuGet restore.

In app.config:

<startup>
  <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/>
</startup>

In Project > Properties > Application > TargetFramework (.NET Framework 4.6.2)

How can I fix it?


回答1:


Please make the next steps

  1. Clean solution
  2. Clean folder "packages"
  3. Delete folder "bin"
  4. Delete folder "obj"



回答2:


I up-voted Larissa but I thought it might be helpful to know how I got into this. I added a .net standard project file to my build (we target lots of platforms) and it produced the debris found in the obj folder. When the android sanity build came around, it threw up on the obj folder. My solution was to clean that folder out as a pre-build step. This is a difficult problem because it was working just fine for years...needle meet haystack.




回答3:


I ran into the same thing with .net 4.71. In my case, I simply migrated from packages.config to "package references" per

Migrate from packages.config to PackageReference

... and it fixed my issue. For me, I was going to do this anyway, so if you're going this way already, I'd just skip the above and migrate to package references.



来源:https://stackoverflow.com/questions/52833741/your-project-does-not-reference-netframework-version-v4-6-2-framework-add-a

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!