The type provider 'FSharp.Data.SqlCommandProvider' reported an error: System.Data.SqlClient is not supported on this platform - f#

I'm trying to create a small F# script that will be using FSharp.Data.SqlClient or other SQL Type Prodiver. I also tried SQLProvider. I always get the following error :
The type provider 'FSharp.Data.SqlCommandProvider' reported an error: System.Data.SqlClient is not supported on this platform.
I'm using Visual Studio 2022 with .NET 6. I also tried with .NET 4.7.2.

The maintainer of the project gave me a fix for the issue : https://github.com/fsprojects/FSharp.Data.SqlClient/issues/423.
I had to force the evaluation of the System.Data.SqlClient nuget with ";;" :
#r "nuget: System.Data.SqlClient";;
at the beginning of the script.
#BentTranberg, the maintainer said he is evaluating the change to Microsoft.Data.SqlClient.

Related

F# Can't install nugets because doesn't find default nuget source

I'm trying to install some nuget packages using vs code in F# interactive (fsx script). It has worked before because I have successfully installed FSharp.Data, but it seems to not work (anymore).
Following error
No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages, nuget.org (vs code)
Code
open System.IO
open System
Environment.CurrentDirectory <- __SOURCE_DIRECTORY__
#r "nuget:System.Data.Linq.dll"
#r "nuget:FSharp.Data.SqlClient.dll"
A related issue says to list the nuget sources through commandline:
Visual Studio 2019 F# NU1101 Unable to find package FSharp.core
When I do this I get a correct response:
So what is going on here?
When You use nuget prefix in the #r directive, you don't have to add ".dll" extension at the end of package name. It is required only when you are referencing local dlls.
https://learn.microsoft.com/en-us/dotnet/fsharp/tools/fsharp-interactive/

Updated FSharp.Data and now getting an error on the build server

I have a FSharp project that uses FSharp.Data. I upgraded the project to point to .NET Framework 4.6.2 and use FSharp.Core 4.7.0. It works fine locally using VS2019 but when it runs on the build server, I am seeing this:
error FS3033(0,0): Error : The design-time type 'System.String'
utilized by a type provider was not found in the target reference
assembly set
Any ideas what is going on?

F# (mono) for VS Code on MacOS : bugs

I'm trying to use F# with VS Code (v1.17.2) on MacOS (Sierra 10.12.6)
I think i've installed latest versions of Mono and .NET SDK
I'm trying just to build the simple project described here as a test
https://github.com/s952163/FSharpVSCode
after my default installation, I could do a MSBuild and run the program in the terminal without any problem. However at that stage,
(1) Intellisense is not working properly, not recognizing Deedle
(2) in the F# explorer it would say
'TestProject1.fsproj (load failed)
when doing a right-click i got this error
Error: MSBuild failed with exitCode 1 Working Directory:
'/Users/francois-guillaume.rideau/Documents/FsharpVsCode/TestProject1'
Exe Path: 'dotnet' Args: 'msbuild
/Users/francois-guillaume.rideau/Documents/FsharpVsCode/TestProject1/TestProject1.fsproj
/p:SkipCompilerExecution=true /p:ProvideCommandLineArgs=true
/p:CopyBuildOutputToOutputDirectory=false
/p:UseCommonOutputDirectory=true /t:_Inspect_FscArgs
/p:_Inspect_FscArgs_OutFile=/var/folders/gm/z065gk616xg6g0xgn4c7_bvc0000gn/T/tmp52c377ed.tmp.FscArgs.txt
/p:DesignTimeBuild=true /t:_Inspect_GetResolvedProjectReferences
/p:_Inspect_GetResolvedProjectReferences_OutFile=/var/folders/gm/z065gk616xg6g0xgn4c7_bvc0000gn/T/tmpfe4a2c2.tmp.GetResolvedProjectReferences.txt
/t:_Inspect_GetProperties
/p:_Inspect_GetProperties_OutFile=/var/folders/gm/z065gk616xg6g0xgn4c7_bvc0000gn/T/tmpfe4a2c2.tmp.GetProperties.txt
/nologo /verbosity:quiet' Log: writing helper target file in
'/Users/francois-guillaume.rideau/Documents/FsharpVsCode/TestProject1/obj/TestProject1.fsproj.proj-info.targets'
/usr/local/share/dotnet/sdk/2.0.2/Microsoft.Common.CurrentVersion.targets(1122,5):
error MSB3644: The reference assemblies for framework
".NETFramework,Version=v4.6.1" were not found. To resolve this,
install the SDK or Targeting Pack for this framework version or
retarget your application to a version of the framework for which you
have the SDK or Targeting Pack installed. Note that assemblies will be
resolved from the Global Assembly Cache (GAC) and will be used in
place of reference assemblies. Therefore your assembly may not be
correctly targeted for the framework you intend.
[/Users/francois-guillaume.rideau/Documents/FsharpVsCode/TestProject1/TestProject1.fsproj]
to try to solve this, i typed in the following
export FrameworkPathOverride=/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5/
but worse, after that, the project doesn't build anymore in VS Code as I get this output when trying (Cmd-Shift-P) MSBuild: Build Project
/usr/local/share/dotnet/sdk/2.0.2/Microsoft.Common.CurrentVersion.targets(1122,5): error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.6.1" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. [/Users/francois-guillaume.rideau/Documents/FsharpVsCode/TestProject1/TestProject1.fsproj]
screenshot here https://imgur.com/KtMM2Bu
VS Code environment is passed to msbuild when it invokes it, so setting environment variables on startup of VS Code does the trick:
FrameworkPathOverride=/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5/ code .
Go to project location in the terminal and then run FrameworkPathOverride=/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5/ code . as said before.
Then you should be able to build again.

One F# 4.1 compiler includes targetPlatform value of netstandard, the other does not

The F# 4.1 compiler on my build machine has slightly different --targetProfile options than the F# 4.1 compiler on my dev machine.
On my dev machine, when I type fsc.exe -? the output includes the following:
Microsoft (R) F# Compiler version 4.1
:
--targetprofile:<string>
Specify target framework profile of this assembly.
Valid values are mscorlib, netcore or netstandard.
:
On my build server, the same command outputs the following:
Microsoft (R) F# Compiler version 4.1
:
--targetprofile:<string>
Specify target framework profile of this assembly.
Valid values are mscorlib or netcore.
:
Notice that the dev machine includes netstandard as a valid value, but the build server does not.
Consequently, when I try to build my project on the build server, I get a compile time error of "error FS1052: Invalid value 'netstandard' for '--targetprofile'"
What is going on? Is there a way to display the real version number of an F# 4.1 compiler? fsc.exe --version does not work.
I don't think this is to do with the F# compiler version but rather the .NET SDK(s) installed.
Check the target framework TFMs.
I have mscorlib, netcore or netstandard and I will take a stab at where they come from:
mscorlib from full framework...comes with Windows
netcore installed with VS 2017 when selecting ".NET desktop development"
netstandard installed with NET Core SDK
If this is the case I would imagine installing .NET Core SDK on the build server would sort it out since you seem to be targeting netstandard.

F# Cannot find DLL

I am currently learning F# and working through the samples on tryfsharp.org. I am using the Mono F# on a Mac.The script begins as follows:
#r "MathNet.Numerics.dll"
open MathNet.Numerics
open System.Numerics
When starting the script I get the following error message:
/Users/benjamin/Desktop/Kalman/kalman.fsx(1,1): error FS0078: Unable to find the file '
MathNet.Numerics.dll' in any of
/Library/Frameworks/Mono.framework/Versions/3.0.12/lib/mono/4.5
/Users/benjamin/Desktop/Kalman
/Library/Frameworks/Mono.framework/Versions/3.0.12/lib/m
I do not know, where to find that DLL or how to install it.
You should just be able to use nuget to get that library.
http://nuget.org/packages/MathNet.Numerics
See here to install nuget:
http://docs.nuget.org/docs/start-here/nuget-faq

Resources