Introduction

After pull request #19201 attached debugging is now working on all supported platforms. The issues that had been stopping debugging on windows have been fixed and we can now set breakpoints, inspect variables, and step through code to our hearts content.

Currently this requires a recent build from master branch, or 3.0.3+.

1. Install VS Code extension:

  1. Click on the Extensions icon in the activities bar (left had side).
  2. Search for and install the Mono Debug extension.
  3. Close VS Code (some elements will appear only after restarting the application).
    mono-extension

2. Configure your project using the Godot Editor:

  1. Check Project Settings -> Mono -> Debugger Agent -> Wait for Debugger.
  2. While on the Debugger Agent page note the value specified for Port.
  3. Optionally change the Wait Timeout to a larger value (this will give you more time when performing step 4.3 below).
    project-settings

3. Configure your project using VS Code:

  1. Drop-down menu: Debug > Add Configuration > C# Mono.
  2. This will create and open your project’s launch.json file. Ensure the profile named Attach has the correct port from step 2.2 above.
  3. Click on the debug icon on the activities bar (left hand side) then select Attach from the configuration pull-down (top).
  4. If your project has been created by a Godot version before #18949 (this applies to all official releases before 3.0.3) then edit your project’s .csproj file so that all instances of <DebugType>full</DebugType> are changed to <DebugType>portable</DebugType>.
    mono-debugger

4. Start debugging:

  1. Apply a breakpoint to an interesting location using VS Code.
  2. Start your project using the Godot Editor.
  3. Switch to the VS Code application and “Start Debugging” either with the F5 key, the green play button on the debugger activity panel or the Debug drop-down menu.
    debugging-live

Conclusion

For subsequent debuging sessions on the same project you can simply repeat step 4, but for new projects you will have to start from step 2. To restore normal behaviour for your project you will need to toggle Wait for Debugger from 2.1 above.

Further Reading

You may also enjoy:

Tags: