Skip to content
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

Closed
danschultz opened this issue Oct 30, 2017 · 34 comments
Closed

SqlTypeProvider build error with dotnet core 2.0 #474

danschultz opened this issue Oct 30, 2017 · 34 comments

Comments

@danschultz
Copy link

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

  1. dotnet new console -lang f#
  2. dotnet add package SQLProvider --version 1.1.18
  3. dotnet restore
  4. dotnet build

.fsproj

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>
  <PropertyGroup>
    <IsWindows Condition="'$(OS)' == 'Windows_NT'">true</IsWindows>
    <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>/usr/local/bin</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.18" />
  </ItemGroup>
</Project>

Expected behavior

Project compiles successfully.

Actual behavior

Project build error:

$ dotnet build
Microsoft (R) Build Engine version 15.3.409.57025 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

error FS3053 : The type provider 'FSharp.Data.Sql.SqlTypeProvider' reported an error : The type provider constructor has thrown an exception: The method or operation is not implemented. [/Users/dan/Development/fsharp/sql-provider/sql-provider.fsproj]
FSC : warning FS3005: Referenced assembly '/Users/dan/.nuget/packages/sqlprovider/1.1.18/lib/netstandard2.0/FSharp.Data.SqlProvider.dll' has assembly level attribute 'Microsoft.FSharp.Core.CompilerServices.TypeProviderAssemblyAttribute' but no public type provider classes were found [/Users/dan/Development/fsharp/sql-provider/sql-provider.fsproj]

Build FAILED.

FSC : warning FS3005: Referenced assembly '/Users/dan/.nuget/packages/sqlprovider/1.1.18/lib/netstandard2.0/FSharp.Data.SqlProvider.dll' has assembly level attribute 'Microsoft.FSharp.Core.CompilerServices.TypeProviderAssemblyAttribute' but no public type provider classes were found [/Users/dan/Development/fsharp/sql-provider/sql-provider.fsproj]
error FS3053 : The type provider 'FSharp.Data.Sql.SqlTypeProvider' reported an error : The type provider constructor has thrown an exception: The method or operation is not implemented. [/Users/dan/Development/fsharp/sql-provider/sql-provider.fsproj]
    1 Warning(s)
    1 Error(s)

Known workarounds

Unknown

Related information

  • Used database: Postgres
  • Operating system: MacOS
  • .NET Runtime, CoreCLR or Mono Version:
$ dotnet --version
2.0.0

$ mono --version
Mono JIT compiler version 5.0.1.1 (2017-02/5077205 Wed May 31 14:47:04 BST 2017)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
	TLS:           normal
	SIGSEGV:       altstack
	Notification:  kqueue
	Architecture:  amd64
	Disabled:      none
	Misc:          softdebug 
	LLVM:          supported, not enabled.
	GC:            sgen (concurrent by default)
@Thorium
Copy link
Member

Thorium commented Oct 30, 2017

If you clone this repo, do you get the example project to compile?

@danschultz
Copy link
Author

I ran ./build.sh in the root of the repo and it built + tests passed successfully.

@Thorium
Copy link
Member

Thorium commented Nov 1, 2017

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.

@fredc0088
Copy link

Hi,
I'm experiencing the same issue, following the same procedure.

Here is my output:

C:\Program Files\dotnet\sdk\2.0.2\FSharp\Microsoft.FSharp.Targets(224,9): error MSB6006: "RunFsc.cmd" exited with code -1073741571. [C:\Users\federico.cocco\Documents\MyScrips\Applications_Tests_Metrics\CodeCoverage_Metrics\CodeCoverage_Metrics.fsproj]

Build FAILED.

C:\Program Files\dotnet\sdk\2.0.2\FSharp\Microsoft.FSharp.Targets(224,9): error MSB6006: "RunFsc.cmd" exited with code -1073741571. [C:\Users\federico.cocco\Documents\MyScrips\Applications_Tests_Metrics\CodeCoverage_Metrics\CodeCoverage_Metrics.fsproj]
0 Warning(s)
1 Error(s)

@dsyme
Copy link
Contributor

dsyme commented Nov 2, 2017

Every time you see this error it is because of this dotnet/fsharp#3303

Apply the workaround there

@danschultz
Copy link
Author

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.

@Thorium
Copy link
Member

Thorium commented Nov 2, 2017

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.

@fredc0088
Copy link

@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

@Sebosek
Copy link

Sebosek commented Nov 8, 2017

Just to be clear, I'm not able to use SQLProvider in .net core without full .net framework, am I right?

@Thorium
Copy link
Member

Thorium commented Nov 8, 2017

Maybe the documentation should be more clear...

  • You are able to use SQLProvider with .NET Core without full .NET framework on runtime.
  • You are able to compile a SQLProvider dependant project with only .NET Core on Windows.
  • You are NOT able to compile a SQLProvider dependant project without Mono on Mac/Linux.

@Dzoukr
Copy link

Dzoukr commented Nov 11, 2017

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?

@Thorium
Copy link
Member

Thorium commented Nov 11, 2017

As far as I know, the .netstandard2.0 and .netcoreapp2.0 should both work.

@Dzoukr
Copy link

Dzoukr commented Nov 12, 2017

Thanks for info, @Thorium. However, something strange is still happening because building .netcoreapp2.0 is ok, but switching to .netstandard2.0 I got error:

error FS3053 : The type provider 'FSharp.Data.Sql.SqlTypeProvider' reported an error : The type provider constructor has thrown an exception: Invalid host of cross-targeting type provider. Exception: System.NullReferenceException: Object reference not set to an instance of an object.

Should I create new issue for this?

@Thorium
Copy link
Member

Thorium commented Nov 12, 2017

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.

@Dzoukr
Copy link

Dzoukr commented Nov 14, 2017

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

@Disco-Dave
Copy link

@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.

@Thorium
Copy link
Member

Thorium commented Nov 24, 2017

  1. Are you using the latest version of SQLProvider?
  2. Do you have the reference dlls in the resolutionPath you specify in the constructor?
  3. Does your project file look quite like the examples?

More details: http://fsprojects.github.io/SQLProvider/core/netstandard.html

@Disco-Dave
Copy link

  1. I'm using 1.1.23
  2. I'm not actually sure what you mean by referencePath now? I searched the website I couldn't find an example of it. Do you mean resolution path? I want to use SQL Server on linux if that matters.
  3. Yes, I tried using a project that looks very similar to this https://github.com/fsprojects/SQLProvider/tree/master/tests/SqlProvider.Core.Tests/MsSql

@Thorium
Copy link
Member

Thorium commented Nov 25, 2017

Sorry, yes, meant resolution path. The three dlls have to be there also.

@Disco-Dave
Copy link

Disco-Dave commented Nov 25, 2017

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

total 744K
-rwxrw-rw- 1 disco wheel 646K Jul 25 13:33 �[0m�[00;32mNpgsql.dll�[0m
-rwxrw-rw- 1 disco wheel  68K Nov  5  2016 �[00;32mSystem.Data.Common.dll�[0m
-rwxrw-rw- 1 disco wheel  26K Nov  2 18:56 �[00;32mSystem.Threading.Tasks.Extensions.dll�[0m

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

Microsoft (R) Build Engine version 15.4.8.50001 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

error FS3053 : The type provider 'FSharp.Data.Sql.SqlTypeProvider' reported an error : The type provider constructor has thrown an exception: The method or operation is not implemented. [/home/disco/Documents/code/sqlprovider/Provider.fsproj]
FSC : warning FS3005: Referenced assembly '/home/disco/.nuget/packages/sqlprovider/1.1.23/lib/netstandard2.0/FSharp.Data.SqlProvider.dll' has assembly level attribute 'Microsoft.FSharp.Core.CompilerServices.TypeProviderAssemblyAttribute' but no public type provider classes were found [/home/disco/Documents/code/sqlprovider/Provider.fsproj]

Build FAILED.

FSC : warning FS3005: Referenced assembly '/home/disco/.nuget/packages/sqlprovider/1.1.23/lib/netstandard2.0/FSharp.Data.SqlProvider.dll' has assembly level attribute 'Microsoft.FSharp.Core.CompilerServices.TypeProviderAssemblyAttribute' but no public type provider classes were found [/home/disco/Documents/code/sqlprovider/Provider.fsproj]
error FS3053 : The type provider 'FSharp.Data.Sql.SqlTypeProvider' reported an error : The type provider constructor has thrown an exception: The method or operation is not implemented. [/home/disco/Documents/code/sqlprovider/Provider.fsproj]
    1 Warning(s)
    1 Error(s)

Time Elapsed 00:00:03.38

Other information

Linux disco-machine 4.13.12-1-ARCH #1 SMP PREEMPT Wed Nov 8 11:54:06 CET 2017 x86_64 GNU/Linux

dotnet core 2.0.2

Mono JIT compiler version 5.0.0 (Stable 5.0.0.100/9667aa6 Wed Jul 12 17:00:30 UTC 2017)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
	TLS:           __thread
	SIGSEGV:       altstack
	Notifications: epoll
	Architecture:  amd64
	Disabled:      none
	Misc:          softdebug 
	LLVM:          supported, not enabled.
	GC:            sgen (concurrent by default)

Microsoft (R) F# Compiler version 4.1
Copyright (c) Microsoft Corporation. All Rights Reserved.

Microsoft SQL Server 2017 (RTM-CU1) (KB4038634) - 14.0.3006.16 (X64) 
	Oct 19 2017 02:42:29 
	Copyright (C) 2017 Microsoft Corporation
	Developer Edition (64-bit) on Linux (Arch Linux)         

Thanks for the help, I'm sure I'm just missing something simple.

@chestercodes
Copy link

chestercodes commented Nov 27, 2017

@Disco-Dave i think you're copying the dlls to the wrong place?
They need to end up in the ResolutionPath directory which you're setting to @"/home/disco/Documents/code/sqlprovider/resPath"

You have a post build event to copy the System.Data.SqlClient.dll to bin/Debug/netcoreapp2.0/ but i think you want a pre build event to copy the dlls to @"/home/disco/Documents/code/sqlprovider/resPath"
Something like

<Exec Command="cp ~/.nuget/packages/system.buffers/4.4.0/lib/netstandard1.1/System.Buffers.dll /home/disco/Documents/code/sqlprovider/resPath " />
<Exec Command="cp ~/.nuget/packages/system.threading.tasks.extensions/4.4.0/lib/portable-net45+win8+wp8+wpa81/System.Threading.Tasks.Extensions.dll /home/disco/Documents/code/sqlprovider/resPath " />
<Exec Command="cp ~/.nuget/packages/system.runtime.interopservices.runtimeinformation/4.3.0/lib/net45/System.Runtime.InteropServices.RuntimeInformation.dll /home/disco/Documents/code/sqlprovider/resPath " />
<Exec Command="cp ~/.nuget/packages/system.data.common/4.3.0/lib/netstandard1.2/System.Data.Common.dll /home/disco/Documents/code/sqlprovider/resPath " />

@Thorium
Copy link
Member

Thorium commented Nov 27, 2017

Npgsql.dll and those are just for PostgreSQL. Micorosft SQL Server shouldn't need those.
For Postgres you need those resPath files to be present at compile time.

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 System.Data.SqlClient package and take the correct runtime dll from there as post-build task, not the one included in the SQLProvider-package.

Try to clone this repo and try to run the example project. It did work on my Ubuntu.

@jchidley
Copy link

jchidley commented Dec 9, 2017

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.

@Thorium
Copy link
Member

Thorium commented Dec 9, 2017

Any ideas how to make them more clear? We have a lot of different environments.

@jchidley
Copy link

jchidley commented Dec 9, 2017

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 dotnet build failed with these errors:

error FS3053 : The type provider 'FSharp.Data.Sql.SqlTypeProvider' reported an error : The type provider constructor has thrown an exception: Invalid host of cross-targeting type provider. Exception: System.NullReferenceException: Object reference not set to an instance of an object.�   at <StartupCode$FSharp-Data-SqlProvider>[email protected](IEnumerable`1& next)�   at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1.MoveNextImpl()�   at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1.System-Collections-IEnumerator-MoveNext()�   at Microsoft.FSharp.Collections.SeqModule.ToList[T](IEnumerable`1 source)�   at ProviderImplementation.ProvidedTypes.ProvidedTypesContext.Create(TypeProviderConfig cfg, FSharpOption`1 assemblyReplacementMap) [C:\Users\jackc\Documents\Git\SQLProvider\tests\SqlProvider.Core.Tests\MySql\SqlProvider.Core.Tests.fsproj]
FSC : warning FS3005: Referenced assembly 'C:\Users\jackc\.nuget\packages\sqlprovider\1.1.22\lib\netstandard2.0\FSharp.Data.SqlProvider.dll' has assembly level attribute 'Microsoft.FSharp.Core.CompilerServices.TypeProviderAssemblyAttribute' but no public type provider classes were found [C:\Users\jackc\Documents\Git\SQLProvider\tests\SqlProvider.Core.Tests\MySql\SqlProvider.Core.Tests.fsproj]
  SqlProvider.Core.Tests -> C:\Users\jackc\Documents\Git\SQLProvider\tests\SqlProvider.Core.Tests\MySql\bin\Debug\netcoreapp2.0\SqlProvider.Core.Tests.dll

Build FAILED.

FSC : warning FS3005: Referenced assembly 'C:\Users\jackc\.nuget\packages\sqlprovider\1.1.22\lib\netstandard2.0\FSharp.Data.SqlProvider.dll' has assembly level attribute 'Microsoft.FSharp.Core.CompilerServices.TypeProviderAssemblyAttribute' but no public type provider classes were found [C:\Users\jackc\Documents\Git\SQLProvider\tests\SqlProvider.Core.Tests\MySql\SqlProvider.Core.Tests.fsproj]
error FS3053 : The type provider 'FSharp.Data.Sql.SqlTypeProvider' reported an error : The type provider constructor has thrown an exception: Invalid host of cross-targeting type provider. Exception: System.NullReferenceException: Object reference not set to an instance of an object.�   at <StartupCode$FSharp-Data-SqlProvider>[email protected](IEnumerable`1& next)�   at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1.MoveNextImpl()�   at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1.System-Collections-IEnumerator-MoveNext()�   at Microsoft.FSharp.Collections.SeqModule.ToList[T](IEnumerable`1 source)�   at ProviderImplementation.ProvidedTypes.ProvidedTypesContext.Create(TypeProviderConfig cfg, FSharpOption`1 assemblyReplacementMap) [C:\Users\jackc\Documents\Git\SQLProvider\tests\SqlProvider.Core.Tests\MySql\SqlProvider.Core.Tests.fsproj]
    1 Warning(s)
    1 Error(s)

honestly, I've read everything that I can everywhere and I have no idea what to do next.

@jchidley
Copy link

jchidley commented Dec 9, 2017

Here's the beginning of the script:

C:\Users\jackc\Documents\Git\SQLProvider\tests\SqlProvider.Core.Tests\MySql>..\..\..\.paket\paket.bootstrapper.exe
Checking Paket version (downloading latest stable)...
Paket.exe 5.125.3 is up to date.

C:\Users\jackc\Documents\Git\SQLProvider\tests\SqlProvider.Core.Tests\MySql>..\..\..\.paket\paket.exe restore
Paket version 5.125.3
Performance:
 - Runtime: 1 second

C:\Users\jackc\Documents\Git\SQLProvider\tests\SqlProvider.Core.Tests\MySql>rd /s /q obj

C:\Users\jackc\Documents\Git\SQLProvider\tests\SqlProvider.Core.Tests\MySql>rd /s /q bin

C:\Users\jackc\Documents\Git\SQLProvider\tests\SqlProvider.Core.Tests\MySql>dotnet restore
  Restoring packages for C:\Users\jackc\Documents\Git\SQLProvider\tests\SqlProvider.Core.Tests\MySql\SqlProvider.Core.Tests.fsproj...
  Generating MSBuild file C:\Users\jackc\Documents\Git\SQLProvider\tests\SqlProvider.Core.Tests\MySql\obj\SqlProvider.Core.Tests.fsproj.nuget.g.props.
  Generating MSBuild file C:\Users\jackc\Documents\Git\SQLProvider\tests\SqlProvider.Core.Tests\MySql\obj\SqlProvider.Core.Tests.fsproj.nuget.g.targets.
  Restore completed in 2 sec for C:\Users\jackc\Documents\Git\SQLProvider\tests\SqlProvider.Core.Tests\MySql\SqlProvider.Core.Tests.fsproj.

C:\Users\jackc\Documents\Git\SQLProvider\tests\SqlProvider.Core.Tests\MySql>dotnet build
Microsoft (R) Build Engine version 15.4.8.50001 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  ..\..\..\packages\scripts\MySqlConnector\lib\netstandard2.0\MySqlConnector.dll
  1 File(s) copied
  ..\..\..\packages\standard\System.Buffers\lib\netstandard2.0\System.Buffers.dll
  1 File(s) copied
  ..\..\..\packages\standard\System.Threading.Tasks.Extensions\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll
  1 File(s) copied
  ..\..\..\packages\standard\System.Runtime.InteropServices.RuntimeInformation\lib\netstandard1.1\System.Runtime.InteropServices.RuntimeInformation.dll
  1 File(s) copied
  ..\..\..\packages\standard\System.Data.Common\lib\netstandard1.2\System.Data.Common.dll
  1 File(s) copied
  ..\..\..\packages\scripts\MySqlConnector\lib\netstandard2.0\MySqlConnector.dll
  1 File(s) copied
  ..\..\..\packages\standard\System.Buffers\lib\netstandard2.0\System.Buffers.dll
  1 File(s) copied
  ..\..\..\packages\standard\System.Threading.Tasks.Extensions\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll
  1 File(s) copied
  ..\..\..\packages\standard\System.Runtime.InteropServices.RuntimeInformation\lib\netstandard1.1\System.Runtime.InteropServices.RuntimeInformation.dll
  1 File(s) copied
  ..\..\..\packages\standard\System.Data.Common\lib\netstandard1.2\System.Data.Common.dll
  1 File(s) copied

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.

@Thorium
Copy link
Member

Thorium commented Dec 10, 2017

@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.

@jchidley
Copy link

jchidley commented Dec 10, 2017

Thanks. Your https://github.com/fsprojects/SQLProvider/tree/master/tests/SqlProvider.Core.Tests/MsSql test worked once I edited the SqlProvider.Core.Tests.fsproj file and changed:

from

    <!--TargetFramework>netcoreapp2.0</TargetFramework-->
    <TargetFrameworks>netcoreapp2.0;netstandard2.0</TargetFrameworks>

to

    <TargetFramework>netcoreapp2.0</TargetFramework>
    <!--TargetFrameworks>netcoreapp2.0;netstandard2.0</TargetFrameworks-->

As I discovered, simply editing out ;netstandard2.0 means you have to use --framework netcoreapp2.0 with dotnet run.

Now I have a working example, I'll try to get my own solution to work.

@jchidley
Copy link

My own solution works! This required a couple of minor adjustments to my Library.fsproj:

  <Import Project="../fsc.props" />

  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>

I copied the files from connectorTemp that had been generated when testing https://github.com/fsprojects/SQLProvider/tree/master/tests/SqlProvider.Core.Tests/MsSql to connectorTemp in my library, Library.

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...

Assert Failure
Expression: [Recursive resource lookup bug]
Description: Infinite recursion during resource lookup within System.Private.CoreLib.  This may be a bug in System.Private.CoreLib, or potentially in certain extensibility points such as assembly resolve events or CultureInfo names.  Resource name: ArgumentNull_Generic
[...etc]

That problem with Arch will have to wait for another day. Thanks for you help @Thorium

@Thorium Thorium closed this as completed Jan 12, 2018
@Thorium
Copy link
Member

Thorium commented Jan 12, 2018

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:
https://github.com/fsprojects/SQLProvider/tree/master/tests/SqlProvider.Core.Tests

@Ryan-Palmer
Copy link

Ryan-Palmer commented Feb 27, 2018

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

@Thorium
Copy link
Member

Thorium commented Feb 27, 2018

@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.

@Ryan-Palmer
Copy link

Ryan-Palmer commented Feb 27, 2018

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.

@Ryan-Palmer
Copy link

Ryan-Palmer commented Feb 27, 2018

These have all the info about the bait and switch thing
https://github.com/ericsink/SQLitePCL.raw
http://ericsink.com/entries/pcl_bait_and_switch.html
Could this library give you the common interface you need for cross platform .Net Standard support?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants