0

I have created a .NET framework 4.6.2 web application.

Then I have created a .NET Standard class library. The target framework is 1.6 or 1.5 or everything lower it does not matter.

When I add the web application as project reference to the .NET Standard class library (unit test project) I get this error:

Severity    Code    Description Project File    Line    Suppression State
Error       One or more projects are incompatible with .NETStandard,Version=v1.5.               
Error       Project Api is not compatible with netstandard1.5 (.NETStandard,Version=v1.5). Project Api supports: net462 (.NETFramework,Version=v4.6.2)  

I use Visual Studio 2017 and have latest .NET Core 1.0/11 SDK installed.

How can I make it work?

1
  • Microsoft clearly knows the .NET Standard projects should not use any non-.NET Standard libraries/projects as references. What are you looking for exactly? Do you really know what is .NET Standard? Commented May 29, 2017 at 0:00

1 Answer 1

1

In the current 1.0 tooling .NET 4.6.2 can reference a .NET Standard 1.5 project, but a .NET Standard 1.5 project can not reference a .NET 4.6.2 project.

Once the "Tooling 2.0" comes out with netstandard 2.0 you will be able to do both directions using the new shims feature, but until that comes out you will need to make your class library unit test project also a .NET 4.6.2 project.

Sign up to request clarification or add additional context in comments.

6 Comments

That was my half... solution too, but I need to add some nugets Microsoft.AspNetCore.* to my NetStandard class library, because they do not work with NET462 HAHAHA.... Does Microsoft actually know what they do?
Yes, that is why they are releasing tooling 2.0 to fix all this.
@Pascal: Even with 2.0 tooling you won't make yourself a favor by referencing most of the .NET >=4.5 dlls this way. Unless you are 120% certain that the referenced DLL only use netstandard1.6 (or 2.0) API, it will be a ".NET Framework" solution and explode when run on .NET Core (either windows or linux) at runtime and gives people a wrong impression that it's crossplatform because "library A targets netstandard", but references a ".net 4.5 dll which uses API which are not available in .NET Standard"
But what is the point to allow reference full .NET dll from .NET standard?
@Tseng so my goal should be then for now to create a .NET Core web app with class library STandard 2.0 preview ?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.