Build C#9 with AppCenter
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.
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 6.12.0.122 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 (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?
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:
Jean-Marie Alfonsi
I am a freelance developer since 2012 focusing primarly on Xamarin stuff: xamarin ios, xamarin android, xamarin forms.
Share this post
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK