-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathcommon.ps1
62 lines (52 loc) · 1.61 KB
/
common.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
function CmdExists {
param (
[Parameter(Mandatory)]
[string]
$Cmd
)
Get-Command $Cmd -ErrorAction SilentlyContinue
}
function ChooseCmd {
param (
[Parameter(Mandatory)]
[string[]]
$Cmds
)
foreach($cmd in $Cmds) {
if(CmdExists($cmd)) {
return $cmd
}
}
return $Cmds[0]
}
function MsbuildPath {
param (
[string] $Edition,
[string] $Year = "2019"
)
"C:\Program Files (x86)\Microsoft Visual Studio\$Year\$Edition\MSBuild\Current\Bin\MSBuild.exe"
}
function BuildApkAndUiTest {
[string] $msbuild = ChooseCmd(@(
"msbuild",
(MsbuildPath("Enterprise")),
(MsbuildPath("Professional")),
(MsbuildPath("Community"))))
& $msbuild ../$appName.Android/$appName.Android.csproj `
/p:Configuration=$BuildConfiguration `
/t:SignAndroidPackage
& $msbuild ../$uiTestProjName/$uiTestProjName.csproj `
/p:Configuration=$BuildConfiguration
}
# END OF FUNCTIONS #############################################################
if(!$env:ANDROID_HOME) {
$env:ANDROID_HOME = "C:\Program Files (x86)\Android\android-sdk"
}
if(!$env:JAVA_HOME) {
$env:JAVA_HOME = (Get-ChildItem 'C:\Program Files\Android\jdk\*jdk*')[0].FullName
}
[string] $appName = "XamarinPipelineDemo"
[string] $appPackageName = "com.demo.$appName"
[string] $uiTestProjName = "$appName.UITest"
[string] $adb = ChooseCmd(@("adb", "C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe"))
$env:UITEST_APK_PATH = "../$appName.Android/bin/$BuildConfiguration/$appPackageName-Signed.apk"