Skip to content

Commit

Permalink
Add more information about VS and VS Code debugging (#9222)
Browse files Browse the repository at this point in the history
* Added more information about VS and VS Code debugging

---------

Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>
(cherry picked from commit 25b8b8f)
  • Loading branch information
fyndor authored and mhilbrunner committed Jul 24, 2024
1 parent f994757 commit 2d4cd7f
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 5 deletions.
2 changes: 2 additions & 0 deletions getting_started/step_by_step/scripting_languages.rst
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ officially supported .NET option.
Android and iOS platform support is available as of Godot 4.2, but is
experimental and :ref:`some limitations apply <doc_c_sharp_platforms>`.

.. seealso:: To learn more about C#, head to the :ref:`C# basics <doc_c_sharp>` page.

C++ via GDExtension
~~~~~~~~~~~~~~~~~~~

Expand Down
64 changes: 59 additions & 5 deletions tutorials/scripting/c_sharp/c_sharp_basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -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
--------------------

Expand Down

0 comments on commit 2d4cd7f

Please sign in to comment.