Azure-webjobs-sdk: Using System.Data.SqlClient 4.6.0 throws PlatformNotSupportedException

Created on 7 Dec 2018  路  8Comments  路  Source: Azure/azure-webjobs-sdk

I just updated System.Data.SqlClient from 4.5.1 to 4.6 (not preview) and got the same error message as described here https://github.com/dotnet/corefx/issues/33620.

Repro steps

Provide the steps required to reproduce the problem

  1. create any project with a dependency on System.Data.SqlClient version 4.6.0

  2. Try to run it on Azure Functions

Expected behavior

It should not fail.

Actual behavior

Throwing PlatformNotSupportedException.

Known workarounds

Downgrading to 4.5.1 works.

Most helpful comment

There seems some problem when it comes to references related to runtime assemblies, check this issue.

Right click on Function project and Edit <FunctionAppName>.csproj, add items below to copy related assemblies to output dir.

 <!-- For publish -->
  <ItemGroup>
    <None Include="$(USERPROFILE)\.nuget\packages\system.data.sqlclient\4.6.0\runtimes\win\lib\netcoreapp2.1\System.Data.SqlClient.dll">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
  </ItemGroup>

  <!-- For local debug -->
  <Target Name="CopyToBin" BeforeTargets="Build">
    <Copy SourceFiles="$(USERPROFILE)\.nuget\packages\system.data.sqlclient\4.6.0\runtimes\win\lib\netcoreapp2.1\System.Data.SqlClient.dll" DestinationFolder="$(OutputPath)\bin" />
  </Target>

All 8 comments

There seems some problem when it comes to references related to runtime assemblies, check this issue.

Right click on Function project and Edit <FunctionAppName>.csproj, add items below to copy related assemblies to output dir.

 <!-- For publish -->
  <ItemGroup>
    <None Include="$(USERPROFILE)\.nuget\packages\system.data.sqlclient\4.6.0\runtimes\win\lib\netcoreapp2.1\System.Data.SqlClient.dll">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
  </ItemGroup>

  <!-- For local debug -->
  <Target Name="CopyToBin" BeforeTargets="Build">
    <Copy SourceFiles="$(USERPROFILE)\.nuget\packages\system.data.sqlclient\4.6.0\runtimes\win\lib\netcoreapp2.1\System.Data.SqlClient.dll" DestinationFolder="$(OutputPath)\bin" />
  </Target>

Possibly. I don't need 4.6.0 so I will stick to 4.5.1 for the time being. Just wanted to report the issue to make sure someone knows about it :)

@JohnReeson : Thanks for the possible workaround. But it's not working over here ?
Since we are using Microsoft.EntityFrameworkCore.SqlServer 2.2.0, a downgrade to 4.5.1 is not possible.

Any idea on when this could be fixed ?

Same for me. Working with Microsoft.EntityFrameworkCore.SqlServer 2.2.0 and get:

System.Private.CoreLib: One or more errors occurred. (System.Data.SqlClient is not supported on this platform.)

Same here

Can confirm that the issue still exists in (preview) versions beyond 4.6.0.
And... also important to note... that @JohnReeson 's workaround does work.

2019-01-23 16_49_39-mremoteng - confcons xml - my little dev machine
2019-01-23 16_49_51-mremoteng - confcons xml - my little dev machine
(The error is a good sign... as the error occured before actually being able to get a connection error) :)

This workaround is still working locally, but it does not work on Azure Devops anymore. Last time I did a build was December 2018. Yesterday (3/5/2019) The build failed to find the dll in the user nuget path on the build host:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(4582,5): Error MSB3030: Could not copy the file "C:\Users\VssAdministrator\.nuget\packages\system.data.sqlclient\4.6.0\runtimes\win\lib\netcoreapp2.1\System.Data.SqlClient.dll" because it was not found.

Process 'msbuild.exe' exited with code '1'.

Is it in another folder?

I'm having this issue with 4.7.0 preview.

Was this page helpful?
0 / 5 - 0 ratings