I have a bunch of F# scripts (fsx) that I use for my basic deployment needs. I just right click them and say "Run with F# interactive"
However, sometimes the script fails and I would like to keep the interactive console running. So far I haven't figured out a nice way to achieve that.
I tried starting up the fsi.exe manually but then how can I launch my script from there?
If you are hackish enough, you may want adding just another Explorer context menu item similar to Run with F# Interactive
, but keeping the console window open after .fsx
script terminates. Here is the working outline of how to achieve this for Windows7/VS2012:
regedit
and find the key HKEY_CLASSES_ROOT\VisualStudio.fsx.11.0\shell
openRunCmd
, make (Default)
value for this key whatever you like to see in context menu, maybe Run with Fsi in shell
finally, add subkey HKEY_CLASSES_ROOT\VisualStudio.fsx.11.0\shell\openRunCmd\command
and set (Default)
value for this subkey to the following line:
c:\windows\system32\cmd.exe /Q /K %%USERPROFILE%%\fsx.bat "%1"
Now, close regedit
, go to your home directory and create there a batch file fsx.bat
with the following line:
"C:\Program Files (x86)\Microsoft SDKs\F#\3.0\Framework\v4.0\Fsi.exe" --quiet --exec "%1"
After these mods you would be able to click on any .fsx
script with right mouse button, pick Run with Fsi in shell
and have the shell window staying after script termination until you close it. With few small adjustments the same approach would work for VS2010.
Just be careful to adjust details, if your system settings differ from ones above. Good luck!
Update: For those who want to try this at home or at work I've posted a detailed walk-through here.
#load "myScipt.fsx";;
should work I think. But myself i prefer just to have separate console window (cmd.exe), from which i can run fsi myScipt.fsx
and see the output.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With