I’ve just realised that I’ve never done this before.
Here’s what I did just now to debug a .NET Core console F# app - you should be able to adjust as necessary.
- In VS Code - I have the Ionide F# and the Microsoft C# extension.
- I’m using .NET Core 3.1 SDK.
To get started ran the following on the command line:
> cd AProject
> dotnet new console -lang f#
> code .
Once in VS Code I just pressed F5, and when prompted for an “Environment” I selected “.NET Core”
This opened me a launch.json like so:
// 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
At the bottom right of the editor I clicked “Add Configuration”:
and selected “.NET: Launch .NET Core Console App”
I then had to update the “program” to point to the framework and assembly name. In my case:
I then pressed F5 again and when prompted about a missing “build” task I clicked “Configure Task”:
Then I selected “Create tasks.json file from template”, then selected the “.NET Core” template.
Now when I press F5 it launches the app with the debugger attached:
As I said, at the start, I’d not done this before, usually I’m just writing scripts in F# and using the REPL to run them. Or I just use
dotnet run from the terminal, one of the things I like about F# and functional programming is that I spend a lot less time debugging code than I do with C#.