Reputation: 190919
I find some good post on F#/WPF programming, but it doesn't seem to teach a way to compile/build the code to make binary out of F#/WPF.
What command/tool do I use to build/compile this code into execution binary? Just running fsc
or fsi
doesn't seem to work.
#light
#I @"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0"
#r @"WindowsBase.dll"
#r @"PresentationCore.dll"
#r @"PresentationFramework.dll"
open System
open System.Windows
(* From Chap 1 - SayHello.cs *)
let win = new Window()
win.Title <- "Say Hello"
win.Show()
#if COMPILED
[<STAThread()>]
do
let app = new Application() in
app.Run() |> ignore
#endif
Upvotes: 1
Views: 385
Reputation: 243071
If you want to compile the code using fsc
then you'll need to remove the #I
and #r
commands and use a compiler command line arguments instead. The #light
command is not required anymore, so you can just delete first 5 lines. In addition to the #r
references, I also had to add System.Xaml.dll
(which is probably new in .NET 4)
Then you can compile it using something like:
fsc.exe -r:WindowsBase.dll -r:PresentationCore.dll -r:System.Xaml.dll
-r:PresentationFramework.dll --target:winexe Main.fs
Running the code in fsi.exe
should work just fine (after adding #r "System.Xaml.dll"
). Just copy the code and paste it to the F# Interactive (running either in console or in Visual Studio IDE).
Upvotes: 6
Reputation: 60041
Running fsc should work. You'll want to pass the --target:winexe command line argument to the fsc.exe.
See F# Compiler Options for more info.
Upvotes: 1