Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Commit

Permalink
Update build.cake
Browse files Browse the repository at this point in the history
  • Loading branch information
jfversluis committed Apr 19, 2023
1 parent a7af960 commit dc3b08a
Showing 1 changed file with 58 additions and 3 deletions.
61 changes: 58 additions & 3 deletions DeviceTests/build.cake
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#addin nuget:?package=Cake.AppleSimulator&version=0.2.0
#addin nuget:?package=Cake.Android.Adb&version=3.2.0
#addin nuget:?package=Cake.Android.AvdManager&version=2.2.0
#addin "nuget:?package=Cake.Android.SdkManager&version=3.0.2"
#addin nuget:?package=Cake.FileHelpers&version=3.3.0
#addin "nuget:?package=Cake.Boots&version=1.1.0.712-preview2"

Expand Down Expand Up @@ -42,6 +43,11 @@ System.Environment.SetEnvironmentVariable("PATH",
$"{ANDROID_HOME}/emulator" + System.IO.Path.PathSeparator +
EnvironmentVariable("PATH"));

string androidSdks = EnvironmentVariable("ANDROID_API_SDKS", "platform-tools,platforms;android-26,platforms;android-27,platforms;android-28,platforms;android-29,build-tools;29.0.3,platforms;android-30,build-tools;30.0.2,platforms;android-32,build-tools;32.0.0,platforms;android-33,build-tools;33.0.2");

Information("ANDROID_API_SDKS: {0}", androidSdks);
string[] androidSdkManagerInstalls = androidSdks.Split(',');

// utils

Task DownloadTcpTextAsync(int port, FilePath filename, Action waitAction = null)
Expand Down Expand Up @@ -136,12 +142,61 @@ Task("test-ios-emu")

// Android tasks

Task("provision-androidsdk")
.Description("Install Xamarin.Android SDK")
.Does(async (ctx) =>
{
Information ("ANDROID_HOME: {0}", ANDROID_HOME);
if(androidSdkManagerInstalls.Length > 0)
{
Information("Updating Android SDKs");
var androidSdkSettings = new AndroidSdkManagerToolSettings {
SkipVersionCheck = true
};
if(!String.IsNullOrWhiteSpace(ANDROID_HOME))
androidSdkSettings.SdkRoot = ANDROID_HOME;
try{
AcceptLicenses (androidSdkSettings);
}
catch(Exception exc)
{
Information("AcceptLicenses: {0}", exc);
}
try{
AndroidSdkManagerUpdateAll (androidSdkSettings);
}
catch(Exception exc)
{
Information("AndroidSdkManagerUpdateAll: {0}", exc);
}
try{
AcceptLicenses (androidSdkSettings);
}
catch(Exception exc)
{
Information("AcceptLicenses: {0}", exc);
}
try{
AndroidSdkManagerInstall (androidSdkManagerInstalls, androidSdkSettings);
}
catch(Exception exc)
{
Information("AndroidSdkManagerInstall: {0}", exc);
}
}
await Boots (Product.XamarinAndroid, releaseChannel);
});
Task("build-android")
.IsDependentOn("provision-androidsdk")
.Does(async () =>
{
// Setup latest Xamarin.Android SDK
await Boots (Product.XamarinAndroid, ReleaseChannel.Stable);
MSBuild(ANDROID_PROJ, c => {
c.Configuration = "Debug"; // needs to be debug so unit tests get discovered
c.Restore = true;
Expand Down

0 comments on commit dc3b08a

Please sign in to comment.