Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you run an F# script file (.fsx) using .net core?

Tags:

.net-core

mono

f#

Is it possible to run .fsx files using .net core? (Equivalent to fsharpi on Mono.)

like image 469
Martimatix Avatar asked Mar 27 '17 11:03

Martimatix


3 Answers

It works out of the box in .NETCore v3.0 or newer:

$ cat hello.fsx
#!/usr/bin/env fsharpi
printfn "hello world"
$ dotnet fsi hello.fsx
hello world
$ dotnet --version
3.0.100

PS: Side-note: if you want to compile your scripts without having to run them, check this tool (only Linux/Mac compatible for now sorry, we accept PRs to add Windows support).

like image 196
knocte Avatar answered Oct 17 '22 11:10

knocte


I went looking for this answer and the best I could find matches your comment @Martimatix from March 28 however I did find issue 2407 in the visualfsharp repo which tracks the support for fsi on .NET Core 2.0.

Update (April 2009): It looks like there is now a preview version now for .NET Core available. https://devblogs.microsoft.com/dotnet/announcing-net-core-3-preview-3/

like image 6
jpierson Avatar answered Oct 17 '22 12:10

jpierson


They are working on it. This is the main issue, the same one posted by jpierson.

You can try right now with something like this:

dotnet /usr/share/dotnet/sdk/2.1.403/FSharp/fsi.exe test.fsx

It kinda / sorta works, but there are parts missing, especially full support for #r and interactive line editing (readline).

like image 4
Tobia Avatar answered Oct 17 '22 13:10

Tobia