A simple example of using Cake to build Xamarin.Android and Xamarin.iOS projects. Plus, the script runs xUnit tests, and StyleCop.
What the script does:
- Clean the solution and artifacts folder.
- Restore NuGet packages and Xamarin Components.
- Build Android project.
- Build iOS project.
- Run StyleCop.
- Run xUnit tests.
- Write the xUnit tests result and StyleCop output to the artifacts folder.
What's part of the solution:
Cake.Xamarin.Sample.Shared=> A Portable Class Library (PCL) with shared code between Xamarin.Android and Xamarin.iOS.Cake.Xamarin.Sample.Tests=> A PCL with tests over shared code PCL.Cake.Xamarin.Sample.Android=> A Android project that uses the shared code PCL.Cake.Xamarin.Sample.iOS=> A iOS project that uses the shared code PCL.
- xbuild (Linux and OS X) or msbuild (Windows) installed.
- .NET Core, .NET 4.5 or Mono installed.
- Terminal or Powershell.
- Clone the repo and open terminal inside it.
- Run
./build.shin OS X or.\build.ps1on Windows. - Get the outputs on the
artifactsfolder.
- To use a specific Xamarin account to restore Xamarin Components:
./build.sh -ScriptArgs -xamarin_username="youremail@example.com" -xamarin_password="password". - To run a specific Task like build only android or ios:
./build.sh -t Build-Androidor./build.sh -t Build-iOS.