First I must confess something.
I think that appcenter is one of the best devops tool on the market:
- It's super intuitive
- It's super easy to setup
- Distribution is a blessing
- You can organize a close beta test with no pain
- Diagnostics are super powerful
- You can attach logs to crash reports: https://devblogs.microsoft.com/appcenter/give-your-crashes-a-context-through-logs-attachments/
But, lately, some of you may have encountered a quite upsetting issue with appcenter builds:
It cannot build C#9:
The issue lies on the mono side of appcenter, the latest stable build 22.214.171.124 cannot build C#9, it uses msbuild 15:
Trying to compile C#9 code will result numerous errors.
The good news is that the Preview (126.96.36.199) 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 (
- Pre-build (
- Post-build (
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:
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:
Then I saw the light, since it broke the nuget step, why not use Boots AFTER the restore step, in the
Unfortunately, I hit another issue:
So should I quit?
Should I betray the Lord who is my witness and is watching from above?
So I tried a simple custom way to install the mono preview in the pre-build script (
#!/usr/bin/env bash # Download Mono 188.8.131.52 wget https://download.mono-project.com/archive/6.12.0/macos-10-universal/MonoFramework-MDK-184.108.40.206.macos10.xamarin.universal.pkg # Add execution permission sudo chmod +x MonoFramework-MDK-220.127.116.11.macos10.xamarin.universal.pkg # Install Mono 18.104.22.168 sudo installer -pkg MonoFramework-MDK-22.214.171.124.macos10.xamarin.universal.pkg -target /
EDIT Octobre 2021
You currently need a Post-clone script to fix a
NETSDK1005 error on iOS (
/Users/runner/hostedtoolcache/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1005: Assets file '/Users/runner/work/1/s/XXXX/XXXX/obj/project.assets.json' doesn't have a target for 'netstandard2.0'. Ensure that restore has run and that you have included 'netstandard2.0' in the TargetFrameworks for your project. [/Users/runner/work/1/s/XXXX/XXXX/XXXX.csproj]
So add also a
appcenter-post-clone.sh next to your iOS csproj:
#!/usr/bin/env bash echo "Post-clone script executing..." # Update nuget (fix NETSDK1005) sudo nuget update -self
And guess what: