You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Windows 10, VS 2022 Community, dotNet CLI and MSBuild (VS)
Issue description
I'm attempting to use project settings "Mono->Project->Solution Directory" and "Mono->Project->C# Project Directory" to get .sln and .csproj files to be created in, or used from, specified subdirectories, rather than the Godot project root (see this proposal and the pulls resolving it). In 4.0-beta4, these settings are relabeled Dotnet->Project->... and require the "Advanced Settings" toggle to be turned on.
On my machine (W10/VS2022/VS MSBuild or dotNet CLI), however, Godot 3.5.1 and 4.0-beta4 ignore these settings or encounter project-breaking bugs when they are used. This is both for initially creating the .sln and .csproj files, and when populating the settings and moving the .sln and .csproj files after initial creation. Failure modes include creating solution files in the wrong directory, re-creating solution files in the wrong directory, and build and/or runtime errors depending on version.
Steps to reproduce
To reproduce initial creation of the files in the wrong directory:
Create a new Godot project.
Create a subdirectory for the solution and a sub-subdirectory for the C# project.
Open Project Settings and edit the "Solution Directory" and "C# Project Directory" settings to indicate the subdirectories you created.
Create a basic scene and set it as the project's main scene. Attach a C# script and place it in the C# project sub-subdirectory.
Expected behavior: Godot will create .sln and .csproj files in the indicated subdirectories. Observed: Godot will create .sln and .csproj files in the project root directory, instead of the indicated subdirectories.
To reproduce re-creation of files in the wrong directory:
Follow steps above, populating the project settings for "Solution Directory" and "C# Project Directory" either before or after initial creation of the C# script.
Close Visual Studio if open.
Without closing Godot, move the .sln and .csproj files to the correct directories.
In Godot, press the "Build" button.
Expected behavior: Godot will read the .sln and .csproj files from the indicated directories. Observed: Godot creates new .sln and .csproj files in the project root. Additionally, there is an output message reading "scene/gui/popup_menu.cpp:1191 - Index p_idx = -1 is out of bounds (items.size() = 0)." (In 4.0-beta4, the indicated line number in popup_menu.cpp is 1723.)
To reproduce build errors after moving .sln and .csproj files:
Follow steps above to create a project, attach a C# script, and populate project settings for solution and C# project directories.
Close Visual Studio and Godot.
Move the .sln and .csproj files to the correct directories.
Reopen Godot, open the project, and press the "Build" button.
Expected behavior: Godot will read the .sln and .csproj files from the indicated directories. Observed: Godot fails to build the C# solution, apparently looking for the .csproj file in the same directory as the .sln file (possibly because the .sln file was created referring to a .csproj file in the same directory and has not been updated to reflect that they are in different directories?). The full error (in my 3.5.1 test project) reads:
C:\Users\Mark\Documents\Godot\DirectoriesBug6\src\DirectoriesBug6.sln" (Restore target) (1) ->
(_FilterRestoreGraphProjectInputItems target) ->
C:\Program Files\dotnet\sdk\6.0.402\NuGet.targets(369,5): error MSB3202: The project file "C:\Users\Mark\Documents\Godot\DirectoriesBug6\src\DirectoriesBug6.csproj" was not found. [C:\Users\Mark\Documents\Godot\DirectoriesBug6\src\DirectoriesBug6.sln]
To reproduce build/runtime errors after updating .sln file to point to correct .csproj location:
Note, this bug displays different behaviors in 3.5.1 and 4.0-beta4.
Follow steps above to create a project, attach a C# script, and populate project settings for solution and C# project directories.
Close Visual Studio and Godot.
Move the .sln and .csproj files to the correct directories.
Open the .sln file in Visual Studio. It will complain that the .csproj was not found. Remove the outdated reference to the .csproj and use "Add Existing Project" to add it back at its new location.
At this point, 3.5.1 and 4.0-beta4 diverge in their behavior. 3.5.1 continues to experience build errors, while 4.0-beta4 encounters a runtime error.
Expected behavior: Visual Studio and Godot build the solution from the correct location.
Observed, 3.5.1: At this point, Godot sees and reads the relocated .sln file, but neither Visual Studio nor Godot will build the project without errors. Visual Studio shows broken dependencies on the GodotSharp assemblies and throws build errors indicating "type or namespace not found" for Godot dependencies:
Godot will show the same errors:
Observed, 4.0-beta4: Visual Studio initially flags the GodotSharp packages as broken when the .csproj is added from its new location, but it corrects them and successfully builds the solution:
Godot also successfully builds the project. However, when the Godot project runs, although it does not crash, Godot's debugger displays the following error, and nothing in the script is executed (e.g., a GD.Print("Hello world"); in _Ready() does not produce output):
E 0:00:01:0793 can_instantiate: Cannot instance script because the associated class could not be found. Script: 'res://src/DirectoriesBug4-v4/Root.cs'.
<C++ Error> Method/function failed. Returning: false
<C++ Source> modules/mono/csharp_script.cpp:2288 @ can_instantiate()
Additional troubleshooting attempts/information for 3.5.1 after updating the .sln to point to the new location for the .csproj:
From Godot, using the "Clean Solution" option from the Build menu produces an error indicating that Godot is trying to read the node's script file from the project root, despite the node's properties correctly pointing to the C# file in the subdirectory. The same build errors as above persist on the next build attempt:
As a naive attempt with no real understanding of the internals, I'm able to get Visual Studio to build the solution by copying the .mono directory from the project root into the solution directory. However, this doesn't resolve build errors within Godot (output is identical to the post-clean errors showing incorrect script location, as in the previous bullet), so I'm guessing that folder copy can't actually function as a fix and there are other things that need to be adjusted.
Minimal reproduction project
"DirectoriesBug1" is a v3.5.1 project with the correct configuration to reproduce the bug in initial creation of sln and csproj files -- it has a basic main scene, subdirectories to contain the C# solution and project, and the settings to place the solution and project configured. Adding a C# script to the "Root" scene will cause the .sln and .csproj files to be populated in the project root; moving them and attempting to build while leaving Godot open will cause the files to be re-created at the project root.
"DirectoriesBug2" is the same, but after adding the C# script and moving the sln/csproj files to the correct locations, but without manually updating the sln to point to the csproj. The script, sln, and csproj files are in the correct locations with respect to the Godot project settings, but attempting to build in Godot will give the error that the csproj file is not found (looking in the sln directory).
"DirectoriesBug3" is the same, but with the .sln and .csproj files moved to the correct subdirectories and the .sln file updated with the new .csproj location. Godot 3.5.1 will see the .sln file in its new location but it will not build the project correctly, showing errors about missing Godot assemblies.
"DirectoriesBug3Beta" is the same as DirectoriesBug3, but for v4.0-beta4. It will build correctly in VS or Godot, but will show a runtime error in the debugger about instancing a script (see above in "Steps to reproduce"), and will not execute the print statement in the main scene's _Ready() method.
I did not notice any issues with leaving the solution file in the root and moving the csproj, other than the godot.project issue (#69045) I was fixing in #69047.
I take it from the change in #69391 now you can still move the solution but not the csproj? Which seems fairly pointless
Godot version
3.5.1.stable.mono.official, 4.0.beta4.mono.official
System information
Windows 10, VS 2022 Community, dotNet CLI and MSBuild (VS)
Issue description
I'm attempting to use project settings "Mono->Project->Solution Directory" and "Mono->Project->C# Project Directory" to get .sln and .csproj files to be created in, or used from, specified subdirectories, rather than the Godot project root (see this proposal and the pulls resolving it). In 4.0-beta4, these settings are relabeled Dotnet->Project->... and require the "Advanced Settings" toggle to be turned on.
On my machine (W10/VS2022/VS MSBuild or dotNet CLI), however, Godot 3.5.1 and 4.0-beta4 ignore these settings or encounter project-breaking bugs when they are used. This is both for initially creating the .sln and .csproj files, and when populating the settings and moving the .sln and .csproj files after initial creation. Failure modes include creating solution files in the wrong directory, re-creating solution files in the wrong directory, and build and/or runtime errors depending on version.
Steps to reproduce
To reproduce initial creation of the files in the wrong directory:
Expected behavior: Godot will create .sln and .csproj files in the indicated subdirectories.
Observed: Godot will create .sln and .csproj files in the project root directory, instead of the indicated subdirectories.
To reproduce re-creation of files in the wrong directory:
Expected behavior: Godot will read the .sln and .csproj files from the indicated directories.
Observed: Godot creates new .sln and .csproj files in the project root. Additionally, there is an output message reading "scene/gui/popup_menu.cpp:1191 - Index p_idx = -1 is out of bounds (items.size() = 0)." (In 4.0-beta4, the indicated line number in popup_menu.cpp is 1723.)
To reproduce build errors after moving .sln and .csproj files:
Expected behavior: Godot will read the .sln and .csproj files from the indicated directories.
Observed: Godot fails to build the C# solution, apparently looking for the .csproj file in the same directory as the .sln file (possibly because the .sln file was created referring to a .csproj file in the same directory and has not been updated to reflect that they are in different directories?). The full error (in my 3.5.1 test project) reads:
To reproduce build/runtime errors after updating .sln file to point to correct .csproj location:
Note, this bug displays different behaviors in 3.5.1 and 4.0-beta4.
At this point, 3.5.1 and 4.0-beta4 diverge in their behavior. 3.5.1 continues to experience build errors, while 4.0-beta4 encounters a runtime error.
Expected behavior: Visual Studio and Godot build the solution from the correct location.
Observed, 3.5.1: At this point, Godot sees and reads the relocated .sln file, but neither Visual Studio nor Godot will build the project without errors. Visual Studio shows broken dependencies on the GodotSharp assemblies and throws build errors indicating "type or namespace not found" for Godot dependencies:
Godot will show the same errors:
Observed, 4.0-beta4: Visual Studio initially flags the GodotSharp packages as broken when the .csproj is added from its new location, but it corrects them and successfully builds the solution:
Godot also successfully builds the project. However, when the Godot project runs, although it does not crash, Godot's debugger displays the following error, and nothing in the script is executed (e.g., a GD.Print("Hello world"); in _Ready() does not produce output):
Additional troubleshooting attempts/information for 3.5.1 after updating the .sln to point to the new location for the .csproj:
Minimal reproduction project
"DirectoriesBug1" is a v3.5.1 project with the correct configuration to reproduce the bug in initial creation of sln and csproj files -- it has a basic main scene, subdirectories to contain the C# solution and project, and the settings to place the solution and project configured. Adding a C# script to the "Root" scene will cause the .sln and .csproj files to be populated in the project root; moving them and attempting to build while leaving Godot open will cause the files to be re-created at the project root.
"DirectoriesBug2" is the same, but after adding the C# script and moving the sln/csproj files to the correct locations, but without manually updating the sln to point to the csproj. The script, sln, and csproj files are in the correct locations with respect to the Godot project settings, but attempting to build in Godot will give the error that the csproj file is not found (looking in the sln directory).
"DirectoriesBug3" is the same, but with the .sln and .csproj files moved to the correct subdirectories and the .sln file updated with the new .csproj location. Godot 3.5.1 will see the .sln file in its new location but it will not build the project correctly, showing errors about missing Godot assemblies.
"DirectoriesBug3Beta" is the same as DirectoriesBug3, but for v4.0-beta4. It will build correctly in VS or Godot, but will show a runtime error in the debugger about instancing a script (see above in "Steps to reproduce"), and will not execute the print statement in the main scene's _Ready() method.
DirectoriesBug1.zip
DirectoriesBug2.zip
DirectoriesBug3.zip
DirectoriesBug3Beta.zip
The text was updated successfully, but these errors were encountered: