-
Notifications
You must be signed in to change notification settings - Fork 0
Notes
While Microsoft.Data.SqlClient is a modern package with full support for .NET Core and the new .NET it has a few limitations with regards to it's usage in a type provider. The issues mostly stem from the fact that dotnet cannot load packages, it can only load assemblies. The assemblies that need to be loaded depend on the tooling runtime, because the TP runs in the tooling context.
I can't find a good reference for what runtimes the tooling host uses but the situation is something like:
- Visual Studio might use net48
- dotnetbuild might use netcoreapp3.1
Then there are native components for win and unix that nuget packages can specify. So depending on the OS the correct runtime assemblies also need to use used.
The first issue I ran into is that the ref assembly is loaded for Microsoft.Data.SqlClient when building. This package has win and unix versions which you need to use to be able to actually connect to a database. This can be resolved with TypeProviderForNamespaces.ResolveAssembly and some custom code to find the correct assembly. I was able to get this working but I ran into a second issue.
The package Microsoft.Data.SqlClient depends on Microsoft.Data.SqlClient.SNI so that package needs a runtime assembly to be loaded as well.
Currently I'm trying to figure out how to load the dll for this package, which doesn't seem to be working. To test it I'm building SqlClient.Tests on the command line with dotnet build.
I'm also getting a different error when I try to build the project in Visual Studio: `Severity Code Description Project File Line Suppression
The type provider 'C:\Projects\FSharp.Data.SqlClient\bin\netstandard2.1\FSharp.Data.SqlClient.dll' reported an error: The type provider designer assembly 'FSharp.Data.SqlClient.DesignTime.dll' could not be loaded from folder 'C:\Projects\FSharp.Data.SqlClient\bin\netstandard2.1'.
The exception reported was: System.IO.FileNotFoundException - Could not load file or assembly 'netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.
I wonder if I could avoid these issues by using a merged TP without a separate TPDTC).
Technical notes for how to build a type provider