From 3051a367b9de59787c2de7600420d3da378946da Mon Sep 17 00:00:00 2001 From: stakx Date: Sat, 2 May 2020 12:07:06 +0200 Subject: [PATCH] Prefer to run `mono` via Docker This lets us choose which version of Mono to use without having to install it. This is important because the version currently preinstalled on App- Veyor has a regression that breaks our build, and installing another Mono version on AppVeyor is both slow and error-prone. --- README.md | 2 +- appveyor.yml | 1 - build.sh | 16 ++++++++++++---- buildscripts/docker-run-mono.sh | 4 ++++ 4 files changed, 17 insertions(+), 6 deletions(-) create mode 100755 buildscripts/docker-run-mono.sh diff --git a/README.md b/README.md index d445dc1c3d..562b145ce0 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ Most of these requirements should be covered by Visual Studio 2017. Compilation requires an up-to-date .NET Core SDK. -Running the unit tests additionally requires Mono and the .NET Core 1.1 runtime to be installed. We recommend Mono 5.10+, though older versions (4.6.1+) might still work as well. +Running the unit tests additionally requires the .NET Core 1.1 runtime to be installed, as well as either Docker or Mono. For the latter, we recommend Mono 5.10+, though older versions (4.6.1+) might still work as well. :information_source: **Mono runtime support:** Castle Core runs with minor limitations and defects on Mono 4.0.2+ (however 4.6.1+ is highly recommended, or 5.10+ if your code uses new C# 7.x language features such as `in` parameters). diff --git a/appveyor.yml b/appveyor.yml index 926c93a873..5428d4f4f8 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -21,7 +21,6 @@ for: # build and run tests build_script: - uname -a - - mono --version - ./build.sh # upload test results diff --git a/build.sh b/build.sh index 03519c913e..eea56cc55d 100755 --- a/build.sh +++ b/build.sh @@ -13,19 +13,27 @@ # See the License for the specific language governing permissions and # limitations under the License. # **************************************************************************** +shopt -s expand_aliases DOTNETPATH=$(which dotnet) if [ ! -f "$DOTNETPATH" ]; then echo "Please install Microsoft/netcore from: https://www.microsoft.com/net/core" exit 1 fi -MONOPATH=$(which mono) -if [ ! -f "$MONOPATH" ]; then - echo "Please install Xamarin/mono from: http://www.mono-project.com/docs/getting-started/install/" - exit 1 +DOCKERPATH=$(which docker) +if [ -f "$DOCKERPATH" ]; then + alias mono="$PWD/buildscripts/docker-run-mono.sh" +else + MONOPATH=$(which mono) + if [ ! -f "$MONOPATH" ]; then + echo "Please install either Docker, or Xamarin/Mono from http://www.mono-project.com/docs/getting-started/install/" + exit 1 + fi fi +mono --version + # Linux/Darwin OSNAME=$(uname -s) echo "OSNAME: $OSNAME" diff --git a/buildscripts/docker-run-mono.sh b/buildscripts/docker-run-mono.sh new file mode 100755 index 0000000000..eb4459f8fd --- /dev/null +++ b/buildscripts/docker-run-mono.sh @@ -0,0 +1,4 @@ +#!/bin/bash +set -e +MONO_TAG=${MONO_TAG:-6.0.0.334} +docker run --rm -v "$PWD":'/project' -w='/project' mono:$MONO_TAG mono "$@"