Skip to content

Commit bdc1d88

Browse files
authored
Use the Microsoft Hosted Pool (#3051)
1 parent 8afcbc4 commit bdc1d88

File tree

5 files changed

+34
-101
lines changed

5 files changed

+34
-101
lines changed

.config/dotnet-tools.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@
3636
"api-tools"
3737
],
3838
"rollForward": false
39+
},
40+
"androidsdk.tool": {
41+
"version": "0.18.0",
42+
"commands": [
43+
"android"
44+
],
45+
"rollForward": false
3946
}
4047
}
4148
}

scripts/azure-pipelines-complete-internal.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,9 @@ parameters:
6868
type: object
6969
default:
7070
pool:
71-
name: VSEng-VSMac-Xamarin-Shared
72-
vmImage: VSEng-VSMac-Xamarin-Shared
71+
name: Azure Pipelines
72+
vmImage: macos-14
7373
os: macos
74-
demands:
75-
- macOS.Name -equals Ventura
76-
- macOS.Architecture -equals x64
7774
parameters:
7875
installXcode: false
7976
- name: enableSigning

scripts/azure-pipelines-complete.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,9 @@ parameters:
7474
type: object
7575
default:
7676
pool:
77-
name: MAUI
78-
vmImage: MAUI
77+
name: Azure Pipelines
78+
vmImage: macos-14
7979
os: macos
80-
demands:
81-
- macOS.Name -equals Ventura
82-
- macOS.Architecture -equals x64
8380
parameters:
8481
installXcode: false
8582

scripts/azure-pipelines-tests.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,9 @@ parameters:
4040
type: object
4141
default:
4242
pool:
43-
name: VSEng-VSMac-Xamarin-Shared
44-
vmImage: VSEng-VSMac-Xamarin-Shared
43+
name: Azure Pipelines
44+
vmImage: macos-14
4545
os: macos
46-
demands:
47-
- macOS.Name -equals Ventura
48-
- macOS.Architecture -equals x64
4946
parameters:
5047
installXcode: false
5148

scripts/cake/xharness-android.cake

Lines changed: 21 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#addin nuget:?package=Cake.Android.Adb&version=3.2.0
2-
#addin nuget:?package=Cake.Android.AvdManager&version=2.2.0
3-
41
DirectoryPath ROOT_PATH = MakeAbsolute(Directory("../.."));
52

63
#load "shared.cake"
@@ -27,46 +24,7 @@ if (string.IsNullOrEmpty(TEST_RESULTS)) {
2724
Information("Test Results Directory: {0}", TEST_RESULTS);
2825
CleanDir(TEST_RESULTS);
2926

30-
// set up env
31-
var ANDROID_SDK_ROOT = Argument("android", EnvironmentVariable("ANDROID_SDK_ROOT") ?? EnvironmentVariable("ANDROID_SDK_HOME"));
32-
if (string.IsNullOrEmpty(ANDROID_SDK_ROOT)) {
33-
throw new Exception("Environment variable 'ANDROID_SDK_ROOT' must be set to the Android SDK root.");
34-
}
35-
System.Environment.SetEnvironmentVariable("PATH",
36-
$"{ANDROID_SDK_ROOT}/cmdline-tools/latest/bin" + System.IO.Path.PathSeparator +
37-
$"{ANDROID_SDK_ROOT}/platform-tools" + System.IO.Path.PathSeparator +
38-
$"{ANDROID_SDK_ROOT}/emulator" + System.IO.Path.PathSeparator +
39-
$"{ANDROID_SDK_ROOT}/tools/bin" + System.IO.Path.PathSeparator +
40-
EnvironmentVariable("PATH"));
41-
42-
Information("Android SDK Root: {0}", ANDROID_SDK_ROOT);
43-
Information("PATH: {0}", EnvironmentVariable("PATH"));
44-
45-
var bat = IsRunningOnWindows() ? ".bat" : "";
46-
var exe = IsRunningOnWindows() ? ".exe" : "";
47-
var avdSettings = new AndroidAvdManagerToolSettings {
48-
SdkRoot = ANDROID_SDK_ROOT,
49-
ToolPath = $"{ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/avdmanager{bat}"
50-
};
51-
var adbSettings = new AdbToolSettings {
52-
SdkRoot = ANDROID_SDK_ROOT,
53-
ToolPath = $"{ANDROID_SDK_ROOT}/platform-tools/adb{exe}"
54-
};
55-
var emuSettings = new AndroidEmulatorToolSettings {
56-
SdkRoot = ANDROID_SDK_ROOT,
57-
ToolPath = $"{ANDROID_SDK_ROOT}/emulator/emulator{exe}",
58-
Verbose = true,
59-
ArgumentCustomization = args => args.Append(
60-
"-no-boot-anim " +
61-
"-no-snapshot " +
62-
"-gpu host " +
63-
"-no-audio " +
64-
"-camera-back none " +
65-
"-camera-front none " +
66-
"-qemu -m 2048")
67-
};
68-
69-
AndroidEmulatorProcess emulatorProcess = null;
27+
var usingEmulator = true;
7028

7129
Setup(context =>
7230
{
@@ -80,7 +38,6 @@ Setup(context =>
8038
// determine the device characteristics
8139
{
8240
var working = TEST_DEVICE.Trim().ToLower();
83-
var emulator = true;
8441
var api = 34;
8542
// version
8643
if (working.IndexOf("_") is int idx && idx > 0) {
@@ -93,81 +50,59 @@ Setup(context =>
9350
throw new Exception("Unexpected platform (expected: android) in device: " + TEST_DEVICE);
9451
// device/emulator
9552
if (parts[1] == "device")
96-
emulator = false;
53+
usingEmulator = false;
9754
else if (parts[1] != "emulator" && parts[1] != "simulator")
9855
throw new Exception("Unexpected device type (expected: device|emulator) in device: " + TEST_DEVICE);
9956
// arch/bits
10057
if (parts[2] == "32") {
101-
if (emulator)
58+
if (usingEmulator)
10259
DEVICE_ARCH = "x86";
10360
else
10461
DEVICE_ARCH = "armeabi-v7a";
10562
} else if (parts[2] == "64") {
10663
if (RuntimeInformation.ProcessArchitecture == System.Runtime.InteropServices.Architecture.Arm64)
10764
DEVICE_ARCH = "arm64-v8a";
108-
else if (emulator)
65+
else if (usingEmulator)
10966
DEVICE_ARCH = "x86_64";
11067
else
11168
DEVICE_ARCH = "arm64-v8a";
11269
}
11370
DEVICE_ID = $"system-images;android-{api};google_apis;{DEVICE_ARCH}";
71+
}
11472

115-
// we are not using a virtual device, so quit
116-
if (!emulator)
117-
return;
73+
// we are not using a virtual device, so quit
74+
if (!usingEmulator) {
75+
Information("Using a physical device:");
76+
DotNetTool("android device list");
77+
return;
11878
}
11979

12080
Information("Test Device ID: {0}", DEVICE_ID);
12181

122-
// delete the AVD first, if it exists
123-
Information("Deleting AVD if exists: {0}...", ANDROID_AVD);
124-
try { AndroidAvdDelete(ANDROID_AVD, avdSettings); }
125-
catch { }
126-
12782
// create the new AVD
12883
Information("Creating AVD: {0}...", ANDROID_AVD);
129-
AndroidAvdCreate(ANDROID_AVD, DEVICE_ID, DEVICE_NAME, force: true, settings: avdSettings);
84+
DotNetTool($"android avd create --name \"{ANDROID_AVD}\" --sdk \"{DEVICE_ID}\" --device \"{DEVICE_NAME}\" --force");
13085

131-
// start the emulator
86+
// start the emulator (only wait 5 mins)
13287
Information("Starting Emulator: {0}...", ANDROID_AVD);
133-
emulatorProcess = AndroidEmulatorStart(ANDROID_AVD, emuSettings);
134-
135-
// wait for it to finish booting (4 mins)
136-
var waited = 0;
137-
var interval = 10;
138-
var totalMins = 4;
139-
var total = 60 * totalMins / interval;
140-
while (AdbShell("getprop sys.boot_completed", adbSettings).FirstOrDefault() != "1") {
141-
TakeSnapshot(TEST_RESULTS, $"boot-{waited:000}");
142-
System.Threading.Thread.Sleep(interval * 1000);
143-
Information("Wating {0}/{1} seconds for the emulator to boot up.", waited * interval, total);
144-
if (waited++ > total)
145-
break;
146-
}
88+
DotNetTool($"android avd start --name \"{ANDROID_AVD}\" --gpu guest --wait-boot --no-window --no-snapshot --no-audio --no-boot-anim --camera-back none --camera-front none --timeout 300");
89+
90+
// show running emulator information
91+
Information("Emulator started:");
92+
DotNetTool("android device list");
14793
TakeSnapshot(TEST_RESULTS, "boot-complete");
148-
Information("Waited {0} seconds for the emulator to boot up.", waited);
14994
});
15095

15196
Teardown(context =>
15297
{
153-
TakeSnapshot(TEST_RESULTS, "teardown");
154-
15598
// no virtual device was used
156-
if (emulatorProcess == null)
99+
if (!usingEmulator)
157100
return;
158101

159-
// stop and cleanup the emulator
160-
AdbEmuKill(adbSettings);
161-
162-
System.Threading.Thread.Sleep(5000);
163-
164-
// kill the process if it has not already exited
165-
try { emulatorProcess.Kill(); }
166-
catch { }
102+
TakeSnapshot(TEST_RESULTS, "teardown");
167103

168-
// delete the AVD
169-
try { AndroidAvdDelete(ANDROID_AVD, avdSettings); }
170-
catch { }
104+
// cleanup the emulator
105+
DotNetTool($"android avd delete --name \"{ANDROID_AVD}\"");
171106
});
172107

173108
Task("Default")

0 commit comments

Comments
 (0)