This is my cheat sheet for compiling mono on Raspbian which come from the mono docs.

First like yoghurt, you need mono to make mono

sudo apt-get install git autoconf libtool automake build-essential mono-devel gettext 

Download and unzip the source, substituting 4.0.2.4 or whatever the latest version is:

wget http://download.mono-project.com/sources/mono/mono-4.0.2.4.tar.bz2
tar xvf 4.0.2.4.tar.gz
cd mono-4.0.2

Finally, build it

./configure --prefix=/opt/mono-4.0.2
make
sudo make install

Except then there are two versions of mono:

  1. apt-get version 3.2.8
  2. our freshly compiled build in /opt/mono-4.0.2

In order to execute code with our fresh new mono build, the docs tell us to: nano ~/mono4.sh and paste in

#!/bin/bash
MONO_PREFIX=/opt/mono-4.0.2
GNOME_PREFIX=/opt/gnome
export DYLD_FALLBACK_LIBRARY_PATH=$MONO_PREFIX/lib:$DYLD_LIBRARY_FALLBACK_PATH
export LD_LIBRARY_PATH=$MONO_PREFIX/lib:$LD_LIBRARY_PATH
export C_INCLUDE_PATH=$MONO_PREFIX/include:$GNOME_PREFIX/include
export ACLOCAL_PATH=$MONO_PREFIX/share/aclocal
export PKG_CONFIG_PATH=$MONO_PREFIX/lib/pkgconfig:$GNOME_PREFIX/lib/pkgconfig
export PATH=$MONO_PREFIX/bin:$PATH
PS1="[mono4.0.2] \w @ "

Save that and we can switch from old mono to new by executing source ~/mono4.sh. If it worked, the bash prompt should have changed and we can verify it by checking mono --version.