How to install specific version of Mono on MacOS / Visual Studio for Mac / Xamarin stack

If you’d need a specific version of mono other than the version which ships with Visual Studio for Mac, you can install any available mono version with a simple Script.

All you’ll need is the macos (universal) pkg download URL of the mono version you want to install, which you can get from:

Simply add a Script step to the relevant workflow(s) as the very first step in the build (the script doesn’t have any dependencies so it’s safe to run even before Git Clone etc.):

set -ex

# Get the macos universal pkg installer download url
# for the version you want to install from:
# and set it here as the value of this variable:

# create a temp dir and cd into it
mkdir -p /tmp/mono-install
cd /tmp/mono-install

# debug: mono version before the install
mono --version

# download mono mac installer (pkg)
wget -q -O ./mono-installer.pkg "$MONO_MACOS_PKG_DOWNLOAD_URL"

# install it
sudo installer -pkg ./mono-installer.pkg -target /

# debug: mono version after install, just to confirm it did overwrite the original version
mono --version

# just for fun print this symlink too, which should point to the version we just installed
ls -alh /Library/Frameworks/Mono.framework/Versions/Current

That’s all! When this script finishes the mono version which you specified should be the used by the tools which use Mono (including Xamarin / Visual Studio for Mac).

Happy Building! :slight_smile: