Add more information about VS and VS Code debugging (#9222)

* Added more information about VS and VS Code debugging

---------

Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>
This commit is contained in:
Greg Cobb
2024-04-15 04:57:27 -07:00
committed by GitHub
parent 08f4be3045
commit 25b8b8f20f
2 changed files with 61 additions and 5 deletions

View File

@@ -112,11 +112,52 @@ In Visual Studio Code:
for the C# tools plugin to work.
To configure a project for debugging, you need a ``tasks.json`` and ``launch.json`` file in
the ``.vscode`` folder with the necessary configuration. An example configuration can be
found `here <https://github.com/godotengine/godot-csharp-vscode/issues/43#issuecomment-1258321229>`__ .
In the ``launch.json`` file, make sure the ``program`` parameter in the relevant configuration points to your Godot executable, either by
changing it to the path of the executable or by defining a ``GODOT4`` environment variable that points to the
executable. Now, when you start the debugger in Visual Studio Code, your Godot project will run.
the ``.vscode`` folder with the necessary configuration.
Here is an example ``launch.json``:
.. code-block:: json
{
"version": "0.2.0",
"configurations": [
{
"name": "Play",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${env:GODOT4}",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
}
]
}
For this launch configuration to work, you need to either setup a GODOT4
environment variable that points to the Godot executable, or replace ``program``
parameter with the path to the Godot executable.
Here is an example ``tasks.json``:
.. code-block:: json
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build"
],
"problemMatcher": "$msCompile"
}
]
}
Now, when you start the debugger in Visual Studio Code, your Godot project will run.
Visual Studio (Windows only)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -143,6 +184,19 @@ In Godot's **Editor → Editor Settings** menu:
the ``NuGet.Config`` file. When you build your Godot project again,
the file will be automatically created with default values.
To debug your C# scripts using Visual Studio, open the .sln file that is generated
after opening the first C# script in the editor. In the **Debug** menu, go to the
**Debug Properties** menu item for your project. Click the **Create a new profile**
button and choose **Executable**. In the **Executable** field, browse to the path
of the C# version of the Godot editor, or type ``%GODOT4%`` if you have created an
environment variable for the Godot executable path. It must be the path to the main Godot
executable, not the 'console' version. For the **Working Directory**, type a single period,
``.``, meaning the current directory. Also check the **Enable native code debugging**
checkbox. You may now close this window, click downward arrow on the debug profile
dropdown, and select your new launch profile. Hit the green start button, and your
game will begin playing in debug mode.
Creating a C# script
--------------------