Reputation: 759
I have a project named Site.Dal that compiles using netstandard2.0.
csproj is :
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp2.2;netcoreapp3.1;netstandard2.1;netstandard2.0</TargetFrameworks>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Elastic.Apm.NetCoreAll" Version="1.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Models\Models\Models.csproj" />
</ItemGroup>
</Project>
This project is referenced in a .netframework 4.7.2 project. When I run it, it fails with error: "Microsoft.Data.SqlClient is not supported on this platform". This is a dependancy of Microsoft.EntityFrameworkCore.
I've spent few hours on this problem, reading tons of article than all mention to add in the csproj:
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="copy $(OutDir)$(ProjectName).deps.json $(OutDir)bin\$(ProjectName).deps.json" />
</Target>
<Target Name="PostPublish" BeforeTargets="Publish">
<Exec Command="copy $(PublishDir)$(ProjectName).deps.json $(PublishDir)bin\$(ProjectName).deps.json" />
</Target>
Upvotes: 3
Views: 2954
Reputation: 21
I had this issue and resolved it by simply installing the Microsoft.Data.SqlClient
package.
Upvotes: 1