Given a simple F# console app:
[<EntryPoint>]
let main argv =
printfn "Hello world"
Console.ReadLine() |> ignore
0
What do I need to do to start the console app up in the same manner that ctrl F5 would do in Visual Studio. I have tried running it form a FAKE build script using the Fake.ProcessHelper:
Target "Run" (fun _ ->
let exe = @"C:\Source\code\fs_console_app\build\fs_console_app.exe"
let errorCode = Shell.AsyncExec(exe, "", buildDir)
()
)
Hitting Ctrl F5 I receive the following build report:
Target Duration
------ --------
Build 00:00:00.3916039
Run 00:00:00.0743197
Total: 00:00:00.5605493
Status: Ok
But no sign of the console application starting up and waiting for input.
I would have preferred to comment but it would be too long, I consider this more of a workaround answer, as I'm not that familiar with Fake. My guess is that your Run Target is actually being executed but is probably being swallowed by AsyncExec or it just shows in the Fake output window (try Exec) but doesn't start a new window.
You can just create a runcmd.bat (assuming you're on windows), and put the following into it, make sure the file is NOT in your build directory as it might get cleaned up:
start C:\Source\code\fs_console_app\build\fs_console_app.exe
You need start to kick off a new cmd window. This could be something else of course, bash or powershell, etc.
Then inside your build.fsx:
Target "Run" (fun _ ->
let exe = "path/to/runcmd.bat"
printfn "%A" "Hello World"
Shell.Exec(exe) |> ignore
)
// Build order
"Clean"
==> "Build"
==> "Run"
==> "Deploy"
Now if I run (via Ctrl+Shift+P) Fake, and pick Run, it compiles, starts a new command line and waits for the ReadLine. It also works via Ctrl+F5.
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