godotengine / godot

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

Mono Build fails with "Missing required property 'OutputPath' for project type 'PackageReference'." #39600

Open madmiraal opened 4 years ago

madmiraal commented 4 years ago

Godot version: v3.2.2.rc1.mono.official

OS/device including version: Windows 10

Issue description: Cannot build any Mono Project with MSBuild (Mono). Projects build without a problem using MSBuild (VS Build Tools).

Steps to reproduce:

Minimal reproduction project: Test Mono RC1.zip

Console Output:

Godot Engine v3.2.2.rc1.mono.official - https://godotengine.org
OpenGL ES 3.0 Renderer: Intel(R) HD Graphics 4600

Mono: Logfile is: C:\Users\Marcel\AppData\Roaming/Godot/mono/mono_logs/2020_06_16 17.16.11 (15180).txt
Editing project: C:/Users/Marcel/Downloads/Godot/Test Mono RC1 (C:::Users::Marcel::Downloads::Godot::Test Mono RC1)
Godot Engine v3.2.2.rc1.mono.official - https://godotengine.org
OpenGL ES 3.0 Renderer: Intel(R) HD Graphics 4600

Mono: Logfile is: C:\Users\Marcel\AppData\Roaming/Godot/mono/mono_logs/2020_06_16 17.16.14 (8508).txt
Running: "C:\Program Files\Mono\bin\msbuild.bat" "C:/Users/Marcel/Downloads/Godot/Test Mono RC1/Test Mono RC1.sln" /v:normal /t:Restore,Build "/p:Configuration=Debug" "/l:GodotTools.BuildLogger.GodotBuildLogger,C:\Users\Marcel\Downloads\Godot\Godot_v3.2.2-rc1_mono_win64\GodotSharp\Tools\GodotTools.BuildLogger.dll;C:\Users\Marcel\AppData\Roaming/Godot/mono/build_logs\adeb49de002905ec5b4f1c77aaf06cf7_Debug" /p:GodotDefineConstants=\"GODOT_WINDOWS;GODOT_64;\"
Microsoft (R) Build Engine version 16.5.0-ci for Mono
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 16/06/2020 17:16:20.
Project "C:\Users\Marcel\Downloads\Godot\Test Mono RC1\Test Mono RC1.sln" on node 1 (Restore;Build target(s)).
ValidateSolutionConfiguration:
  Building solution configuration "Debug|Any CPU".
ERROR: call_build: An EditorPlugin build callback failed.
   At: editor/editor_node.cpp:5276

Build Log:

Project "Test Mono RC1.sln" (Restore;Build target(s)):
    Message: Building solution configuration "Debug|Any CPU".
    Project "Test Mono RC1.csproj" (Restore target(s)):
        Project "Test Mono RC1.csproj" (_IsProjectRestoreSupported target(s)):
        Done building project "Test Mono RC1.csproj".
        Project "Test Mono RC1.csproj" (_GenerateRestoreProjectPathWalk target(s)):
        Done building project "Test Mono RC1.csproj".
        Project "Test Mono RC1.csproj" (_IsProjectRestoreSupported target(s)):
        Done building project "Test Mono RC1.csproj".
        Project "Test Mono RC1.csproj" (_GenerateRestoreGraphProjectEntry target(s)):
        Done building project "Test Mono RC1.csproj".
        Project "Test Mono RC1.csproj" (_GenerateProjectRestoreGraph target(s)):
        Done building project "Test Mono RC1.csproj".
        C:\Program Files\Mono\lib\mono\msbuild\15.0\bin\NuGet.targets(124,5): error : Invalid restore input. Missing required property 'OutputPath' for project type 'PackageReference'. Input files: C:\Users\Marcel\Downloads\Godot\Test Mono RC1\Test Mono RC1.csproj. [C:\Users\Marcel\Downloads\Godot\Test Mono RC1\Test Mono RC1.csproj]

Possibly related to #36361.

madmiraal commented 4 years ago

I've removed the regression label, because #36361 means projects don't build in v3.2.1 using MSBuild (Mono) either.

neikeq commented 4 years ago

We discourage using MSBuild (Mono) for building projects on Windows. There are many issues with it. It's better to use MSBuild (VS Build Tools). With Godot 3.2.2 we also introduced the option to use the dotnet CLI.

That being said, let's try to determine if this is an issue with Godot or Mono's MSBuild. I'll test this when I have some time, but I'm quite busy with other tasks so I don't know when that will be possible. If you have time, these are the steps I would follow:

  1. check if you can build the project manually with MSBuild from the Mono Command Prompt, using the same arguments Godot passes to MSBuild (you can get those from the Godot std output, may need running Godot with --verbose).
  2. Check if you can build the project manually with MSBuild from the Mono Command Prompt, with basic options msbuild Path/To/Solution.sln.
  3. Check if you can build a normal C# project (not a Godot C# project) with MSBuild from the Mono Command Prompt.
madmiraal commented 4 years ago
  1. From a PowerShell I ran: & "C:\Program Files\Mono\bin\msbuild.bat" "C:/Users/Marcel/Downloads/Godot/Test Mono RC1/Test Mono RC1.sln" /v:normal /t:Restore,Build "/p:Configuration=Debug" "/l:GodotTools.BuildLogger.GodotBuildLogger,C:\Users\Marcel\Downloads\Godot\Godot_v3.2.2-rc1_mono_win64\GodotSharp\Tools\GodotTools.BuildLogger.dll;C:\Users\Marcel\AppData\Roaming/Godot/mono/build_logs\adeb49de002905ec5b4f1c77aaf06cf7_Debug" /p:GodotDefineConstants=\"GODOT_WINDOWS;GODOT_64;\"

Which produced the following output:

Microsoft (R) Build Engine version 16.5.0-ci for Mono
Copyright (C) Microsoft Corporation. All rights reserved.

MSBUILD : error MSB1006: Property is not valid.
Switch: GODOT_64

For switch syntax, type "MSBuild -help"
  1. From a PowerShell I ran: & "C:\Program Files\Mono\bin\msbuild.bat" "C:/Users/Marcel/Downloads/Godot/Test Mono RC1/Test Mono RC1.sln"

Which produced the following output:

Microsoft (R) Build Engine version 16.5.0-ci for Mono
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 17/06/2020 14:07:56.
Project "C:\Users\Marcel\Downloads\Godot\Test Mono RC1\Test Mono RC1.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
  Building solution configuration "Debug|Any CPU".
Project "C:\Users\Marcel\Downloads\Godot\Test Mono RC1\Test Mono RC1.sln" (1) is building "C:\Users\Marcel\Downloads\Go
dot\Test Mono RC1\Test Mono RC1.csproj" (2) on node 1 (default targets).
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the i
nput files.
CoreCompile:
  C:\Program Files\Mono\lib\mono\msbuild\15.0\bin\Roslyn\csc.exe /noconfig /nowarn:1701,1702 /nostdlib+ /errorreport:pr
  ompt /warn:4 /define:GODOT;DEBUG;TOOLS /highentropyva+ /reference:"C:\Users\Marcel\Downloads\Godot\Test Mono RC1\.mon
  o\assemblies\Debug\GodotSharp.dll" /reference:"C:\Users\Marcel\Downloads\Godot\Test Mono RC1\.mono\assemblies\Debug\G
  odotSharpEditor.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7\m
  scorlib.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7\System.Co
  re.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7\System.dll" /d
  ebug+ /debug:portable /optimize- /out:".mono\temp\obj\Debug\Test Mono RC1.dll" /subsystemversion:6.00 /target:library
   /utf8output /langversion:7.3 Node2D.cs Properties\AssemblyInfo.cs "C:\Users\Marcel\AppData\Local\Temp\.NETFramework,
  Version=v4.7.AssemblyAttributes.cs"
  Using shared compilation with compiler from directory: C:\Program Files\Mono\lib\mono\msbuild\15.0\bin\Roslyn
C:\Program Files\Mono\lib\mono\msbuild\15.0\bin\Roslyn\Microsoft.CSharp.Core.targets(59,5): error MSB6006: "csc.exe" ex
ited with code 1. [C:\Users\Marcel\Downloads\Godot\Test Mono RC1\Test Mono RC1.csproj]
Done Building Project "C:\Users\Marcel\Downloads\Godot\Test Mono RC1\Test Mono RC1.csproj" (default targets) -- FAILED.

Done Building Project "C:\Users\Marcel\Downloads\Godot\Test Mono RC1\Test Mono RC1.sln" (default targets) -- FAILED.

Build FAILED.

"C:\Users\Marcel\Downloads\Godot\Test Mono RC1\Test Mono RC1.sln" (default target) (1) ->
"C:\Users\Marcel\Downloads\Godot\Test Mono RC1\Test Mono RC1.csproj" (default target) (2) ->
(CoreCompile target) ->
  C:\Program Files\Mono\lib\mono\msbuild\15.0\bin\Roslyn\Microsoft.CSharp.Core.targets(59,5): error MSB6006: "csc.exe"
exited with code 1. [C:\Users\Marcel\Downloads\Godot\Test Mono RC1\Test Mono RC1.csproj]

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:01.84

Lines 59 of Microsoft.CSharp.Core.targets is:

    <Csc Condition="'%(_CoreCompileResourceInputs.WithCulture)' != 'true'"
  1. From a PowerShell I ran: & "C:\Program Files\Mono\bin\msbuild.bat" "C:\Users\Marcel\Downloads\Godot\MSBuildTest\MSBuildTest.sln" With the following minimal project: MSBuildTest.zip

Which produced the following output

Microsoft (R) Build Engine version 16.5.0-ci for Mono
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 17/06/2020 14:50:41.
Project "C:\Users\Marcel\Downloads\Godot\MSBuildTest\MSBuildTest.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
  Building solution configuration "Debug|x86".
Project "C:\Users\Marcel\Downloads\Godot\MSBuildTest\MSBuildTest.sln" (1) is building "C:\Users\Marcel\Downloads\Godot\
MSBuildTest\MSBuildTest.csproj" (2) on node 1 (default targets).
PrepareForBuild:
  Creating directory "bin\Debug\".
  Creating directory "\x86\Debug\".
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the i
nput files.
CoreCompile:
  C:\Program Files\Mono\lib\mono\msbuild\15.0\bin\Roslyn\csc.exe /noconfig /nowarn:1701,1702 /nostdlib+ /platform:x86 /
  errorreport:prompt /warn:4 /define:DEBUG /highentropyva+ /reference:"C:\Program Files (x86)\Reference Assemblies\Micr
  osoft\Framework\.NETFramework\v4.7\mscorlib.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Fr
  amework\.NETFramework\v4.7\System.Core.dll" /debug+ /debug:full /optimize- /out:\x86\Debug\MSBuildTest.exe /subsystem
  version:6.00 /target:exe /utf8output /langversion:7.3 HelloWorld.cs "C:\Users\Marcel\AppData\Local\Temp\.NETFramework
  ,Version=v4.7.AssemblyAttributes.cs"
  Using shared compilation with compiler from directory: C:\Program Files\Mono\lib\mono\msbuild\15.0\bin\Roslyn
C:\Program Files\Mono\lib\mono\msbuild\15.0\bin\Roslyn\Microsoft.CSharp.Core.targets(59,5): error MSB6006: "csc.exe" ex
ited with code 1. [C:\Users\Marcel\Downloads\Godot\MSBuildTest\MSBuildTest.csproj]
Done Building Project "C:\Users\Marcel\Downloads\Godot\MSBuildTest\MSBuildTest.csproj" (default targets) -- FAILED.

Done Building Project "C:\Users\Marcel\Downloads\Godot\MSBuildTest\MSBuildTest.sln" (default targets) -- FAILED.

Build FAILED.

"C:\Users\Marcel\Downloads\Godot\MSBuildTest\MSBuildTest.sln" (default target) (1) ->
"C:\Users\Marcel\Downloads\Godot\MSBuildTest\MSBuildTest.csproj" (default target) (2) ->
(CoreCompile target) ->
  C:\Program Files\Mono\lib\mono\msbuild\15.0\bin\Roslyn\Microsoft.CSharp.Core.targets(59,5): error MSB6006: "csc.exe"
exited with code 1. [C:\Users\Marcel\Downloads\Godot\MSBuildTest\MSBuildTest.csproj]

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:01.48

For the record, when using Visual Studio's MSBuild.exe, 1. produced the same error i.e. running: & "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe" "C:/Users/Marcel/Downloads/Godot/Test Mono RC1/Test Mono RC1.sln" /v:normal /t:Restore,Build "/p:Configuration=Debug" "/l:GodotTools.BuildLogger.GodotBuildLogger,C:\Users\Marcel\Downloads\Godot\Godot_v3.2.2-rc1_mono_win64\GodotSharp\Tools\GodotTools.BuildLogger.dll;C:\Users\Marcel\AppData\Roaming/Godot/mono/build_logs\adeb49de002905ec5b4f1c77aaf06cf7_Debug" /p:GodotDefineConstants=\"GODOT_WINDOWS;GODOT_64;\"

Produced the following output:

Microsoft (R) Build Engine version 16.6.0+5ff7b0c9e for .NET Framework```
Copyright (C) Microsoft Corporation. All rights reserved.

MSBUILD : error MSB1006: Property is not valid.
Switch: GODOT_64

For switch syntax, type "MSBuild -help"

However, both 2 and 3 both built fine.

In short there is a problem building projects from the command line.

madmiraal commented 4 years ago

Running Mono MSBuild with /v:diag includes the following additional information just before the error:

Could not load file or assembly 'System.Text.Encoding.CodePages, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03
  f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. (TaskId:20)

So it looks like Mono MSBuild is looking for a system dependency that's not included in the targeted Framework. :-/

madmiraal commented 4 years ago

This is a known issue on Windows. As described here, Mono MSBuild is invoking csc.exe instead of Mono's csc.bat.

There is an open issue to fix it, but the workaround is to use the parameters: /p:CscToolPath="c:\Program Files\Mono\bin" /p:CscToolExe=csc.bat to force it to use Mono's csc.bat.

Adding these parameters, both 2, and 3 now build fine with Mono MSBuild too.

neikeq commented 4 years ago

The first one is related to this argument:

/p:GodotDefineConstants=\"GODOT_WINDOWS;GODOT_64;\"

Try removing the backslash \ before the double quotes.

If that still fails, remove the entire argument. I don't think it has any effect on this.

neikeq commented 4 years ago

I just noticed this is 3.2.2rc1. In that case it may be related to calling restore like this: /t:Restore,Build. I read that's bug prone and should use /restore instead.

madmiraal commented 4 years ago

Try removing the backslash \ before the double quotes.

Running: & "C:\Program Files\Mono\bin\msbuild.bat" "C:/Users/Marcel/Downloads/Godot/Test Mono RC1/Test Mono RC1.sln" /v:normal /t:Restore,Build "/p:Configuration=Debug" "/l:GodotTools.BuildLogger.GodotBuildLogger,C:\Users\Marcel\Downloads\Godot\Godot_v3.2.2-rc1_mono_win64\GodotSharp\Tools\GodotTools.BuildLogger.dll;C:\Users\Marcel\AppData\Roaming/Godot/mono/build_logs\adeb49de002905ec5b4f1c77aaf06cf7_Debug" /p:GodotDefineConstants="GODOT_WINDOWS;GODOT_64;"

Produces a similar message:

MSBUILD : error MSB1005: Specify a property and its value.
Switch: /p:GodotDefineConstants=GODOT_WINDOWS;GODOT_64;

If that still fails, remove the entire argument.

Running: & "C:\Program Files\Mono\bin\msbuild.bat" "C:/Users/Marcel/Downloads/Godot/Test Mono RC1/Test Mono RC1.sln" /v:normal /t:Restore,Build "/p:Configuration=Debug" "/l:GodotTools.BuildLogger.GodotBuildLogger,C:\Users\Marcel\Downloads\Godot\Godot_v3.2.2-rc1_mono_win64\GodotSharp\Tools\GodotTools.BuildLogger.dll;C:\Users\Marcel\AppData\Roaming/Godot/mono/build_logs\adeb49de002905ec5b4f1c77aaf06cf7_Debug"

This seems to work, although it doesn't say success:

Build started 18/06/2020 11:58:38.
Project "C:\Users\Marcel\Downloads\Godot\Test Mono RC1\Test Mono RC1.sln" on node 1 (Restore;Build target(s)).
ValidateSolutionConfiguration:
  Building solution configuration "Debug|Any CPU".

I assume this is because it doesn't try to recompile it.

neikeq commented 4 years ago

I managed to reproduce this today. It seems Mono's MSBuild has issues with PackageReference. I will consider removing the option in 3.2.x and maybe 4.0 as well if the problem persists with the new project sdk.