Hi I've made a simple program in f# and windows forms, how can I build the exe and then send it to friends for testing ? In the debug folder i found nothing.
It is possible to create an executable from an FSX file, but this scenario is not supported by Visual Studio out of the box. If you've reached this stage because you're using F# for the first time, and the difference between fsx and fs files was unclear I'd recommend turning your code into an .fs file and going from there.
If you have a reason to compile an fsx file (there are some!), then read on...
The F# compiler itself is perfectly happy to accept FSX files as source files, but you do need to play a few tricks.
Firstly, if you have any #load or #r lines in your script files, you will need to wrap them in a #if INTERACTIVE block.
Secondly, you must now manage feeding the compiler command line executable all of the relevant references and your code files in the correct order: remember that F# is an order dependent language.
You can find the compiler options on MSDN, although it's worth noting that if you're using the open source build of F# the compiler is called fsharpc rather than fsc as it is in the Visual Studio install.
So you're likely to end up running a command that looks something like this:
fsc.exe -r System.Xml --target:exe myProgram.exe MyScript.Things.fsx MyScript.fsx
I've been dealing with .fsx scripts so much, lately, for DevOps tasks, that I found myself in need of this, to:
So then I've decided to embark myself in automating what @mavnn explained in his answer.
It's so meta that my tool to compile scripts is a script itself (so it can compile itself and therefore not incur in performance impact if you want to use it for the sake of performance).
I'm working on this project in the open and I've published it here in GitLab. Contributions welcome.
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