8

Build C#9 with AppCenter

 3 years ago
source link: https://www.sharpnado.com/build-c-9-with-appcenter/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
Build C#9 with AppCenterMenu

First I must confess something.
I think that appcenter is one of the best devops tool on the market:

But, lately, some of you may have encountered a quite upsetting issue with appcenter builds:

It cannot build C#9:

appcenterc9.png

The issue lies on the mono side of appcenter, the latest stable build 6.12.0.122 cannot build C#9, it uses msbuild 15:

mono_122.png

Trying to compile C#9 code will result numerous errors.

errors.png

The good news is that the Preview (6.12.0.145) version supports C#9.

So can we uses the latest preview of mono instead of the stable one?

First you need to know that you can add custom scripts to appcenter at various build steps:

  • Post-clone (appcenter-post-clone.sh)
  • Pre-build (appcenter-pre-build.sh)
  • Post-build (appcenter-post-build.sh)

more here: https://docs.microsoft.com/en-us/appcenter/build/custom/scripts/

All you have to do is add file at the root of your project (or solution) with the correct naming convention.

Thanks to this, we can use tools to modify the environment of appcenter.
This is what Boots is doing, a great tool by the even greater Jonathan Peppers:

https://devblogs.microsoft.com/xamarin/boots-xamarin-ci/

So as stated in the article I tried to install new version of mono in the appcenter-post-clone.sh script of my build.

Unfortunately it seems to break the nuget command in some way:

https://github.com/jonathanpeppers/boots/issues/87

Then I saw the light, since it broke the nuget step, why not use Boots AFTER the restore step, in the appcenter-pre-build.sh script.

Unfortunately, I hit another issue:

https://github.com/jonathanpeppers/boots/issues/90

So should I quit?
Should I betray the Lord who is my witness and is watching from above?

geton_withit.png

Ok.
So I tried a simple custom way to install the mono preview in the pre-build script (appcenter-pre-build.sh):

#!/usr/bin/env bash

# Download Mono 6.12.0.145
wget https://download.mono-project.com/archive/6.12.0/macos-10-universal/MonoFramework-MDK-6.12.0.145.macos10.xamarin.universal.pkg

# Add execution permission
sudo chmod +x MonoFramework-MDK-6.12.0.145.macos10.xamarin.universal.pkg

# Install Mono 6.12.0.145
sudo installer -pkg MonoFramework-MDK-6.12.0.145.macos10.xamarin.universal.pkg -target /  

And guess what:

zero_errors.png

a-blessing-a-blessing-from-the-lord.jpg

Jean-Marie Alfonsi

I am a freelance developer since 2012 focusing primarly on Xamarin stuff: xamarin ios, xamarin android, xamarin forms.

Share this post


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK