I'm trying to practice my F# by writing small console scripts in F# in place of my usual method of writing shell scripts/batch files. I currently run them using "fsi script.fsx [args]". Is there a way I can associate these fsx files with fsi so that I can run them directly like "script.fsx [args]"?
.net – Executing F# scripts
%fnet
Best Answer
Yes it is possible.
There are two keys here:
You need to bind an application to execute to the ".fsx" extension. The exact way to do this may vary a bit between operating system versions (I have only done this in the past by editing the registry directly, so I can't provide a generic solution here); make sure the command to be executed does include the script arguments (as
%*
), so the shell\open\command entry in the registry for the binding should look like"c:\Program Files\FSharp-1.9.9.9\bin\fsi.exe" "@%1" %*
See Gradbot's response for more details.