Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. 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...

like image 390
Philippe Lavoie Avatar asked Apr 25 '17 15:04

Philippe Lavoie


1 Answers

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.

like image 74
Aboo Avatar answered Nov 14 '22 17:11

Aboo