Repository: godot
Issue: Detect when the .NET SDK is missing when compiling with Mono and abort early
Labels: enhancement,topic:buildsystem,topic:dotnet

### Godot version

3.3.3

### System information

Gentoo Linux amd64, Kernel 5.10.52-gentoo, Mono 6.12.0.122

### Issue description

Tried to build Godot Engine with Mono backend. But it failed with this:
```scons: Reading SConscript files ...
Enabling ALSA
Enabling PulseAudio
Enabling udev support
Checking for `thread_local` support... supported
Mono root directory not found. Using pkg-config instead
Checking for C header file mntent.h... (cached) yes
scons: done reading SConscript files.
scons: Building targets ...
[  0%] build_api_solution(["bin/GodotSharp/Api/Debug/GodotSharp.dll", "bin/GodotSharp/Api/Debug/GodotSharp.pdb", "bin/GodotSharp/Api/Debug/GodotSharp.xml", "bin/GodotSharp/Api/Debug/GodotSharpEditor.dll", "bin/GodotSharp/Api/Debug/GodotSharpEditor.pdb", "bin/GodotSharp/Api/Debug/GodotSharpEditor.xml"], [])
MSBuild path: /usr/bin/msbuild
[  1%] Microsoft (R) Build Engine version 15.9.20.62856 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

[  1%] Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
[  3%] Build started 28.08.2021 9:33:42.
[  5%] Project "/home/teashrock/Dev/Not-Mine/godot-3.3.3-stable/modules/mono/glue/GodotSharp/GodotSharp.sln" on node 1 (Restore target(s)).
[  5%] ValidateSolutionConfiguration:
  Building solution configuration "Debug|Any CPU".
[  6%] Project "/home/teashrock/Dev/Not-Mine/godot-3.3.3-stable/modules/mono/glue/GodotSharp/GodotSharp.sln" (1) is building "/home/teashrock/Dev/Not-Mine/godot-3.3.3-stable/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj" (2) on node 1 (Restore target(s)).
/home/teashrock/Dev/Not-Mine/godot-3.3.3-stable/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj : error MSB4057: The target "Restore" does not exist in the project.
Done Building Project "/home/teashrock/Dev/Not-Mine/godot-3.3.3-stable/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj" (Restore target(s)) -- FAILED.
Project "/home/teashrock/Dev/Not-Mine/godot-3.3.3-stable/modules/mono/glue/GodotSharp/GodotSharp.sln" (1) is building "/home/teashrock/Dev/Not-Mine/godot-3.3.3-stable/modules/mono/glue/GodotSharp/GodotSharpEditor/GodotSharpEditor.csproj" (3) on node 1 (Restore target(s)).
/home/teashrock/Dev/Not-Mine/godot-3.3.3-stable/modules/mono/glue/GodotSharp/GodotSharpEditor/GodotSharpEditor.csproj : error MSB4057: The target "Restore" does not exist in the project.
Done Building Project "/home/teashrock/Dev/Not-Mine/godot-3.3.3-stable/modules/mono/glue/GodotSharp/GodotSharpEditor/GodotSharpEditor.csproj" (Restore target(s)) -- FAILED.
Done Building Project "/home/teashrock/Dev/Not-Mine/godot-3.3.3-stable/modules/mono/glue/GodotSharp/GodotSharp.sln" (Restore target(s)) -- FAILED.
[  6%] 
Build FAILED.
[  6%] 
[  6%] "/home/teashrock/Dev/Not-Mine/godot-3.3.3-stable/modules/mono/glue/GodotSharp/GodotSharp.sln" (Restore target) (1) ->
"/home/teashrock/Dev/Not-Mine/godot-3.3.3-stable/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj" (Restore target) (2) ->
  /home/teashrock/Dev/Not-Mine/godot-3.3.3-stable/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj : error MSB4057: The target "Restore" does not exist in the project.


"/home/teashrock/Dev/Not-Mine/godot-3.3.3-stable/modules/mono/glue/GodotSharp/GodotSharp.sln" (Restore target) (1) ->
"/home/teashrock/Dev/Not-Mine/godot-3.3.3-stable/modules/mono/glue/GodotSharp/GodotSharpEditor/GodotSharpEditor.csproj" (Restore target) (3) ->
  /home/teashrock/Dev/Not-Mine/godot-3.3.3-stable/modules/mono/glue/GodotSharp/GodotSharpEditor/GodotSharpEditor.csproj : error MSB4057: The target "Restore" does not exist in the project.

    0 Warning(s)
    2 Error(s)
[  6%] 
Time Elapsed 00:00:00.62
[ 25%] Compiling ==> modules/mono/glue/collections_glue.cpp
[ 25%] Compiling ==> modules/mono/glue/gd_glue.cpp
[ 25%] Compiling ==> modules/mono/glue/mono_glue.gen.cpp
[ 25%] Compiling ==> modules/mono/glue/nodepath_glue.cpp
[ 25%] Compiling ==> modules/mono/glue/rid_glue.cpp
[ 25%] Compiling ==> modules/mono/glue/string_glue.cpp
[ 25%] Compiling ==> modules/mono/mono_gd/gd_mono.cpp
[ 25%] Compiling ==> modules/mono/mono_gd/gd_mono_assembly.cpp
scons: *** [bin/GodotSharp/Api/Debug/GodotSharp.dll] RuntimeError : 'msbuild' exited with error code: 1
Traceback (most recent call last):
  File "/home/teashrock/Dev/Not-Mine/godot-3.3.3-stable/modules/mono/build_scripts/solution_builder.py", line 106, in run_command
    subprocess.check_call(args, env=env_override)
  File "/usr/lib/python3.9/subprocess.py", line 373, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/usr/bin/msbuild', '/home/teashrock/Dev/Not-Mine/godot-3.3.3-stable/modules/mono/glue/GodotSharp/GodotSharp.sln', '/restore', '/t:Build', '/p:Configuration=Debug', '/p:NoWarn=1591']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/SCons/Action.py", line 1280, in execute
    result = self.execfunction(target=target, source=rsources, env=env)
  File "/home/teashrock/Dev/Not-Mine/godot-3.3.3-stable/modules/mono/build_scripts/api_solution_build.py", line 21, in build_api_solution
    build_solution(env, solution_path, build_config, extra_msbuild_args=extra_msbuild_args)
  File "/home/teashrock/Dev/Not-Mine/godot-3.3.3-stable/modules/mono/build_scripts/solution_builder.py", line 148, in build_solution
    run_command(msbuild_path, msbuild_args, env_override=msbuild_env, name="msbuild")
  File "/home/teashrock/Dev/Not-Mine/godot-3.3.3-stable/modules/mono/build_scripts/solution_builder.py", line 108, in run_command
    raise RuntimeError("'%s' exited with error code: %s" % (name, e.returncode))
RuntimeError: 'msbuild' exited with error code: 1
scons: building terminated because of errors.
teashrock@Cuaqmaijida ~/Dev/Not-Mine/godot-3.3.3-stable %
```

### Steps to reproduce

1. Get Gentoo Linux.
2. Emerge full version of Mono 6.12.0.122.
3. Compile Godot with Mono, but without glue.
4. Generate Mono glue.
5. Try to compile Godot with Mono and glue.
6. Get the error above.

### Minimal reproduction project

Not needed.