Repository: godot
Issue: Godot w/Mono fails before reaching MSBuild call
Labels: bug,confirmed,topic:dotnet

**Godot version:** 3.1 Beta 11 (custom build from commit 2940475c716eab517ca52957acc8714f195d32cb)

**OS/device including version:** Gentoo Linux, Kernel 4.19.23, KDE 5, GTX 1080 w/NVidia proprietary drivers 415.27, Mono 5.18.0.240

**Issue description:**
On both my Linux and my Windows systems, I have (starting from Godot 3.0.0) so far not been able to make Godot w/Mono work - using both official releases and git builds.

My Linux environment is as follows:

`mono -V`
```
Mono JIT compiler version 5.18.0.240 (tarball Sat Feb 16 17:29:33 CET 2019)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           __thread
        SIGSEGV:       altstack
        Notifications: epoll
        Architecture:  amd64
        Disabled:      none
        Misc:          softdebug 
        Interpreter:   yes
        LLVM:          supported, not enabled.
        Suspend:       preemptive
        GC:            sgen (concurrent by default)
```

`xbuild /version`
```
XBuild Engine Version 14.0
Mono, Version 5.18.0.240
Copyright (C) 2005-2013 Various Mono authors
```

`msbuild /version`
```
Microsoft (R) Build Engine version 15.3.0.0 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
```

`nuget | grep -i version`
```
NuGet Version: 2.8.7.0
```

When I open a Mono project in Godot, I get a message box saying "Failed to build GodotSharp solution."

The "Builds" panel shows "GodotSharp [Release]" on the left side and nothing on the right side. Clicking "View log" causes a KDE message saying that the file or folder `/home/cygon/.local/share/godot/mono/build_logs/bignumber_Release/msbuild_log.txt` doesn't exist.

The is no `build_logs` directory, only a `mono_logs` directory. The files in `mono_logs` contain some details about Mono working, but no error messages or indications that it attempted to build anything.

Going into `/home/cygon/.local/share/godot/mono/solutions` (where the GodotSharp solution is stored) reveals two projects, `GodotSharp` and `GodotSharpEditor`. Both had no build artifacts (so likely no attempt to compile them was made by Godot), but they compile successfully if I invoke `msbuild` myself from the shell.

Setting `GODOT_DEBUG_MSBUILD=1` as recommended by @neikeq prints the following output into the console:

```MSBUILD : error MSB1025: An internal failure occurred while running MSBuild.
System.IO.IOException: Invalid handle to path "/mnt/devel/GameDev/MonoTest/[Unknown]"
  at System.IO.FileStream.ReadData (System.Runtime.InteropServices.SafeHandle safeHandle, System.Byte[] buf, System.Int32 offset, System.Int32 count) [0x0002d] in <88bf9a9916c3444d928dbbd1370328e5>:0 
  at System.IO.FileStream.ReadInternal (System.Byte[] dest, System.Int32 offset, System.Int32 count) [0x00026] in <88bf9a9916c3444d928dbbd1370328e5>:0 
  at System.IO.FileStream.Read (System.Byte[] array, System.Int32 offset, System.Int32 count) [0x000a1] in <88bf9a9916c3444d928dbbd1370328e5>:0 
  at System.IO.StreamReader.ReadBuffer () [0x000b3] in <88bf9a9916c3444d928dbbd1370328e5>:0 
  at System.IO.StreamReader.Read () [0x00021] in <88bf9a9916c3444d928dbbd1370328e5>:0 
  at System.TermInfoDriver.GetCursorPosition () [0x00048] in <88bf9a9916c3444d928dbbd1370328e5>:0 
  at System.TermInfoDriver.Init () [0x002dc] in <88bf9a9916c3444d928dbbd1370328e5>:0 
  at System.ConsoleDriver.Init () [0x00000] in <88bf9a9916c3444d928dbbd1370328e5>:0 
  at System.Console.add_CancelKeyPress (System.ConsoleCancelEventHandler value) [0x00007] in <88bf9a9916c3444d928dbbd1370328e5>:0 
  at Microsoft.Build.CommandLine.MSBuildApp.Execute (System.String[] commandLine) [0x00067] in <784c80f67d6847369ca02438ab3612f4>:0 

Unhandled Exception:
System.IO.IOException: Invalid handle to path "/mnt/devel/GameDev/MonoTest/[Unknown]"
  at System.IO.FileStream.ReadData (System.Runtime.InteropServices.SafeHandle safeHandle, System.Byte[] buf, System.Int32 offset, System.Int32 count) [0x0002d] in <88bf9a9916c3444d928dbbd1370328e5>:0 
  at System.IO.FileStream.ReadInternal (System.Byte[] dest, System.Int32 offset, System.Int32 count) [0x00026] in <88bf9a9916c3444d928dbbd1370328e5>:0 
  at System.IO.FileStream.Read (System.Byte[] array, System.Int32 offset, System.Int32 count) [0x000a1] in <88bf9a9916c3444d928dbbd1370328e5>:0 
  at System.IO.StreamReader.ReadBuffer () [0x000b3] in <88bf9a9916c3444d928dbbd1370328e5>:0 
  at System.IO.StreamReader.Read () [0x00021] in <88bf9a9916c3444d928dbbd1370328e5>:0 
  at System.TermInfoDriver.GetCursorPosition () [0x00048] in <88bf9a9916c3444d928dbbd1370328e5>:0 
  at System.TermInfoDriver.Init () [0x002dc] in <88bf9a9916c3444d928dbbd1370328e5>:0 
  at System.ConsoleDriver.Init () [0x00000] in <88bf9a9916c3444d928dbbd1370328e5>:0 
  at System.Console.add_CancelKeyPress (System.ConsoleCancelEventHandler value) [0x00007] in <88bf9a9916c3444d928dbbd1370328e5>:0 
  at Microsoft.Build.CommandLine.MSBuildApp.Execute (System.String[] commandLine) [0x003be] in <784c80f67d6847369ca02438ab3612f4>:0 
  at Microsoft.Build.CommandLine.MSBuildApp.Main (System.String[] args) [0x00029] in <784c80f67d6847369ca02438ab3612f4>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.IO.IOException: Invalid handle to path "/mnt/devel/GameDev/MonoTest/[Unknown]"
  at System.IO.FileStream.ReadData (System.Runtime.InteropServices.SafeHandle safeHandle, System.Byte[] buf, System.Int32 offset, System.Int32 count) [0x0002d] in <88bf9a9916c3444d928dbbd1370328e5>:0 
  at System.IO.FileStream.ReadInternal (System.Byte[] dest, System.Int32 offset, System.Int32 count) [0x00026] in <88bf9a9916c3444d928dbbd1370328e5>:0 
  at System.IO.FileStream.Read (System.Byte[] array, System.Int32 offset, System.Int32 count) [0x000a1] in <88bf9a9916c3444d928dbbd1370328e5>:0 
  at System.IO.StreamReader.ReadBuffer () [0x000b3] in <88bf9a9916c3444d928dbbd1370328e5>:0 
  at System.IO.StreamReader.Read () [0x00021] in <88bf9a9916c3444d928dbbd1370328e5>:0 
  at System.TermInfoDriver.GetCursorPosition () [0x00048] in <88bf9a9916c3444d928dbbd1370328e5>:0 
  at System.TermInfoDriver.Init () [0x002dc] in <88bf9a9916c3444d928dbbd1370328e5>:0 
  at System.ConsoleDriver.Init () [0x00000] in <88bf9a9916c3444d928dbbd1370328e5>:0 
  at System.Console.add_CancelKeyPress (System.ConsoleCancelEventHandler value) [0x00007] in <88bf9a9916c3444d928dbbd1370328e5>:0 
  at Microsoft.Build.CommandLine.MSBuildApp.Execute (System.String[] commandLine) [0x003be] in <784c80f67d6847369ca02438ab3612f4>:0 
  at Microsoft.Build.CommandLine.MSBuildApp.Main (System.String[] args) [0x00029] in <784c80f67d6847369ca02438ab3612f4>:0
```

**Steps to reproduce:**
1. Install a Gentoo Linux AMD64 system, Mono, MSBuild, NuGet
2. Run Godot on it
3. Create a Mono project