Description
Given a project which targets netcoreapp2.0. And a package which targets netstandard13 - Devart.Data.PostgreSql (ado.net provider for Postgres).
Installing in VS
The package cannot be installed in VS2017.3. It silently fails.
Installing via cli
dotnet add package Devart.Data.PostgreSql
installs the package, but build fails (it's only a excerpt from full output):
D:\Work\Learn\dotnet\devart_pgsql>dotnet build
D:\Work\Learn\dotnet\devart_pgsql\devart_pgsql.csproj : error NU1605: Detected package downgrade: System.Net.Primitives from 4.3.0 to 4.0.11. Reference the package directly from the project to select a different version. \r [D:\Work\Learn\dotnet\devart_pgsql\devart_pgsql.sln]
D:\Work\Learn\dotnet\devart_pgsql\devart_pgsql.csproj : error NU1605: devart_pgsql (>= 1.0.0) -> Devart.Data.PostgreSql (>= 7.9.958) -> NETStandard.Library (>= 1.6.1) -> System.Net.Primitives (>= 4.3.0) \r [D:\Work\Learn\dotnet\devart_pgsql\devart_pgsql.sln]
D:\Work\Learn\dotnet\devart_pgsql\devart_pgsql.csproj : error NU1605: devart_pgsql (>= 1.0.0) -> Devart.Data.PostgreSql (>= 7.9.958) -> System.Net.Primitives (>= 4.0.11) [D:\Work\Learn\dotnet\devart_pgsql\devart_pgsql.sln]
D:\Work\Learn\dotnet\devart_pgsql\devart_pgsql.csproj : error NU1605: Detected package downgrade: System.Reflection from 4.3.0 to 4.1.0. Reference the package directly from the project to select a different version. \r [D:\Work\Learn\dotnet\devart_pgsql\devart_pgsql.sln]
Here's the dependencies of the package:
<dependencies>
<group targetFramework=".NETStandard1.3">
<dependency id="Microsoft.Extensions.PlatformAbstractions" version="1.0.0" />
<dependency id="Microsoft.NETCore.Portable.Compatibility" version="1.0.1" />
<dependency id="Microsoft.Win32.Registry" version="4.0.0" />
<dependency id="NETStandard.Library" version="1.6.1" />
<dependency id="System.ComponentModel" version="4.3.0" />
<dependency id="System.ComponentModel.Annotations" version="4.1.0" />
<dependency id="System.ComponentModel.Primitives" version="4.1.0" />
<dependency id="System.ComponentModel.TypeConverter" version="4.1.0" />
<dependency id="System.Diagnostics.FileVersionInfo" version="4.0.0" />
<dependency id="System.Net.NameResolution" version="4.0.0" />
<dependency id="System.Net.Primitives" version="4.0.11" />
<dependency id="System.Net.Requests" version="4.0.11" />
<dependency id="System.Reflection" version="4.1.0" />
<dependency id="System.Runtime.InteropServices.RuntimeInformation" version="4.0.0" />
<dependency id="System.Security.Cryptography.Algorithms" version="4.2.0" />
<dependency id="System.Security.Cryptography.Csp" version="4.0.0" />
<dependency id="System.Threading.ThreadPool" version="4.0.10" />
<dependency id="System.Xml.XmlDocument" version="4.0.1" />
<dependency id="Devart.Data" version="5.0.1750" />
</group>
</dependencies>
I managed to workaround the issue by adding the following package references into csproj:
<PackageReference Include="System.IO.FileSystem.Primitives" Version="4.3.0" />
<PackageReference Include="System.Net.NameResolution" Version="4.3.0" />
<PackageReference Include="System.Net.Primitives" Version="4.3.0" />
<PackageReference Include="System.Reflection" Version="4.3.0" />
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" Version="4.3.0" />
<PackageReference Include="System.Security.Cryptography.Algorithms" Version="4.3.0" />
<PackageReference Include="System.Security.Cryptography.Csp" Version="4.3.0" />
After that the project builds and runs successfully. But only for netcoreapp2.0.
If I build and run it for net462:
<TargetFrameworks>netcoreapp2.0;net462</TargetFrameworks>
it fails:
Error Message:
System.IO.FileNotFoundException : Could not load file or assembly 'System.Security.Principal.Windows, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
So for net462 I added:
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<PackageReference Include="System.Security.Principal.Windows" Version="4.3.0" />
</ItemGroup>
After that it builds and runs on net462 too.
But I think it's too cumbersome. Also it requires manual csproj editing and does not work via VS Package Manager out of the box. So I believe it's not a normal situation.
P.S. I really have no idea where such an issue should be reported, so please feel free to move it to an appropriate repo.