Skip to content
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

Unable to Build Project with c# solution (Godot 4.1.1) #81790

Open
ArtemSin opened this issue Sep 17, 2023 · 16 comments
Open

Unable to Build Project with c# solution (Godot 4.1.1) #81790

ArtemSin opened this issue Sep 17, 2023 · 16 comments

Comments

@ArtemSin
Copy link

ArtemSin commented Sep 17, 2023

Godot version

4.1.1 Stable

System information

Windows 10 - Gotot 4.1.1 Stable

Issue description

Run Game failed if i have c# solution in project with these errors
editor/editor_node.cpp:6468 - An EditorPlugin build callback failed.
Transient parent has another exclusive child
If i delete csproj file it runs well , but cant rebuild ( it will regenerate csproj and have error again)
I'm using Rider with gotot plugin ,MSBuild dotnet 6

Steps to reproduce

Create Empty project
Create c# script
Create c# solution
Run it

Minimal reproduction project

Reproduction Project
Test5 copy.zip

@raulsntos
Copy link
Member

Deleting the csproj will make Godot think your project doesn't contain C# code and will not build it.

In the steps to reproduce, you mention creating the solution as one of the steps after creating a script. Godot should automatically create the solution if it doesn't exist when creating a C# script, did that not happen for you?

This error is likely to show up when your C# project does not compile, check the MSBuild panel to see if there were any errors building your project.

Please upload a minimal reproduction project to make this easier to troubleshoot.

@ArtemSin
Copy link
Author

@raulsntos yes, you right. If i create с#script - godot will make solution as well. In MSBuild panel there is one error- "The build method threw an exception." Actualy i dont have more info about that. There is reproduction project
Test5 copy.zip

@raulsntos
Copy link
Member

You should be able to right-click that error and copy it, it should contain the exception that was thrown. It could be that you don't have the dotnet CLI in the PATH environment variable, can you run the dotnet --info command in a console?

@ArtemSin
Copy link
Author

@raulsntos i tried to copy error but it didnt provide more info , only "The build method threw an exception." There is dotnet info comand's result
image

@ArtemSin
Copy link
Author

@raulsntos i see, 4 real environment variables not set, will try to fix this

@raulsntos
Copy link
Member

i tried to copy error but it didnt provide more info

That's weird, from what I can see that message should always include the exception in a new line:

BuildLaunchFailed?.Invoke(buildInfo,
$"The build method threw an exception.\n{e.GetType().FullName}: {e.Message}");
Console.Error.WriteLine(e);

Can you see the exception message if you hover the error? Also, since the exception is printed to the console, try opening Godot from a terminal and see the output there.

i see, 4 real environment variables not set, will try to fix this

It seems that you do have dotnet in the PATH, otherwise you wouldn't be able to execute the command, right?

@ArtemSin
Copy link
Author

ArtemSin commented Sep 17, 2023

@raulsntos i tried to launch with console too, but there's no second line . I checked and add again dotnet in the PATH ( maybe it already was), also i added DOTNET_ROOT variable too , but there's no effect . Also i asked my friend to share his dotnet --info screen and it looks like mine. Btw i can easily run console/unity projects , so i dont think there is an .net issue , also my friends who stared using Godot dont have such problem ,maybe i need some kind of extra win/godot setup?
image

@ArtemSin
Copy link
Author

@raulsntos in godot i changed verbosity level to detailed , so for now in console i see new exception
image

@raulsntos
Copy link
Member

It seems Godot can't find dotnet in your PATH environment variable. Try executing echo %PATH% in the terminal you are using to open Godot, it should contain the path to the directory that contains the dotnet executable.

@lukiiko
Copy link

lukiiko commented Sep 17, 2023

I'm experiencing the same issue on Ubuntu 22.04 and I just verified that dotnet is in my path. The issue still persists. Also I was building perfectly fine with a C# solution. I seem to have done something however which made it no longer work. Since I just started this project last night, it's very small (like 4 scenes and 3 scripts). If it helped, I could upload it.

@lukiiko
Copy link

lukiiko commented Sep 17, 2023

I have solved the issue on my end. I decided to run dotnet build in my project directory and it gave me a usable error message. It turns out I had a signal declared as private. After fixing that it builds normally again.

@ArtemSin
Copy link
Author

@raulsntos yeah, it contains . I have some dotnet instances in diffrent paths , and also in system and user variables for sure. I tried to remove from PATH some other instances and leave just one ( from user documents / program files ) , but there's no result. There is no a way to set the path directly in godot ?
image

image

@raulsntos
Copy link
Member

In 3.x there are multiple build tools, which one are you using? It should default to dotnet CLI, unless it can't find it.

In both 3.x and 4.x we use the same code to find dotnet in the PATH, so if 3.x is working I'm guessing it's not using the dotnet CLI as build tool. You check the value for this setting: Editor Settings > Mono > Builds > Build Tool.

Your PATH environment variable seems to contain the path to the dotnet CLI, so it should be able to find it. Can you also share the output of echo %PATHEXT%? These are the extensions that will be considered when looking for executables in PATH, I believe the default value should contain .EXE.

@ArtemSin
Copy link
Author

@raulsntos so , i was wrong about v3.5 , it can run c# code, but it also give me an error when i press Build button . Build tool is dotnet CLI
image

image
image

@ArtemSin
Copy link
Author

@raulsntos alright, i've found temporary solution from this topic ( about same problem on Mac) #38985
If i launch Godot from cmd , it works fine ,both 3.5 and 4.1 , so i can build project and run it without errors. It is wierd , but for now this is only solution for me

@cyraid
Copy link

cyraid commented Oct 8, 2023

I'm not sure if this will help anyone, but make sure in project.godot:

[dotnet]

project/assembly_name="NameOfSolution"

Make sure NameOfSolution.sln and NameOfSolution.csproj exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants