SAFE-BookStore
SAFE-BookStore copied to clipboard
Cannot add a Nuget package to the Client
So, this example project compiles and runs for me. I decided to add FSharp.Data Nuget package to use type providers. And it does not work.
Let's say, I want to have in my Menu page this:
open FSharp.Data
type Wiki = HtmlProvider<"https://en.wikipedia.org/wiki/F_Sharp_(programming_language)">
First, I tried directly adding the package it via Nuget package manager. It installed, I got my intellisense, was nearly happy, ran build script in the powershell and got this sad error:
ERROR in ./views/Menu.fs
.../SAFE-BookStore/src/Client/views/Menu.fs(11,12): (11,24) error FSHARP: The type 'HtmlProvider' is not defined. Maybe you want one of the following:
HTMLNode
HtmlNode
@ ./Shared.fs 13:0-49 127:36-42
@ ./App.fs
@ ./Client.fsproj
@ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./Client.fsproj
Then I recalled that this project utilizes some fancy package manager Paket, so I read some docs, uninstalled the Nuget package and added it via Paket CLI as described here:
paket add FSharp.Data --version 2.4.6
It still throws the same stuff and now it is not recognized by Visual Studio as well.
What can I do? I do not want to parse html with regex...
Hi! So, there's two things. Firstly, yes, the bookstore project (and many F# repositories) use the Paket package manager. In addition to adding the project to the repository you would also need to add FSharp.Data to the .references file of the project. Note two things:
-
Type Providers are not 100% supported on .NET Core at the moment, and it requires (I believe) some manual workarounds at the moment to get things to work. There's work going on at the moment to fix this so that they work "normally" as for standard .NET projects.
-
It seems like you're trying to use the HTML type provider on the client project. Remember that the client project actually executes as javascript in the browser. I have no clue whether Fable (which converts F# into Javascript) even supports type providers - @alfonsogarciacaro can you comment on this? Is this possible and / or is this in the roadmap?
Cheers
Fsharp.data does not work as Javascript project
Isaac Abraham [email protected] schrieb am So., 1. Apr. 2018, 11:33:
Hi! So, there's two things. Firstly, yes, the bookstore project (and many F# repositories) use the Paket package manager. In addition to adding the project to the repository you would also need to add FSharp.Data to the .references file of the project. Note two things:
Type Providers are not 100% supported on .NET Core at the moment, and it requires (I believe) some manual workarounds at the moment to get things to work. There's work going on at the moment to fix this so that they work "normally" as for standard .NET projects. 2.
It seems like you're trying to use the HTML type provider on the client project. Remember that the client project actually executes as javascript in the browser. I have no clue whether Fable (which converts F# into Javascript) even supports type providers - @alfonsogarciacaro https://github.com/alfonsogarciacaro can you comment on this? Is this possible and / or is this in the roadmap?
Cheers
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/SAFE-Stack/SAFE-BookStore/issues/322#issuecomment-377774694, or mute the thread https://github.com/notifications/unsubscribe-auth/AADgNMpz52hB-FaXE45nNkgPlpwU-N34ks5tkJ7RgaJpZM4TCwm2 .
So, in this case you could try to get it working on the server side instead and expose the data over an API
@isaacabraham, @forki, Alright, thank you for responses.
Yes, I will give it a try server-side then.
Well even server-side it can be an issue since not all functions from fsharp.data are ported to dotnet core. This is WIP AFAIK and needs a lot of help. What are you trying to use exactly?
@isaacabraham, adding FSharp.Data to .references made the code compile, right. And still the code does not work - if I try to actually use FSharp.Data, I get e.g.
...\src\Server\WebServer.fs(16,16): error FS3033:
The type provider 'ProviderImplementation.HtmlProvider' reported an error in the context
of provided type 'FSharp.Data.HtmlProvider,Sample="https://en.wikipedia.org/..."', member 'Load'.
The error: Failed to bind type 'System.IO.TextReader'
in assembly 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'
Parameter name: tcName
@forki, well, not much, just HtmlProvider to parse some wikipedia. Eh, well, this is very sad. I do not need any .Net core features, I really only need basic F# stuff.
Guys, do you think it is reasonably possible to migrate the whole thing to .Net framework or will it be a such a PITA that I better go for creating some new plain F# service with jQuery on front-end and abandon SAFE?
@psfinaki I had the same problem just yesterday :). All you need to do is the fcs.props step from https://github.com/Microsoft/visualfsharp/issues/3303#issue-240393680 and make sure the compiler path is correct (you might need to change 4.1 to 10.1).
@psfinaki It's definitely possible to create a full .net framework app on SAFE. Type Providers are basically the only thing that don't "just work" on .NET Core yet. And they will soon :) I'd advise trying the fix above ad failing that, falling back to full framework.
@kerams, yeeeaaahh, you have saved me from despair, this worked :)
Thanks everybody for support. This can be probably closed now although maybe worth mentioning in the docs for further heroes.
Just today I saw that fsharp.data 3 is in beta and it comes with .NET core support.
Peter Semkin [email protected] schrieb am Do., 5. Apr. 2018, 08:26:
@kerams https://github.com/kerams, yeeeaaahh, you have saved me from despair, this worked :)
Thanks everybody for support. This can be probably closed now although maybe worth mentioning in the docs for further heroes.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/SAFE-Stack/SAFE-BookStore/issues/322#issuecomment-378844649, or mute the thread https://github.com/notifications/unsubscribe-auth/AADgNADQv5IbDEPwFtOktyHULB_rejXQks5tlcdBgaJpZM4TCwm2 .