Reputation: 177
I really wanted to be a good citizen... copied all my classes to .net standard 1.6 libraries. Just to find out that my test DLL can't use it. I get the following error
Project X targets '.NETStandard,Version=v1.6'. It cannot be referenced by a project that targets '.NETFramework,Version=v4.6.1'.
Of course, when I check .Net Standard (https://learn.microsoft.com/en-us/dotnet/articles/standard/library) it says that with 1.6 it can target 4.6.1.
I tried 4.6.2 without better luck. I installed the .net standard 1.6.1
NuGet package. 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.
Thanks
P.S. I did find a work around (kind of) by using a .net core unit test project instead of a .net framework one. It doesn't solve my problem, so I can't mark that as an answer, but at least I can go back to coding...
Upvotes: 13
Views: 5284
Reputation: 5364
In case of errors with similar titles that are targeting different versions of .net framework, this usually means that you need to (install if already not and) change the target of your project to newer/newest version of .net framework to comply with the project that targets newer .net standard.
Upvotes: 1
Reputation: 2464
You need to upgrade to .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+
With .Net Core SDK 1.x you can only reference Net Standard 1.5 in .Net Framework 4.6.2
Best would be to upgrade your Net Standard project to version 2.0 if you can.
Upvotes: 1