Skip to content

Make it easier to run and debug the project entirely from VSCode #163

@G-Fuchter

Description

@G-Fuchter

I always disliked the idea of having to switch constantly between godot and vscode to be able to debug a project. Because of this slight annoyance, I took it upon myself of finding a way to be able to write my C# scripts from vscode and debug them with the touch of a single button. Without having to configure the "Wait for debugger" nor have to switch to the godot window to build it.

Thanks to this article I managed to create my simple task.json and settings.json in order to build and debug my C# project from VSCode. Would it be possible for the extension to create (or at least make it easier to create) the json files necessary in the project's folder?

Here are my JSON files:
launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Run",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            "program": "[insert path to godot executable here]",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "console": "internalConsole",
            "internalConsoleOptions": "openOnSessionStart"
        },
        {
            "name": "Attach",
            "type": "mono",
            "request": "attach",
            "address": "localhost",
            "port": "[insert port given by godot here]",
            "internalConsoleOptions": "neverOpen",
        }
    ],
    "compounds": [
        {
            "name": "Run and attach",
            "configurations": [
                "Attach",
                "Run",
            ]
        }
    ]
}

task.json

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "type": "shell",
            "command": "[Insert path to msbuild.exe or mono-build]",
            "args": [
                // Ask msbuild to generate full paths for file names.
                "/p:Configuration=Tools;Platform=Any CPU;GenerateFullPaths=true",
                "/t:Build;"
                // Do not generate summary otherwise it leads to duplicate errors in Problems panel
                //"/consoleloggerparameters:NoSummary"
            ],
            "group": "build",
            "presentation": {
                // Reveal the output only if unrecognized errors occur.
                "reveal": "silent"
            },
            // Use the standard MS compiler pattern to detect errors, warnings and infos
            "problemMatcher": "$msCompile"
        }
    ]
}

These json files should be inside the .vscode folder inside of the project's folder.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions