Skip to content

Setup VSCode Debugging

Valk edited this page Oct 13, 2024 · 1 revision

Setup Debugging

Create a launch.json with the following contents. Replace all program paths with the path to your Godot executable.

{
    "version": "0.2.0",
    "configurations": [
        // For these launch configurations to work, you need to setup a GODOT
        // environment variable. On mac or linux, this can be done by adding
        // the following to your .zshrc, .bashrc, or .bash_profile file:
        // export GODOT="/Applications/Godot.app/Contents/MacOS/Godot"
        {
            "name": "🕹 Debug Game",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            "program": "C:/Users/VALK-DESKTOP/Downloads/Godot_v4.3-stable_mono_win64/Godot_v4.3-stable_mono_win64.exe",
            "args": [],
            "cwd": "${workspaceFolder}",
            "stopAtEntry": false,
            "console": "integratedTerminal"
        },
        // Debug the scene that matches the name of the currently open *.cs file
        // (if there's a scene with the same name in the same directory).
        {
            "name": "🎭 Debug Current Scene",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            "program": "C:/Users/VALK-DESKTOP/Downloads/Godot_v4.3-stable_mono_win64/Godot_v4.3-stable_mono_win64.exe",
            "args": [
                "${fileDirname}/${fileBasenameNoExtension}.tscn"
            ],
            "cwd": "${workspaceFolder}",
            "stopAtEntry": false,
            "console": "integratedTerminal"
        },
        {
            "name": "🧪 Debug Tests",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            "program": "C:/Users/VALK-DESKTOP/Downloads/Godot_v4.3-stable_mono_win64/Godot_v4.3-stable_mono_win64.exe",
            "args": [
                // These command line flags are used by GoDotTest to run tests.
                "--run-tests",
                "--quit-on-finish"
            ],
            "cwd": "${workspaceFolder}",
            "stopAtEntry": false,
            "console": "integratedTerminal"
        },
        {
            "name": "🔬 Debug Current Test",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            "program": "C:/Users/VALK-DESKTOP/Downloads/Godot_v4.3-stable_mono_win64/Godot_v4.3-stable_mono_win64.exe",
            "args": [
                // These command line flags are used by GoDotTest to run tests.
                "--run-tests=${fileBasenameNoExtension}",
                "--quit-on-finish"
            ],
            "cwd": "${workspaceFolder}",
            "stopAtEntry": false,
            "console": "integratedTerminal"
        },
    ]
}

Create a tasks.json file with the following contents. Replace all program paths with the path to your Godot executable.

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "command": "dotnet",
            "type": "process",
            "args": [
                "build",
                "${workspaceFolder}/Template.csproj"
            ],
            "problemMatcher": "$msCompile",
            "presentation": {
                "echo": true,
                "reveal": "silent",
                "focus": false,
                "panel": "shared",
                "showReuseMessage": false,
                "clear": false
            }
        },
        {
            "label": "coverage",
            "group": "test",
            "command": "${workspaceFolder}/coverage.sh",
            "type": "shell",
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "presentation": {
                "echo": true,
                "reveal": "always",
                "focus": false,
                "panel": "shared",
                "showReuseMessage": false,
                "clear": true
            },
        },
        {
            "label": "build-solutions",
            "group": "test",
            "command": "dotnet restore; C:/Users/VALK-DESKTOP/Downloads/Godot_v4.3-stable_mono_win64/Godot_v4.3-stable_mono_win64.exe --headless --build-solutions --quit || exit 0",
            "type": "shell",
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "presentation": {
                "echo": true,
                "reveal": "silent",
                "focus": false,
                "panel": "shared",
                "showReuseMessage": false,
                "clear": false
            }
        },
    ]
}
Clone this wiki locally