Setting up F# Debugging in VS Code on Linux

I’m new to .NET and F#, and I’m trying to set up F# debugging in VS Code on Linux (NixOS to be precise, although I guess that shouldn’t matter). The build prelaunch task works, but running the application doesn’t work, without any error output.

Here’s how to reproduce it.

In a directory called test, I create an F# console application by running dotnet new console -lang F#. This gives me a Program.fs with this content:

// Learn more about F# at http://docs.microsoft.com/dotnet/fsharp

open System

// Define a function to construct a message to print
let from whom =
sprintf "from %s" whom

[<EntryPoint>]
let main argv =
    let message = from "F#" // Call the function
    printfn "Hello world %s" message
    0 // return an integer exit code

and a test.fsproj with this content:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net5.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <Compile Include="Program.fs" />
  </ItemGroup>

</Project>

I create a (VS Code-specific) launch.json with the following content:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": ".NET Core Launch (console)",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            "program": "${workspaceFolder}/bin/Debug/net5.0/test.dll",
            "args": [],
            "cwd": "${workspaceFolder}",
            "stopAtEntry": true,
            "console": "internalConsole"
        }
    ]
}

and a (VS Code-specific) tasks.json with this content:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "command": "dotnet",
            "type": "shell",
            "args": [
                "build",
                // Ask dotnet build to generate full paths for file names.
                "/property:GenerateFullPaths=true",
                // Do not generate summary otherwise it leads to duplicate errors in Problems panel
                "/consoleloggerparameters:NoSummary"
            ],
            "group": "build",
            "presentation": {
                "reveal": "always"
            },
            "problemMatcher": "$msCompile"
        }
    ]
}

When I hit F5, it builds, but the application doesn’t seem to run. I don’t see the expected output Hello world from F#, neither in the Debug Console nor in the integrated terminal. Despite "stopAtEntry": true in the launch.json and setting breakpoints, it doesn’t stop anywhere, it just seems to run through without any output. The specified "program": "${workspaceFolder}/bin/Debug/net5.0/test.dll" exists, it is built in the prelaunch build. Actually, I can enter any non-sense path there and see just the same behavior (no error output).

What am I doing wrong?

Hello @coco

Hope you are doing well,

I can help you with your requirement add me over Skype :- noah_3861

Looking forward to your response.

Best
Noah

noah_cis is just trying to sell paid help.

.NET Foundation Website | Blog | Projects | Code of Conduct