I have finally installed Visual Studio 2017.2 and am trying to get my first project working, but am running into some trouble that I hope to address here.
I have a very simple .NET Standard Library described as the following project file:
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>netstandard1.6</TargetFramework> </PropertyGroup> </Project>
And a very simple .NET Framework console application that references the above .NET Standard library, and is described as the following project file:
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>net45</TargetFramework> </PropertyGroup> <ItemGroup> <ProjectReference Include="..\Common\Common.csproj" /> </ItemGroup> </Project>
When I build my console application, I get the following build error:
C:\Program Files\dotnet\sdk\1.0.4\NuGet.targets(97,5): error : Project Common is not compatible with net45 (.NETFramework,Version=v4.5). Project Common supports: netstandard1.6 (.NETStandard,Version=v1.6)
I saw this question and tried some of the suggestions provided there, but none of them worked. So, this appears to be a different problem. Please note that this occurs during the build of my solution and not referencing (explicit) NuGet packages in any way.
Finally, if it helps, I have a solution that demonstrates this issue here: https://github.com/Mike-EEE/Stash/blob/master/VS2017.Multi/VS2017.dotNetFramework.sln
If you are not sure which version of . NET Standard you should target, go with 2.0 as it offers a balance of reach and APIs available for you to use. If your goal is to make your library usable for many frameworks as possible while gettings all the APIs you can from .
.NET Framework 4.5 only supports using .net standard libraries targeting .NET Standard 1.0 or 1.1. Since your library targets 1.6, the tooling does the right thing here and errors out (since your library may use APIs not available in .NET Framework 4.5). If you published the library as NuGet package and consumed it via a package reference, the package restore would error out as well (with an error saying that the package is incompatible).
There is some confusion about which .NET Standard version a .NET Framework version supports especially since there is preview tooling available ("2.0") that changes these versions. The ".NET platforms support" table in the documentation therefore contains two lines about the supported versions. In your case however, both versions limit .NET Framework 4.5 to .NET Standard 1.1.
for .net framework projects to be compatible with .net standard libraries you must acquire the NETStandard.Library
from the nuget.
Now i cannot find any official resource that states exactly why this is a must, but from what i understand the NETStandard.Library
has the necessary links to make a map from .NET Standard API's to .NET Framework.
If you want more info i suggest to read the official docs of NET Standard.
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