Install MonoGame 3.7.1 on Linux Mint 19.2 Tina Cinnamon

Hi all,

I had some time to try to install MonoGame 3.7.1 on Linux, which in my case is Linux Mint 19.2 Tina Cinnamon!

I used @cra0zy`s installation instructions for MonoGame 3.6 and adapted them to install MonoGame 3.7.1.

So here are the step by step installation instructions which worked for me:

Step 1

Since it is based on Ubuntu I installed the latest official version of MonoDevelop for Ubuntu 18.04 like this (check the link for comparison):

sudo apt install apt-transport-https dirmngr
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb https://download.mono-project.com/repo/ubuntu vs-bionic main" | sudo tee /etc/apt/sources.list.d/mono-official-vs.list
sudo apt update
sudo apt-get install monodevelop

Step 2

After that I used @cra0zy`s package (thank you for providing it btw) like described here like this:

wget https://github.com/cra0zy/monodevelop-run-installer/releases/download/6.2.0.1778-1/monodevelop-6.2.0.1778-1.run
chmod +x monodevelop-6.2.0.1778-1.run
sudo ./monodevelop-6.2.0.1778-1.run

Step 3

After that I opened the Menu and openend MonoDevelop Stable once so that it creates the necessary files as the current user as described by @harry-cpp.

Step 4

After that I installed MonoGame with the provided installer like this:

wget https://github.com/MonoGame/MonoGame/releases/download/v3.7.1/monogame-sdk.run
chmod +x monogame-sdk.run
sudo ./monogame-sdk.run

Step 5

I cleaned up the temporary files with

sudo rm monodevelop-6.2.0.1778-1.run monogame-sdk.run

Step 6

I opened MonoDevelop Stable and used Tools | Add-ins… | Gallery | Game Development | MonoGame Addin from the menu to install the project templates so that it is then possible to create a new solution in MonoDevelop which is based on one of the MonoGame templates.

Step 7

I opened MonoDevelop and used Tools | Extensions… | Gallery | Game Development | MonoGame Extension from the menu to install the project templates so that it is then possible to create a new solution in MonoDevelop which is based on one of the MonoGame templates.

Step 8

At this point the installation should be complete.

Just wanted to share, enjoy :slight_smile:

3 Likes

I wrote a script to automate the process a bit further…

#! /bin/bash
#
# step 1
monodeveloplatest=monodevelop
if [ $(dpkg-query -W -f='${Status}' $package 2>/dev/null | grep -c "ok installed") -eq 0 ];
then
  echo "$monodeveloplatest not installed..."
  sudo apt install -y apt-transport-https dirmngr
  sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
  echo "deb https://download.mono-project.com/repo/ubuntu vs-bionic main" | sudo tee /etc/apt/sources.list.d/mono-official-vs.list
  sudo apt update
  sudo apt-get install -y $monodeveloplatest
else
  echo "$monodeveloplatest already installed."
fi
# step 2
monodevelopstable=monodevelop-6.2.0.1778-1.run
monodevelopstablefull=https://github.com/cra0zy/monodevelop-run-installer/releases/download/6.2.0.1778-1/${monodevelopstable}
if [ -f $monodevelopstable ]; then
  echo "${monodevelopstable} found"
else   
  echo "downloading ${monodevelopstable}..."
  wget $monodevelopstablefull
fi
chmod +x $monodevelopstable
sudo ./$monodevelopstable
# step 3
echo "Opening MonoDevelop stable... The script will continue after MonoDevelop stable is closed. Please close it now. Waiting for MonoDevelop stable to be closed..."
[ $SUDO_USER ] && user=$SUDO_USER || user=`whoami`
echo $user
sudo -H -u $user bash -c 'monodevelop-stable && wait $!'
# step 4
monogame=monogame-sdk.run
monogamefull=https://github.com/MonoGame/MonoGame/releases/download/v3.7.1/${monogame}
if [ -f $monogame ]; then
  echo "${monogame} found"
else   
  echo "Downloading MonoGame..."
  wget $monogamefull
fi
chmod +x monogame-sdk.run
echo "Installing MonoGame..."
sudo ./$monogame
# step 5 
echo "Downloaded files:"
echo ${monodevelopstable} 
echo ${monogame}
while true; do
    read -p "Do you wish to cleanup and delete the downloaded files which are no longer needed by this script?" yn
    case $yn in
        [Yy]* ) echo "deleting files..." && sudo rm ${monodevelop} ${monogame}; break;;
        [Nn]* ) exit;;
        * ) echo "Please answer yes or no.";;
    esac
done
# step 6
echo "To install the MonoGame templates: Please open MonoDevelop stable and use Tools > Add-ins... > Gallery > Game Development > MonoGame Addin."
# step 7
echo "To install the MonoGame templates: Please open MonoDevelop and use Tools > Extensions... > Gallery > Game Development > MonoGame Extension."
# step 8
echo "Finished!"
read -p "Finished! Press [Enter] to exit."

I noticed, that there is a warning when installing the MonoGame templates in MonoDevelop stable but it will work anyway. The created solutions can be openend with both MonoDevelop and MonoDevelop stable.

But there is another issue if you create a new solution with MonoDevelop. There will be a red x visible next to the project saying Invalid Configuration Mapping. It will look like this:


There is a simple workaround for this as suggested here
Right clicking on the red x and choosing Tools > Edit File and then using Ctrl+H to search for “Any CPU” and replace it with “AnyCPU” and then saving the file with Ctrl+S was enough to make it work. After that it was possible to build the solution.

1 Like

Using https://github.com/infinitespace-studios/InfinitespaceStudios.Pipeline I could successfully build a project with shader files.

Thanks so much for this! I was having difficulties getting monodevelop to “see” monogame.
This was very concise and clear; made my getting it working much easier.

I appreciate your time!
Beef

2 Likes

Happy to hear it helped someone. Don’t forget to thank @harry-cpp too. He provides the package on github that I used in the script.

@beef-erikson Did you use Linux Mint 19.2 or 19.3?

Linux Mint 19.3 and yes, a HUGE thanks to @harry-cpp - I’m very grateful to work in Linux again :heart:

1 Like

Since I am very new to the Linux world myself I don’t know how the packaging done by @harry-cpp was accomplished. I guess the installation of the provided package will not be necessary at some point in the future when the installation of MonoGame will maybe changed in some way so that everything works right away and so will hopefully get easier for the end user? Until then this workaround is hopefully convenient enough.

Since I was using a lot of shader programming in my projects I was excited that there is the option for remote shader compiling. But remote compiling the effect files takes more time and debugging of the shaders is more difficult. So hopefully shader compiling will natively soon be possible in Linux too?

What would be nice to have is a detailed tutorial on how to setup a windows environment in a virtual machine with virtual box. Maybe then the compiling would get a bit faster if the “remote” compiling would be done on the same machine or in the local network?

You can use dotnet new -i MonoGame.Templates.CSharp to install dotnet templates which should work out of the box without having to install anything else. Obviously you will need to generate templates from the terminal, but I don’t think that’s an issue for an average Linux user (ie. dotnet new mgdesktopgl will generate a MonoGame DesktopGL template).

As for the shader issue, technically you can compile them with Wine, I could make a tutorial on it, and probably integrate it into MonoGame by default. I’m always hesitant to do that as its not native…

So I have to install .NET Core SDK for that I guess? You’re right, creating templates from the command line should be fine for Linux users.

Edit: I installed the .NET Core SDK 3.1 as described here


with the package manger like this

# Register Microsoft key and feed
wget -q https://packages.microsoft.com/config/ubuntu/19.10/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
# Install the .NET Core SDK
sudo apt-get update
sudo apt-get install apt-transport-https
sudo apt-get update
sudo apt-get install dotnet-sdk-3.1

I can now generate templates from the command line. But since I already had MonoGame installed before with templates available in Mono Develop I am not sure where they should be created if this would not have been the case?

@harry-cpp A tutorial on compiling the shaders with wine would be great. If you have time please do it :slight_smile:

@harry-cpp Any hints on how to do this? Would love to be able to work on Linux :slight_smile:

Again, Wine, pretty much install directx, net framework and mg 3.7.

To be even more precise, here is what you do:

  1. Install newest version of Wine
  2. Install winetricks
  3. Install wine-mono (no need for full .NET Framework, unless you want to run Pipeline Tool, which you don’t)
  4. Install d3dcompiler_42, d3dcompiler_43 and d3dcompiler_47 using winetricks
  5. Install MonoGame version that you want
  6. Just run MGCB or 2MGFX from the command line, it should just work

Extra fun you can do: https://youtu.be/bSH5CijtfRA

  1. I checked with wine --version and I have installed version wine-4.0.3
  2. I have installed winetricks following https://wiki.winehq.org/Winetricks#What_is_winetricks.3F:
    wintricks --version -> 20180217 - sha256sum: 1b156c616174f41df79d72a90c52eb2b110c63a6e8ecb865d303a8f9f0908924
    Edit: I actually made a mistake here. I previously had installed winetricks from the repository with sudo apt install winetricks which will give you the way to old version I thought I used above (20180217). Following the link above and executing the commands downloads a newer version 20191224-next - sha256sum: 3a11b9c07e2d7f5b6c21a5e7ef35c70cbc9344bd9a8e068d74b34793dfee6484! Make sure you run this version by using the cd command to navigate to the download folder and executing ./winetricks (not winetricks!) so that the downloaded version will start. After that you will find the options you need to create a new wine bottle / wine prefix through the winetricks GUI (not so with the old version!). Hope this helps others not fiddling around forever like I did! ^^
    Edit: I also found a good answer on how to get the latest version of winetricks:
    Check which is the current up to date version with this one liner:
    curl --silent --show-error \ https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks --stderr - \ | grep ^WINETRICKS_VERSION | cut -d '=' -f 2
    Then after that check the version you have installed with winetricks --version. If the upstream version is newer and you want the newest one start by uninstall winetricks first with sudo apt-get remove winetricks. Then after that execute the following 3 commands
wget  https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks
chmod +x winetricks 
sudo mv -v winetricks /usr/local/bin
  1. I already have the dotnet framework installed, so skipping the installation of wine-mono here:
    dotnet --version -> 3.1.200
    Edit: But also not sure where to install this and where I get wine-mono from if I had not installed dotnet? Is this available through winetricks? Do I need to install it with wine to the wine prefix I made with winetricks?
  2. I started wintricks and in the GUI selected to install a DLL or component. Then checked to install d3dcompiler_42, d3dcompiler_43 and d3dcompiler_47. Everything was skipped because all were already installed?!
    Edit: If you do not find the option to install these in winetricks maybe you are using an older version of winetricks like I did, see above and make sure you run an up to date version of winetricks. So just start the right version (see above) of winetricks and create a 64 bit wine bottle / wine prefix. After that the GUI should let you choose the just created 64 bit wine bottle / prefix and should show the selected wine bottle / prefix as window title / caption. After that just click on install component or DLL. Choose the DLLs as stated above.
  3. I want to install MonoGame371 for now. I downloaded the Visual Studio version https://github.com/MonoGame/MonoGame/releases/download/v3.7.1/MonoGameSetup.exe of MonoGame371 from MonoGame 3.7.1 Release here. I tried installing it with WINEPREFIX=$HOME/.local/share/wineprefixes/wine-64-mg WINEARCH=win64 wine MonoGameSetup371.exe. The architecture (32 or 64 bit) of the wine prefix is defined when setting the wine prefix up with winetricks! So make sure you use 64 bit when creating it there! How do I know which wine prefix it uses? I did it by just looking inside the wine prefix created with wine and I verified it used this one because I had the MonoGame installation in there. So seems to work to pass the WINEPREFIX variable like in the command above?!
  4. I found the files 2MGFX.exe and MGCB.exe installed in the folder ~/.local/share/wineprefixes/wine-64-mg/drive_c/Program Files (x86)/MSBuild/MonoGame/v3.0/Tools (here wine-64-mg was the name I chose for the 64 bit wine prefix / bottle in winetricks! Change the name to your wine prefix!). How to run the tools now? Just run the tools from bash with wine ./MGCB.exe and wine ./2MGFX.exe from bash? Running the tools like this gives me a message The MonoGame content tools only work on a 64bit OS.. Just found the solution I think. The tools need to be run like this wine64 ./MGCB.exe and wine64 ./2MGFX.exe which seems to work…?
    What is the recommended work flow for the tools to compile effects? What are the commands to compile one effect with the tools? And on the MonoGame side, I would then just load a compiled effect by using Content.load<effect>("effect.xnb")?
    Edit: Still unclear what to do at this point… More advice on how to do this would be nice :slight_smile:

Oh sorry, I missed your comment.

For the Wine setup I am down to this script:

#!/bin/bash

export WINEARCH=win64
export WINEPREFIX=$HOME/.winemonogame
wine64 wineboot
winetricks d3dcompiler_42 d3dcompiler_43 d3dcompiler_47
# Install .NET Core 3.1 SDK from Website

As for actually using MGCB/MGFXC with Wine, right now there is no proper way to use it, you would need to write your own autobuild scripts.

You can also wait few more days, I’m almost done with making MGFXC to automatically relaunch itself under Wine, just some MonoGame.Framework.Content.Pipeline and documentation fixes left.

I can’t get any of this to work… I keep getting this error when running update after installing monodevelop…

Get:1 https://download.mono-project.com/repo/ubuntu vs-bionic/main amd64 msbuild all 1:16.3+xamarinxplat.2019.08.08.00.55-0xamarin2+ubuntu1804b1 [7,720 kB]
Fetched 7,720 kB in 30s (261 kB/s)                                                                                                                    
(Reading database ... 247023 files and directories currently installed.)
Preparing to unpack .../msbuild_1%3a16.3+xamarinxplat.2019.08.08.00.55-0xamarin2+ubuntu1804b1_all.deb ...
Unpacking msbuild (1:16.3+xamarinxplat.2019.08.08.00.55-0xamarin2+ubuntu1804b1) over (1:15.4+xamarinxplat.2017.11.27.11.23-0xamarin1+ubuntu1404b1) ...
dpkg: error processing archive /var/cache/apt/archives/msbuild_1%3a16.3+xamarinxplat.2019.08.08.00.55-0xamarin2+ubuntu1804b1_all.deb (--unpack):
 trying to overwrite '/usr/lib/mono/msbuild/15.0', which is also in package mono-roslyn 5.10.1.20-0xamarin1+debian7b1
Errors were encountered while processing:
 /var/cache/apt/archives/msbuild_1%3a16.3+xamarinxplat.2019.08.08.00.55-0xamarin2+ubuntu1804b1_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

Also the instructions in the OP says " Do note that the installation page forgets to tell you that to install MonoDevelop you need to install monodevelop package" but I do not know how to do that, there is no instructions saying what that means. Does that just mean install the monodevelop IDE?

Did you add the MonoDevelop package repository? Full instructions here: https://www.monodevelop.com/download/#download-lin-ubuntu

Oh my word. This has had me stymied for hours!. Thank you for the work around. Many <3

1 Like

Thanks for manual

1 Like