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

mono
xamarin
#1

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: https://download.mono-project.com/archive/

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.):

#!/bin/bash
set -ex

# Get the macos universal pkg installer download url
# for the version you want to install from: https://download.mono-project.com/archive/
# and set it here as the value of this variable:
MONO_MACOS_PKG_DOWNLOAD_URL='https://download.mono-project.com/archive/5.2.0/macos-10-universal/MonoFramework-MDK-5.2.0.224.macos10.xamarin.universal.pkg'

# 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:

0 Likes

Mono/Nunit issues