godotengine/godot

Unable to Play or Debug C# Projects in Visual Studio 2019

cybereality opened this issue · 2 comments

Godot version

v3.4.stable.mono.official [206ba70]

System information

Windows 11

Issue description

When using Visual Studio 2019 to edit Godot 3.4 C# Mono projects, I am unable to "Play in Editor" or debug the game in any way. If I hit the play button in VS2019, an error message stating:

A project with an Output Type of Class Library cannot be started directly. In order to debug this project, add an executable project to this solution which references the library project. Set the executable project as the startup project.

Godot_C_Sharp_VS_Error

I did however find a work around to allow debugging of Godot C# projects in Visual Studio based on the instructions on this page:
https://gist.github.com/31/302bab2630ddf8d90ab4aec0d358b538

So this works, but it must be done for every new project you create and is a hassle. Hopefully there is some way to update the Visual Studio plugin to do this automatically, or update Godot to generate the solution files with this already applied.

Steps to reproduce

Download the Mono build of Godot 3.4 on Windows
Create a new project.
Add a C# script.
Click the script edit button.
Visual Studio 2019 will open.
Click play and see the error.

Minimal reproduction project

Sharp.zip

Seems like those instructions are for Godot 3.2 so it might be outdated, also this sounds like an issue with the Visual Studio extension and not Godot so it should be reported in the extension's repository: https://github.com/godotengine/godot-csharp-visualstudio

It seems this issue has already been reported in the extension repository:

Closing as duplicate of godotengine/godot-csharp-visualstudio#10 (as I just explained here).