godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.7k stars 20.12k forks source link

Godot w/Mono fails before reaching MSBuild call #26686

Open Cygon opened 5 years ago

Cygon commented 5 years ago

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:

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
neikeq commented 5 years ago

Can you try building #26713 and writing here the MSBuild command Godot is running? It should print the MSBuild command in addition to the output. You could also try running the same command and seeing if it works.

Cygon commented 5 years ago

Just tried it.

The command line for MSBuild is this

/usr/bin/msbuild "/home/cygon/.local/share/godot/mono/solutions/bignumber/GodotSharp.sln" /v:normal /t:Build "/p:Configuration=Release" "/l:GodotSharpTools.Build.GodotBuildLogger,/opt/godot-3.1-beta11-git-mono-2/bin/GodotSharp/Tools/GodotSharpTools.dll;/home/cygon/.local/share/godot/mono/build_logs/bignumber_Release" "/p:NoWarn=1591"

When I run the same command from shell, I get

Microsoft (R) Build Engine version 15.3.0.0 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

MSBUILD : Logger error MSB1029: The "GodotSharpTools.Build.GodotBuildLogger" logger could not be instantiated from the assembly "/opt/godot-3.1-beta11-git-mono-2/bin/GodotSharp/Tools/GodotSharpTools.dll". Please verify the logger assembly has been built using the same version of the Microsoft.Build.Framework assembly as the one installed on your computer and that your host application is not missing a binding redirect for Microsoft.Build.Framework. Specified cast is not valid.

I also tried removing the logger in BuildInstance::BuildArguments(), but even without the logger, MSBuild runs into the same error when launched from Godot:

Running: "/usr/bin/msbuild" "/home/cygon/.local/share/godot/mono/solutions/bignumber/GodotSharp.sln" /v:normal /t:Build "/p:Configuration=Release" "/p:NoWarn=1591"
;1RMSBUILD : error MSB1025: An internal failure occurred while running MSBuild.
System.IO.IOException: Invalid handle to path "/mnt/devel/GameDev/MonoTest/[Unknown]"
neikeq commented 5 years ago

Can you try running that command with /v:diagnostic instead of /v:normal and writing here the output?

BouncyLlama commented 5 years ago

I'm having the same issue as Cygon when trying to build using 3.1 beta 11 (edit: also with RC1) on Ubuntu. Running that first msbuild command by hand succeeds for me with a newer msbuild, however Build output:

/usr/bin/msbuild "./godotsandbox.sln" /v:normal /t:Build "/p:Configuration=Release" "/l:GodotSharpTools.Build.GodotBuildLogger,/home/potato/Downloads/Godot_v3.1-beta11_mono_x11_64/GodotSharp/Tools/GodotSharpTools.dll;./logfile" "/p:NoWarn=1591"
Microsoft (R) Build Engine version 16.0.0.0 for Mono
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 3/8/2019 6:18:59 PM.
Project "/home/potato/repos/godotsandbox/godotsandbox.sln" on node 1 (Build target(s)).
ValidateSolutionConfiguration:
  Building solution configuration "Release|Any CPU".
Project "/home/potato/repos/godotsandbox/godotsandbox.sln" (1) is building "/home/potato/repos/godotsandbox/godotsandbox.csproj" (2) on node 1 (default targets).
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
CoreCompile:
Skipping target "CoreCompile" because all output files are up-to-date with respect to the input files.
CopyFilesToOutputDirectory:
  godotsandbox -> /home/potato/repos/godotsandbox/.mono/temp/bin/Release/godotsandbox.dll
Done Building Project "/home/potato/repos/godotsandbox/godotsandbox.csproj" (default targets).
Done Building Project "/home/potato/repos/godotsandbox/godotsandbox.sln" (Build target(s)).

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:00.83
Cygon commented 5 years ago

I've tried with /v:diagnostic but it doesn't change much about the output:

"/usr/bin/msbuild" "/home/cygon/.local/share/godot/mono/solutions/1652704978954919024_7_1551979185/GodotSharp.sln" /v:diagnostic /t:Build "/p:Configuration=Release" "/p:NoWarn=1591"
WC: "/tmp"
;1RMSBUILD : error MSB1025: An internal failure occurred while running MSBuild.
System.IO.IOException: Invalid handle to path "/tmp/[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

I can find mentions of this error message with Mono on Linux in different scenarios, so maybe it's a generic Mono issue. I still don't see what's different between me invoking MSBuild by hand (or via JetBrains' Rider IDE) and Godot invoking it, though.

akien-mga commented 5 years ago

I'll move to 3.2 as it seems system-specific and quite unlikely to be fixed for 3.1 within a couple of days. If a fix is found after 3.1, it can be cherry-picked to the stable 3.1 branch and make it in a 3.1.x release.

akien-mga commented 4 years ago

@Cygon Is this issue still reproducible with latest 3.2 builds?

neikeq commented 4 years ago

This is either wrong with msbuild on that system or there's something wrong with our msbuild logger. If it's the latter, this can't be changed until 4.0, so I'll move it to that milestone.

rodrigofbm commented 4 years ago

The specified command could not be executed. The file or folder /home/rodrigot/.local/share/godot/mono/build_logs/42e063ca4a4306376d04af131f188009_Tools/msbuild_log.txt does not exists.

I'm facing it too... Godot 3.2 stable

KoBeWi commented 3 years ago

Can anyone still reproduce this bug in Godot 3.2.3 or any later release?

Calinou commented 2 years ago

Can anyone still reproduce this bug in Godot 3.2.3 or any later release?

This was reproduced in 3.4beta4 in https://github.com/godotengine/godot/issues/52780.

neikeq commented 2 years ago

Does this only happen when the selected build tool in the editor settings is MSBuild (Mono)? Can anyone reproduce this with the build tool set to dotnet CLI?

raulsntos commented 1 year ago

Moving to the 3.x milestone, since it seems the issue may only be reproducible using MSBuild (Mono) as the build tool which is only available in 3.x. In 4.0 the only supported build tool is dotnet CLI. If anyone is able to reproduce this issue with the build tool set to dotnet CLI in 3.x or 4.x, feel free to leave a comment.