godot-csharp-visualstudio icon indicating copy to clipboard operation
godot-csharp-visualstudio copied to clipboard

Is this Obsolete? VS2022 works with Godot 4.Beta1 no extension needed

Open jasonswearingen opened this issue 3 years ago • 8 comments

I was able to get VS2022 to Run+Debug (including hitting breakpoints and hot-reload) by following the steps outlined here: https://www.reddit.com/r/GodotCSharp/comments/xgpqfh/oc_rundebug_godot4_c_projects_from_visual_studio/

There are some pains, specifically no Console.WriteLine() support, and Godot errors are not shown unless Native Debugging is enabled. But otherwise it works, and pretty good.

jasonswearingen avatar Sep 17 '22 16:09 jasonswearingen

a wonky workaround to no Console output:

  • add arguments >out.log 2>&1 to the Launch Profile, which will redirect stdout and stderr to file.
  • then open the out.log in some tool that can auto-scroll to the last line. I use the VSCode extension "Log Viewer" which works great.

That works well enough that I can disable native mixed-mode debugging, which means Hot-Reload works (!!!)

jasonswearingen avatar Sep 17 '22 20:09 jasonswearingen

also on windows, stderr seems to buffer it's output, only writing when full. closing the app before then and the stderr is not output.

jasonswearingen avatar Sep 17 '22 21:09 jasonswearingen

Does the same console output issue exist when launching this way?:

As for Windows and Visual Studio, you must add the following to your csproj (or a Directory.Build.props):

  <PropertyGroup>
    <StartAction>Program</StartAction>
    <StartProgram>C:\Path\To\Godot.exe</StartProgram>
    <StartArguments>--path C:\Path\To\Godot\Project\</StartArguments>
  </PropertyGroup>

neikeq avatar Sep 18 '22 23:09 neikeq

Regarding the extension, it's only meant for Godot 3.x. Even for Godot 3.x the extension has not been working properly for a long time after switching to Sdk style projects. There are some workarounds for that, but don't expect a good experience.

For Godot 4.0, there are existing ways to debug the application that don't need an extension. Code completion providers will be moved to NuGet, so no extension will be needed for that either.

neikeq avatar Sep 18 '22 23:09 neikeq

Regarding the extension, it's only meant for Godot 3.x.

We definitely need this extension to work ALSO for Godot4

GeorgeS2019 avatar Dec 18 '22 09:12 GeorgeS2019

@neikeq I'm not sure where best to share this feedback, so if there's a better location, please let me know.

I see that there is a new Godot_v4.0-beta*_win64_console.exe in the releases. This works great for getting the console outputs, however this is a native exe. Is it possible to build that _console.exe as a mixed mode assembly?

I ask because when I launch+debug a godot project from visual studio using the Godot_v4.0-beta*_win64_console.exe as the startup executable, the debugger can not attach to the processes, because it's not a mixed-mode assembly so the vs managed debugger doesn't know how to attach to it. (To clarify, this is launching via visual studio, NOT via the godot editor).

Debugging works fine when running with the Godot_v4.0-beta*_win64.exe, but no console so print/writeline doesn't work with that.

jasonswearingen avatar Dec 18 '22 15:12 jasonswearingen

no console so print/writeline doesn't work with that

https://www.reddit.com/r/godot/comments/xhirp8/debugging_godot4_beta_projects_from_vs_and_vscode/ I haven't found a fix for the first issue, but I've shared a GD.cs to pipe GD.Print functions to the output window.

GeorgeS2019 avatar Mar 18 '23 09:03 GeorgeS2019

I haven't looked into setting up any sort of launch settings, but I was able to just attach to process for the running game from VS 2022 without any issue and hit my breakpoint for loading my scene. Was pretty easy.

Would just be nice though if hitting run from Godot automatically attached the debugger to the process if Visual Studio is open (and vice-versa but that direction involves the launch config).

hawkerm avatar Mar 28 '23 07:03 hawkerm