-
-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for Godot 4 + mono #43
Comments
There are some changes in 4.0 that break the extension, so this issue is probably a duplicate of #38. But since for Godot 4.0 we plan to move to .NET 6.0 this will probably not be fixed. I have a draft PR #39 that should fix the extension to work with the current master that still uses Mono but as I said it won't be merged, so as a workaround you can compile the extension yourself using my branch and it should work. |
Do you think it would be feasible to finish this now that the Godot 4 beta has been released? |
@Seikho FWIW, I was able to use the microsoft / omnisharp c# extension fine for debugging, you just have to manually setup the config for it. |
Thanks @timshannon. Could you be able to provide an example of this for me? |
I always use attach personally, so that config is pretty straightforward:
For any other setup where you are launching godot yourself, you'll need to point at wherever you keep your Godot instance. |
Likewise, if you need to be able to debug immediately once the app starts, you can use the below {
"version": "0.2.0",
"configurations": [
// For these launch configurations to work, you need to setup a GODOT4
// environment variable. On mac or linux, this can be done by adding
// the following to your .zshrc, .bashrc, or .bash_profile file:
// export GODOT4="/Applications/Godot.app/Contents/MacOS/Godot"
{
"name": "Play",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${env:GODOT4}",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
}
]
} And the {
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build"
],
"problemMatcher": "$msCompile",
"presentation": {
"echo": true,
"reveal": "silent",
"focus": false,
"panel": "shared",
"showReuseMessage": true,
"clear": false
}
}
]
} If you need more, I keep the most up-to-date versions that I use for VSCode here. |
@timshannon You're not on Linux, right? Only the launch option worked for me on Linux. I couldn't get attach to work. |
@neikeq Yeah I'm on linux (Ubuntu Ubuntu 22.04.1 LT). Works fine for me. |
Thanks, @timshannon and @definitelyokay ! This works beautifully. Attach, Play and build all worked. |
Thank you so much! I just tested this on my Windows 11 laptop and it worked like a charm! Debugging on VSCode is working with this config! The only thing I did differently was I did not use an environment variable for Godot 4 in the "program" field but rather just pasted the full path of the Godot 4 beta 3 executable I downloaded. |
If I'm understanding correctly by using those configurations with coreclr mono is not needed on Linux anymore, correct? |
Since Microsoft's C# extension can be configured to launch and debug Godot 4 projects (above), will this extension be deprecated going into Godot 4? |
The extension is intended to also provide other auto-completions as well. I haven't had those working for a while. |
Generating launch and task configs would be handy though I found it pretty trivial to set them up manually. An attach launch config that automatically detects the appropriate process would be particularly convenient because currently you have to select the process manually when doing a coreclr attach. What autocomplete issues are you having? Using Godot 4 with the Microsoft/Omnisharp C# extension alone has been seamless for me so far. |
Specifically the node paths. I can't recall if I've had node path completion working in Godot 4 at all, but I haven't really expected it to since it's still in beta. |
Can anyone confirm if they have this working with the open vsx muhammad-sammy.csharp extension? When I run the launch task I get this error in the debug console:
The attach task does nothing. No output; no breakpoints. I thought it might be because the open vsx extension bundles netcoredbg rather than vsdbg, but probably I'm missing something. Weirdly, everything else is working. Omnisharp code completion is working. I can debug non-godot projects (i.e. regular dotnet console apps). I can play a project from the editor, and any GD.Print calls are shown in the editor output log, so it seems like godot has all the C# dependencies it needs. |
FWIW. rafaelgdp's solution worked for me. Just make sure you use the main godot exe and not the console version. Spent a couple of hours on this. This extension and the version in raulsntos fork do not compile anymore due to multiple issues with dependencies. |
The solution in this issue didn't work for me in vscodium and muhammad-sammy's extension (But my error was not the same as yours). So I tried installing VsCode and the official C# omnisharp extension and now it's working fine. |
I was able to do some more investigation today and found the root cause is indeed with netcoredbg. In short, it needs an enhancement to be able to detect dlls and pdbs that are loaded in memory. As others have mentioned, the workaround is to use the official C# vscode extension, or otherwise wait for a netcoredbg enhancement to be made. |
@rafaelgdp 's solution worked for me in current version of gd |
Works still with godot 4.1.2 stable. Just make sure the .vscode directory is in your game's directory and launch it with the standard .NET debugger. |
@definitelyokay You're a hero! Pasting those two files into my project Just Worked. That you so very much. I've been struggling for a few days to understand how to get debugging to work, and I've been despairing at the (possibly outdated) claims I've seen online that C# debugging or breakpoints aren't supported by Godot. Glad to find out those claims are not accurate at present. For others, I'm running Godot 4.1.1 stable mono version, on Windows 10, and Visual Studio Code version 1.82.2, with up-to-date versions of both the godot-tools and C# Tools for Godot plugins. I hardcoded the path to the Godot executable instead of using the environment variable, but otherwise I pasted the files without making other changes, and it worked like a charm. |
@GarrickWinter glad it helped! If you're looking for more on VSCode setup stuff, you might find some of this helpful. |
I've done this on 4.2.1 in VSCode but I'm getting an error: |
@shitwolfymakes .NET/Mono version of Godot should already generate a .csproj for you as soon as you create your first C# script from Godot Editor. |
After deleting, detaching, and re-adding the script, that worked! It appears that it didn't auto-generate because I hadn't configured VSCode as the external editor before adding the script. Thanks for the help! |
In case of anyone looking for C# workaround for debugging using Visual Studio Code based on this useful plugin, here is a basic boilerplate project: |
@M1N1M3 Hey, did you ever tried netcoredbg again? (the fix was introduced). |
OS/device including version:
Linux Manjaro KDE
Issue description:
I'm trying to use Vscode with Godot 4 + mono, but the options for C# doesnt appear as described in the README.MD
The text was updated successfully, but these errors were encountered: