godotengine / godot

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

Godot Mono Doesn't Work on Ubuntu 20.04 #38167

Open RodrigoMedeirosRS opened 4 years ago

RodrigoMedeirosRS commented 4 years ago

Godot version: 3.2.1 Mono x64 OS/device including version: Ubuntu 20.04 x64 Issue description: Godot C# doesn't build the project. Captura de tela de 2020-04-24 00-38-08 Steps to reproduce: Create a New C# project, add a blank script, try to build. Minimal reproduction project: No needed, only a blank project is enought. Error: Projeto "Novo Projeto De Jogo.sln" (Build destino(s)): Message: Compilando a configuração de solução "Debug|Any CPU". Projeto "Novo Projeto De Jogo.csproj" (destinos padrão): /usr/lib/mono/msbuild/Current/bin/Microsoft.CSharp.CurrentVersion.targets(333,5): error MSB4019: o projeto importado "/usr/lib/mono/msbuild/Current/bin/Roslyn/Microsoft.CSharp.Core.targets" não foi localizado. Confirme se a expressão na declaração Import "/usr/lib/mono/msbuild/Current/bin/Roslyn/Microsoft.CSharp.Core.targets" está correta e se o arquivo existe no disco. [/home/margarete/Documentos/GameDev/Projetos/Novo Projeto de Jogo/Novo Projeto De Jogo.csproj] Projeto de compilação pronto "Novo Projeto De Jogo.csproj" -- FALHA. Projeto de compilação pronto "Novo Projeto De Jogo.sln" -- FALHA.

Mono Issue https://github.com/mono/mono/issues/19648

akien-mga commented 4 years ago

You're missing the package that includes /usr/lib/mono/msbuild/Current/bin/Roslyn/Microsoft.CSharp.Core.targets

RodrigoMedeirosRS commented 4 years ago

I get this package from my other notebook (Ubuntu 19.10), and put into the folder, the error persist, i belive this can be a compatibility problem between Ubuntu 20.04 and Mono, but i create this issue more with the intet to alert the community.

akien-mga commented 4 years ago

Copying the folder from another system is not a good solution, you should install the package that the Mono team provides for Ubuntu 20.04: https://www.mono-project.com/download/stable/

They have yet to update their setup instructions for Ubuntu 20.04, but the repository exists: https://download.mono-project.com/repo/ubuntu/dists/stable-focal/

aaronfranke commented 4 years ago

I installed Mono with these commands (the 18.04 commands but replacing "bionic" with "focal"):

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb https://download.mono-project.com/repo/ubuntu stable-focal main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
sudo apt update
sudo apt install mono-complete

After doing this, /usr/lib/mono exists, but /usr/lib/mono/msbuild does not exist.

notverymoe commented 4 years ago

Hopefully I'm not just adding noise to the issue, but, there does appear to be a Microsoft.CSharp.targets under /usr/lib/mono/xbuild/14.0/bin/ and /usr/lib/mono/xbuild/12.0/bin/ when installing mono-complete on 20.04.

akien-mga commented 4 years ago

You have to install msbuild too. (Actually if you don't build Godot from source, you should only need msbuild, not the full mono. But having the mono SDK doesn't hurt either.)

akien-mga commented 4 years ago

Try to install the msbuild package.

neikeq commented 4 years ago

Same issue after upgrading to 20.04. As a workaround, if like me you can't wait for a fix, you can switch to the preview repository:

sudo apt install gnupg ca-certificates
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb https://download.mono-project.com/repo/ubuntu preview-focal main" | sudo tee /etc/apt/sources.list.d/mono-official-preview.list
sudo apt update
# if the packages were already installed
sudo apt upgrade
# otherwise
sudo apt install mono-complete msbuild
neikeq commented 4 years ago

I reverted back to the stable repository. Looks like additionally installing mono-roslyn fixes it.

aaronfranke commented 4 years ago

With apt?

E: Unable to locate package mono-roslyn
neikeq commented 4 years ago

From the stable-bionic repo. I don't see stable-focal listed in the mono download page.

aaronfranke commented 4 years ago

https://download.mono-project.com/repo/ubuntu/dists/stable-focal/

I assume stable-bionic is not intended to be used on Ubuntu 20.04.

neikeq commented 4 years ago

Probably not, but I'll be using it as a workaround until this is fixed. The other option is preview-focal, but that's for Mono 6.10.0 which is not stable either.

petergloor commented 4 years ago

I'm working on another project, However, I can confirm that as a temporary solution using the stable-bionic archives on a fresh Ubuntu 20.04 install the following worked for me:

sudo apt update
sudo apt upgrade
sudo apt install build-essential
sudo apt install gnupg ca-certificates
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb https://download.mono-project.com/repo/ubuntu stable-bionic main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
sudo apt update
sudo apt install mono-roslyn mono-complete mono-dbg msbuild

I could then use msbuild as before. The Mono version is 6.8.0.105 which currently is the latest stable version anyway.

RodrigoMedeirosRS commented 4 years ago

I found the solution, the problem isn't the Godot, the problem is in Mono, i have installed the Mono 20.04 Preview, all problems are fixed.

I suggest the people wait the release of Stable version or trying the preview.

aaronfranke commented 4 years ago

@RodrigoMedeirosRS It's fine if you want to close this, but for future reference it's also fine to leave this open even if the bug isn't caused by Godot. It could help other people who are experiencing the same issue if they search for it.

RodrigoMedeirosRS commented 4 years ago

Hello @aaronfranke Sorry about that, i really didn't know that closing the bug, I would be somehow making it difficult to access the solution. I'm still not quite used to the structure of Github. I will be more carefully in the future.

PizzaConsole commented 3 years ago

Ok, I have tried every solution that everyone has posted here and I still cant get it to work. I am trying to build it through an azure pipeline and no matter wat I always get this error.. Please help me... I am gunna explode

I should also mention that I am running the linux headless mono build

ERROR: get_language_code: Invalid locale 'C'.
2021-02-23T08:58:53.0584126Z    At: core/translation.cpp:945.
2021-02-23T08:58:53.0584703Z ERROR: set_locale: Unsupported locale 'C', falling back to 'en'.
2021-02-23T08:58:53.0585083Z    At: core/translation.cpp:969.
2021-02-23T08:58:54.6973505Z reimport: begin: (Re)Importing Assets steps: 1
2021-02-23T08:58:54.6974074Z    reimport: step 0: icon.png
2021-02-23T08:58:55.1647972Z mono_project_debug_build: begin: Building project solution... steps: 1
2021-02-23T08:58:55.1649044Z    mono_project_debug_build: step 0: Building project solution
2021-02-23T08:58:58.7540445Z mono_project_debug_build: end
2021-02-23T08:58:58.7545111Z ERROR: godot_icall_GD_pusherror: Failed to export project: Failed to build project
2021-02-23T08:58:58.7545626Z    At: modules/mono/glue/gd_glue.cpp:250.
2021-02-23T08:58:58.7599582Z System.Exception: Failed to build project
2021-02-23T08:58:58.7600295Z   at GodotTools.Export.ExportPlugin._ExportBeginImpl (System.String[] features, System.Boolean isDebug, System.String path, System.Int32 flags) [0x000a6] in <fea6bc16b6d64de0afe8ace2924a4bc2>:0 
2021-02-23T08:58:58.7601237Z   at GodotTools.Export.ExportPlugin._ExportBegin (System.String[] features, System.Boolean isDebug, System.String path, System.Int32 flags) [0x0000b] in <fea6bc16b6d64de0afe8ace2924a4bc2>:0 
2021-02-23T08:59:03.5656337Z savepack: begin: Packing steps: 102
2021-02-23T08:59:03.5657380Z    savepack: step 2: Storing File: res://.mono/metadata/scripts_metadata.release
2021-02-23T08:59:03.5658110Z    savepack: step 2: Storing File: res://default_env.tres
2021-02-23T08:59:03.5659470Z    savepack: step 27: Storing File: res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex
2021-02-23T08:59:03.5660269Z    savepack: step 27: Storing File: res://icon.png.import
2021-02-23T08:59:03.5660956Z    savepack: step 52: Storing File: res://scenes/Authenticate.tscn
2021-02-23T08:59:03.5663572Z    savepack: step 77: Storing File: res://scripts/Authenticate.cs
2021-02-23T08:59:03.5664303Z    savepack: step 102: Storing File: res://icon.png
2021-02-23T08:59:03.5667598Z    savepack: step 102: Storing File: res://project.binary
2021-02-23T08:59:03.5669105Z savepack: end
2021-02-23T08:59:03.5678768Z reimport: end
2021-02-23T08:59:05.1989326Z Godot Engine v3.2.3.stable.mono.official - https://godotengine.org
aaronfranke commented 3 years ago

@PoisnFang Do you have .NET Core SDK 3.1 installed? See this article for more information: https://docs.godotengine.org/en/latest/tutorials/scripting/c_sharp/c_sharp_basics.html

PizzaConsole commented 3 years ago

@aaronfranke does the Ubuntu image on the azure pipeline come with .net core installed?

Install the latest stable version of .NET Core SDK (3.1 as of writing). As of Godot 3.2.3, installing Mono SDK is not a requirement anymore, except it is required if you are building the engine from source.

Also why on earth is this not in the stable branch of the docs???

You are reading the latest (unstable) version of this documentation, which may document features not available or compatible with Godot 3.2.x.

I never would have thought to check the "latest" docs when I am running the stable version of godot

Calinou commented 3 years ago

Also why on earth is this not in the stable branch of the docs???

See https://github.com/godotengine/godot-docs/issues/4672. We need someone to update the documentation :slightly_smiling_face:

Also, commits on the master branch of the documentation aren't always cherry-picked to the 3.2/stable branches due to lack of manpower.

PizzaConsole commented 3 years ago

@Calinou Yeah, that makes sense. I am going insane trying to setup my CI/CD though...

PizzaConsole commented 3 years ago

@Calinou @aaronfranke Well that drives me nuts... It worked! You MUST use .NET Core 3.1 SDK not .NET 5!

from my azure yaml

- task: UseDotNet@2
  displayName: 'Use .NET Core sdk 3.1'
  inputs:
    packageType: 'sdk'
    version: '3.x'
    includePreviewVersions: false
aaronfranke commented 3 years ago

@PoisnFang Yes, it should be in the stable version of the docs, https://github.com/godotengine/godot-docs/pull/4560 needs to be cherry-picked (it also doesn't help that it sat waiting to be merged into master for nearly a month).

As for .NET Core 3.1 vs .NET 5, compatibility with .NET 5+ build tools is fixed in the 3.2 branch so it will be fixed in the next 3.2 release, Godot 3.2.4 (which has also taken many months to release due to being filled with many features in addition to bug fixes, so problems like this are inevitable unless we wanted to do a 3.3 branch or a 3.2.3.1 release).

PizzaConsole commented 3 years ago

@aaronfranke Understandable, I have updated to the 3.2.4.rc3 and that has fixed all my immediate issues. I will try to contribute in a helpful manner as I proceed. Thank you all for the great work!