-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SqlTypeProvider build error with dotnet core 2.0 #474
Comments
If you clone this repo, do you get the example project to compile? |
I ran |
Ok, so I expect there are no reference assemblies present or some other problem with your project file. Please see the example. I know it's not optimal that things do not yet work straight out-of-the-box. I hope we'll get to that direction, but I haven't yet figured out how to load dependency NuGet packages when using reflection, without a large amount of other dependencies. |
Hi, Here is my output:
|
Every time you see this error it is because of this dotnet/fsharp#3303 Apply the workaround there |
@dsyme I applied that workaround when I ran into #460, then this issue happened. |
Yes, that was a response to @fredc0088. @danschultz you need to give a referencePath (a directory) where is located Npgsql.dll, System.Threading.Tasks.Extensions.dll and System.Data.Common.dll. |
@dsyme Thanks!! It seems to have worked out, adding the f# .net framework compiler in the project file. I still hope there is some work for core to support type providers natively |
Just to be clear, I'm not able to use SQLProvider in .net core without full .net framework, am I right? |
Maybe the documentation should be more clear...
|
Hi @Thorium , just to be clear - the current state is that I am ABLE to build .netcoreapp2.0 project having SQLProvider, but not .netstandard2.0 library, correct? |
As far as I know, the .netstandard2.0 and .netcoreapp2.0 should both work. |
Thanks for info, @Thorium. However, something strange is still happening because building .netcoreapp2.0 is ok, but switching to .netstandard2.0 I got error:
Should I create new issue for this? |
Ok, create an issue. Edit: Ok, I'm able to reproduce this. It comes from file ProvidedTypes.fs class ProvidedTypesContext method Create because baseObj is null. We could try to update the latest TypeProvider SDK but this method is not changed. I'll create an issue there. |
Thanks @Thorium, I was just about to push special repo for this (to safe you some work), but you already found it. Thanks again and thanks for opening fsprojects/FSharp.TypeProviders.SDK#177 |
@Thorium I'm confused, I tried adding references to the .dlls for Npgsql.dll, System.Threading.Tasks.Extensions.dll and System.Data.Common.dll. But I'm still getting the same error as the original poster. I'm using dotnet core 2.0 and linux. |
More details: http://fsprojects.github.io/SQLProvider/core/netstandard.html |
|
Sorry, yes, meant resolution path. The three dlls have to be there also. |
Not sure where I'm going wrong. fsproj file <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<IsWindows Condition="'$(OS)' == 'Windows_NT'">true</IsWindows>
</PropertyGroup>
<PropertyGroup Condition="'$(MSBuildRuntimeType)' == 'Core'">
<IsOSX Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">true</IsOSX>
<IsLinux Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">true</IsLinux>
</PropertyGroup>
<PropertyGroup Condition="'$(IsWindows)' == 'true'">
<FscToolPath>C:\Program Files (x86)\Microsoft SDKs\F#\4.1\Framework\v4.0</FscToolPath>
<FscToolExe>fsc.exe</FscToolExe>
</PropertyGroup>
<PropertyGroup Condition="'$(IsOSX)' == 'true'">
<FscToolPath>/Library/Frameworks/Mono.framework/Versions/Current/Commands</FscToolPath>
<FscToolExe>fsharpc</FscToolExe>
</PropertyGroup>
<PropertyGroup Condition="'$(IsLinux)' == 'true'">
<FscToolPath>/usr/bin</FscToolPath>
<FscToolExe>fsharpc</FscToolExe>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="SQLProvider" Version="1.1.23" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="cp /home/disco/.nuget/packages/sqlprovider/1.1.23/lib/netstandard2.0/System.Data.SqlClient.dll bin/Debug/netcoreapp2.0/" Condition="'$(IsWindows)' != 'true'" />
</Target>
</Project> My referencePath contains the following
My Program.fs open System
open FSharp.Data.Sql
[<Literal>]
let connStr = @"Data Source=localhost; Initial Catalog=mvc; user id=disco; password=Password123!"
let resPath = @"/home/disco/Documents/code/sqlprovider/resPath"
type HR = SqlDataProvider<
Common.DatabaseProviderTypes.MSSQLSERVER,
connStr,
ResolutionPath = resPath>
[<EntryPoint>]
let main argv =
let runtimeConnectionString = connStr
let ctx = HR.GetDataContext runtimeConnectionString
0 // return an integer exit code dotnet build
Other information
Thanks for the help, I'm sure I'm just missing something simple. |
@Disco-Dave i think you're copying the dlls to the wrong place? You have a post build event to copy the System.Data.SqlClient.dll to
|
Npgsql.dll and those are just for PostgreSQL. Micorosft SQL Server shouldn't need those. The architecture for Postgres and Ms SQL is a bit different: As the compile-time uses Mono but runtime uses Core, you need a different version of System.Data.SqlClient.dll on runtime. That is why you have to add a nuget reference to Try to clone this repo and try to run the example project. It did work on my Ubuntu. |
I've read this issue and visited http://fsprojects.github.io/SQLProvider/core/netstandard.html and I'm finding it difficult to follow the instructions. |
Any ideas how to make them more clear? We have a lot of different environments. |
Don't know yet. I was investigating the use of https://github.com/fsprojects/SQLProvider/tree/master/tests/SqlProvider.Core.Tests/MsSql, by cloning the repo, adjusting the connection string, etc. But
honestly, I've read everything that I can everywhere and I have no idea what to do next. |
Here's the beginning of the script:
Oddly, I'm getting a very similar error with another, different project, and without the pre copy stuff. I'm not sure where that leaves me. Using Windows 10, net core 2.0.3. MySqlConnector on one and MySql.Data on the other. Whatever the problem is, it isn't related to either of those. |
@jchidley this is a known issue right now (fsprojects/FSharp.TypeProviders.SDK#177) try to target to netcodeapp2.0 only and not netstandard2.0. I'll try to figure out the problem when I have a bit spare time, but it seems that F# compiler throws stackoverflow exception, and setting up a debugging for that may take a while. |
Thanks. Your https://github.com/fsprojects/SQLProvider/tree/master/tests/SqlProvider.Core.Tests/MsSql test worked once I edited the from
to
As I discovered, simply editing out Now I have a working example, I'll try to get my own solution to work. |
My own solution works! This required a couple of minor adjustments to my
I copied the files from My program is now running on a Raspberry Pi 3/ubuntu. I tried to get it to run on a Pi 2/Arch but I kept getting exceptions. See below...
That problem with Arch will have to wait for another day. Thanks for you help @Thorium |
NET Standard compilation has to be done with .NET 4.51 library as Don pointed out in fsprojects/FSharp.TypeProviders.SDK#182 (comment) I updated the test projects accordingly: |
Hello :) I am trying to figure out how to set this up with Xamarin for mobile deployment, if it is even possible. I have read the .Net Standard setup guide and looked at the samples. I'm still getting my head around it but it looks like we need to copy the Sqlite implementation to a temp folder during the build so that we can set the resolution path later on in code. The thing with SqliteRaw is that it provides the appropriate Sqlite implementation at build time using bait and switch. I will need different versions of Sqlite depending on the mobile platform I am currently building, and they actually live in the mobile platform project. Am I just being too ambitious? Do I need some kind of conditionals in the fsproj? Just a clue as to whether I am totally wasting my time would be great! Thanks for your help |
@RyanBuzzInteractive are you using Xamarin on Windows or on non-Windows? I didn't get my SQLite + Ubuntu build combination ever work. The basic sqlite-library didn't support .NET Core. There is also this project Microsoft.Data.Sqlite.Core which could be used, but it didn't support non-core Mono. So there wasn't any common interface to work both compile & runtime. With Windows environment however I could get the build to work (and the result should execute on all, right?) with Microsoft.Data.Sqlite.Core. I just downloaded both files to a temp folder. |
I'm currently building on Windows. The thing is though that you need an iOS build of Sqlite to run on an iPhone, and Android build for Android etc etc. SqlitePCL.Raw.bundle_green switches out the version depending on the type of project that is referencing it when you build. I normally use sqlite-net in C# which handles all this under the surface, but I would like to use your SqlProvider in F# if I can. Apologies if I am missing something, I'm not very experienced with F#, editing proj files etc. |
These have all the info about the bait and switch thing |
Description
I'm getting a build error when compiling a simple dotnet core 2.0 project that has SQLProvider as a dependency. Problem seems similar to issue #460.
Repro steps
dotnet new console -lang f#
dotnet add package SQLProvider --version 1.1.18
dotnet restore
dotnet build
.fsproj
Expected behavior
Project compiles successfully.
Actual behavior
Project build error:
Known workarounds
Unknown
Related information
The text was updated successfully, but these errors were encountered: