(4.x .NET) Can't compile project on Windows after working on code on Linux

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By RayHammer

I’m working on a game with my friend, but when they pulled the game repository to their machine they can’t make the game work. I’ve been coding it on Linux, and they’re using Windows. They did manage to install .NET SDK 6.0 and the right version of Godot 4.x, but the errors they’re receiving are among the lines of:

start: Script does not inherit from Node: res://cs/Global.cs.
can_instantiate: Cannot instantiate script because the associated class could not be found. Script: 'res://cs/MainMenu.cs'. ...
emit_signalp: Error calling from signal 'pressed' to callable: 'Control(MainMenu.cs)::StartGame': Method not found.

I asked them to send the files he received, and all the methods and signals are still there, so I don’t know what can possibly be the problem apart from the compiler issues. I also migrated the project from 3.x not long ago, so maybe some metadata got corrupted in the process?

My first thought is an incorrect .net sdk: Download .NET (Linux, macOS, and Windows)

And that godot can’t find the appropriate version.

spaceyjase | 2023-03-17 16:27

How would one check if Godot is able to find an appropriate version? And if it’s not, how would one fix that issue?

RayHammer | 2023-03-17 20:07

The ms build tab in the editor may reveal some more information. I’m not sure what the mono framework does during install although the .net SDK linked previously should configure itself for system access; at least running ‘dotnet’ from a shell should indicate if an appropriate SDK is available, perhaps following a getting started guide to confirm the installation is working (outside of godot).

Using an IDE that’s familiar with dotnet may also help - I prefer to manage framework versions via Rider. Good luck!

spaceyjase | 2023-03-17 21:40

Thanks! Will keep you updated. Told them to run dotnet --version in command line, and checked mine just in case. Apparently I’m using 7.0.x, maybe they could try that one too

RayHammer | 2023-03-17 21:53

Well, looks like they had the right version, at least in the command line. Asked them to install .NET SDK 7.0 just in case, but it also did nothing apart from taking 3 more gigabytes of disk space

RayHammer | 2023-03-17 23:03

Then I’d at least make sure they have the mono version of godot installed! Check the version and that they can create csharp scripts in engine.

spaceyjase | 2023-03-18 06:33

.NET Tutorial | Hello World in 5 minutes
Just check if they can make hello word console app, cannot be more easier.
next check if they have same Godot Versions.
You and then can try get my repository for test godot 4.0 mono here
GitHub - Wanfanel/Godot-4.0-Test-project

Moreus | 2023-03-18 15:08

Is made on Windows

Moreus | 2023-03-18 15:09

:bust_in_silhouette: Reply From: RayHammer

The answer lies within the repo I shared with them. Apparently I put *.csproj in my .gitignore file, since I thought it’s only for the editor, and without this file the project does not compile. Issue solved