[英]Project X targets '.NETStandard,Version=v1.6'. It cannot be referenced by a project that targets '.NETFramework,Version=v4.6.1'
I really wanted to be a good citizen... copied all my classes to .net standard 1.6 libraries. 我真的想成为一个好公民...将我的所有课程复制到.net标准1.6库。 Just to find out that my test DLL can't use it.
只是为了发现我的测试DLL无法使用它。 I get the following error
我收到以下错误
Project X targets '.NETStandard,Version=v1.6'.
Project X的目标是'.NETStandard,Version = v1.6'。 It cannot be referenced by a project that targets '.NETFramework,Version=v4.6.1'.
它不能被针对'.NETFramework,Version = v4.6.1'的项目引用。
Of course, when I check .Net Standard ( https://docs.microsoft.com/en-us/dotnet/articles/standard/library ) it says that with 1.6 it can target 4.6.1 . 当然,当我检查.Net标准版( https://docs.microsoft.com/en-us/dotnet/articles/standard/library )时,它说1.6 可以达到目标4.6.1 。
I tried 4.6.2 without better luck. 我试过4.6.2但没有更好的运气。 I installed the
.net standard 1.6.1
NuGet package. 我安装了
.net standard 1.6.1
NuGet包。 Anyway, you guys are awesome, I'm sure you'll tell me which stupid mistake I'm making that is preventing me from doing something as basic as running unit tests with a .net standard library. 无论如何,你们真棒,我相信你们会告诉我我正在做的哪个愚蠢的错误让我无法做一些像使用.net标准库运行单元测试那样基本的事情。
Thanks 谢谢
PS I did find a work around (kind of) by using a .net core unit test project instead of a .net framework one. PS我确实通过使用.net核心单元测试项目而不是.net框架来找到一种解决方法(种类)。 It doesn't solve my problem, so I can't mark that as an answer, but at least I can go back to coding...
它没有解决我的问题,所以我无法将其标记为答案,但至少我可以回到编码......
You need to upgrade to .Net Core SDK 2.x+ 您需要升级到.Net Core SDK 2.x +
Once that is installed restart your machine and you should be able to reference NetStandard 1.6 in .Net Framework 4.6.1+ 安装完成后,重新启动计算机,您应该可以在.Net Framework 4.6.1+中引用NetStandard 1.6
With .Net Core SDK 1.x you can only reference Net Standard 1.5 in .Net Framework 4.6.2 使用.Net Core SDK 1.x,您只能在.Net Framework 4.6.2中引用Net Standard 1.5
Best would be to upgrade your Net Standard project to version 2.0 if you can. 如果可以,最好将Net Standard项目升级到2.0版。
如果针对不同版本的.net框架的类似标题出现错误,这通常意味着您需要(如果已经没有安装)将项目目标更改为.net框架的新版本/最新版本以符合针对较新的.net标准的项目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.