-
Notifications
You must be signed in to change notification settings - Fork 68
Description
Description
When building a netcoreapp3.1 or netstandard2.1 library, the build will succeed when using Visual Studio 2019 but will fail when built via dotnet build.
Error details:
error FS3033: The type provider 'FSharp.Data.SqlCommandProvider' reported an error: Could not load file or assembly 'System.Data.SqlClient, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (0x80131058)
Repro steps
Create a dotnet core library which uses the type provider.
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors></WarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Data.SqlClient" Version="4.8.1" />
<PackageReference Include="FSharp.Data.SqlClient" Version="2.0.6" />
</ItemGroup>
Expected behavior
I'd expect the non-reference version of System.Data.SqlClient to be loaded and the build to succeed.
Actual behavior
The type provider is unable to load the System.Data.SqlClient assembly as it is a reference assembly.
Known workarounds
Forcing the project to use the full framework compiler seems to work, but you need to set some properties for this to work in .netcore3.0
<PropertyGroup>
<DisableAutoSetFscCompilerPath>true</DisableAutoSetFscCompilerPath>
<DotNetFscToolPath></DotNetFscToolPath>
<DotnetFscCompilerPath></DotnetFscCompilerPath>
</PropertyGroup>
<Import Project="fsc.props" />
Related information
I found a number of what appear to be related but older issues. As far as i can tell .NET Standard 2.0 type providers can now be used when the F# compiler is running on .NET Core. So I believe this is an issue with loading the correct System.Data.SqlClient assembly?
- F# and Visual F# Tools announcement for June dotnet/fsharp#3298
- Project with target netcoreapp2.0 will not build with SQLProvider package version 1.1.38. SQLProvider#529
- https://medium.com/@dsincl12/f-with-net-core-2-0-4-and-sqlprovider-d8f071119da9
- designer assembly 'FSharp.Data.SqlClient.DesignTime.dll' cannot be loaded or doesn't exist #318
Environment
- Windows
- SDK 3.1.100
- F# 4.7