Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to keep fsi.exe open after running

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?

like image 253
Christoph Avatar asked Jul 06 '12 13:07

Christoph


2 Answers

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:

  • being admin open regedit and find the key HKEY_CLASSES_ROOT\VisualStudio.fsx.11.0\shell
  • add new subkey with some unique name, like 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.

like image 163
Gene Belitski Avatar answered Nov 13 '22 10:11

Gene Belitski


#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.

like image 44
Nikolay Avatar answered Nov 13 '22 11:11

Nikolay