Setting up debugging in VSC

To enable the Desktop CLR debugger, change the configuration type in launch.json to be "clr" instead of "coreclr" and program should be pointing at the exe (NOT a .dll).

For unit tests, this can be done thusly:

  1. File->Preferences->Settings

  2. Open "CSharp: Unit Test Debugging Options"

  3. Set the 'type' to 'clr' (see settings.json example below)

settings.json example

{ ... "csharp.unitTestDebuggingOptions": { "type": "clr" } }

launch.json example

{ // 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 Launch (console)", "type":"coreclr", "request": "launch", "preLaunchTask": "my-prelaunch-task", "program": "${workspaceFolder}/bin/Debug/net5.0/<you-app-name>.exe", "args":[], "cwd": "${workspaceFolder}", "console": "internalConsole", "stopAtEntry": false, "internalConsoleOptions": "openOnSessionStart" } ] }

Notice at line 11 the name "my-prelaunch-task", this can be any name you like.

You will need to create another config file tasks.json, it should look like this

tasks.json example

{ // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format "version": "2.0.0", "tasks": [ { "label": "my-prelaunch-task", "command":"dotnet", "type":"shell", "args":[ "run", "-c Debug", "myfirstapp.csproj" ] } ] }

Notice line 7, it has the same name as that used in line 11 in launch.json,

More information about debugging desktop .NET Framework can be found here, https://stackoverflow.com/questions/47707095 .