I have a library written using .NET Core, targetting .netstandard2.0. According to this site it should be compatible to use the that version of a .NET Core library with .NET 4.6.2 and 4.6.1. However, when I try to build my .NET Framework library, I get this error:
Project 'c:\myproj.csproj' targets '.NETStandard,Version=v2.0'. It cannot be referenced by a project that targets '.NETFramework,Version=v4.6.2'.
I'm using Visual Studio 2017 to build the libraries. Is what I'm doing not possible/supported and I'm just misinterpreting the information on the website? The .NET Framework library is referencing System.Management.Automation and is a PowerShell Module, but references code in the .NET core library that is being used in other projects as well.
I resolved this issue by placing this in the tag:
<TargetFrameworks>netstandard2.0;net462</TargetFrameworks>
<TargetFrameworkIdentifier Condition="'$(_ShortFrameworkIdentifier)'=='net'">.NETFramework</TargetFrameworkIdentifier>
<TargetFrameworkIdentifier Condition="'$(_ShortFrameworkIdentifier)'=='netstandard'">.NETStandard</TargetFrameworkIdentifier>
This allowed me to build the .NET Framework class library referencing the .NET core project. Not what I expected from the documentation, since it makes it seem like .netstandard is the new PCL, but it works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With