简体   繁体   中英

Breakpoints are not hitting while debugging F# console application in VSCode using Mono Debug extension

I created a test console application and trying to debug it using VSCode and Mono Debug extension.

fsharp code :

module TestFharp

[<EntryPoint>]
let main argv =
    printfn "Args %A" argv
    let x = 5
    printf "hello world"
    0 

launch.json :

{
    "version": "0.2.0",
    "configurations": [

        {
            "name": "Launch",
            "type": "mono",
            "request": "launch",
            "program": "C:/FSharp/test/TestFharp/bin/Debug/TestFharp.exe",
            "args": [],
            "cwd": "${workspaceRoot}",
            "preLaunchTask": "",
            "runtimeExecutable": null,
            "env": {},
            "externalConsole": false,
            "stopOnEntry": true
        },
        {
            "name": "Attach",
            "type": "mono",
            "request": "attach",
            "address": "localhost",
            "port": 55555
        }
    ]
}

output of the DEBUG CONSOLE window

mono --debug --debugger-agent=transport=dt_socket,server=y,address=127.0.0.1:61724 C:/FSharp/test/TestFharp/bin/Debug/TestFharp.exe 
Args [||]
hello world
  • Do I need to make any other settings to hit the breakpoint?
  • What's the difference between exe file inside build folder and \\projectFolder\\bin\\Debug?

What's the difference between exe file inside build folder and \\projectFolder\\bin\\Debug

exe file in build directory is created by FAKE's build script ( build.fsx file) [invoked in Ionide with Ctrl + F5 / FAKE: Build default command]

exe in \\projectFolder\\bin\\Debug is standard MsBuild output. In Ionide you can invoke MsBuild directly using MsBuild: Build project command.

Both exe files are the same (FAKE is using MsBuild under the hood), it's just matter of preference and whether you want to run some additional operations on build (like testing) - FAKE allows you to define more complex build processes, MsBuild just compile app.

Depending on which method you use to build your app, you need to point at right exe in launch.json

I'd also set externalConsole to true .

Otherwise, it looks good, F5 should start your application and debugger.

The launch.json contains two configurations: one for launching the target (name: "Launch"), one for attaching to an already launched target (name: "Attach"). They are independent from each other.

In the "Launch" configuration no "port" is specified and mono-debug will use a random port when launching mono and will attach to that same port. So these ports are always in sync by definition.

In the "Attach" configuration a port is specified because mono-debug cannot know the debug port mono was started with.

So the launch configurations are both fine and the first one should be easier to use because it launches mono and attaches the debugger in one go.

If breakpoints are not hit, could it be that the TestFharp.exe was not build for debugging?

您指定的附加配置使用端口55555,但是您运行应用程序的方式为调试器指定了61724,因此请尝试将这两者同步

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM