Install new versions of dependencies on Azure devops microsoft hosted build server

Viewed 745

I have an issue with my azure build pipeline for a Xamarin mobile app in iOS. The issue required mono version 6.10.0 to be available on the build server. Currently the pre-installed image for macOS 10.14 only contains Mono up to version 6.08. The image for macOS 10.15 does contain the right version of Mono but due to internal reasons I am unable to upgrade to 10.15 at this point.

Is there a way to update the pipeline to install the new version of Mono before building? Or are we completely limited to the software that is included in the image? I am using a microsoft hosted server.

2 Answers

Is there a way to update the pipeline to install the new version of Mono before building?

As you said, the Mono version 6.10.0 doesn't exist in the Microsoft-Hosted Agent: Macos-10.14, but you could run the script before the Xamarin task to install the target Mono version.

Here is the pipeline example:

steps:
- bash: |
   #!/bin/bash
   set -ex
   
   
   MONO_MACOS_PKG_DOWNLOAD_URL='https://download.mono-project.com/archive/6.10.0/macos-10-universal/MonoFramework-MDK-6.10.0.49.macos10.xamarin.universal.pkg'
   
   
   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
  displayName: 'Bash Script'

- script: |
   mono -V
   
   cat `which mcs`
  displayName: 'Command Line Script'

Here is a Blog about install the mono.

Result:

enter image description here

Azure Pipelines hosted agents are general purpose build and deploy agents. So Microsoft are not going to add arbitrary old versions of software someone might need for an edge case.

However, you do have access to homebrew and other tools that could let you install the software you need on the agent. You also have access to set environment variables. So you could just install all the needed software.

As for the requirement of staying on macOS 10.14 and whatever versions of mono you need. At some point you must realise that none of the images that Microsoft provides will have any of this software. So if you must have this environment, make your own managed macOS agent and add to your pool to run stuff like this on.

Related