Search code examples
windowsf#console-applicationvisual-studio-2019

How do I stop the console window from closing in Visual studio 2019?


I have had this problem for a while but I haven't used Visual studio in ages. But now I just want to solve this issue.

I'm following a F# course at school and i try to follow along with my teachers coding session. This is the code

module Program

open System

let incr = 
  fun x -> 
    x + 1 

[<EntryPoint>]
let main argv =
  let res = incr 5 
    printfn "My result is %d and I print a random number %d" res 5
    0

When I hit F5 or press start the window pops up real quick, no output is shown and it closes instantly. I was reading on other similar posts that you had to disable

tools>options>debugging>Automatically close the console when debugging stops

But it was already unchecked, then I read about that you have to set "subsystem to console" but I tried to look this up but I couldn't find anything about this that I could make sense off.

I'm just trying to do my homework and I really want to fix this problem so I can start using Visual studio again.


Solution

  • If possible, make the project type you create an F# .NET Core console app (which should be the first F# template in the New Project dialog). This uses a different system under the hood where the console window stays open and is re-used by subsequent runs.