@@ -40,14 +40,54 @@ Find the script for that on the DevDiv Azure DevOps instance, Engineering team,
4040
4141param
4242(
43- [string ] $appiumVersion = ' 2.11.0 ' ,
44- [string ] $windowsDriverVersion = ' 2.12.23 ' ,
45- [string ] $androidDriverVersion = ' 3.7.0 ' ,
46- [string ] $iOSDriverVersion = ' 7.21.0 ' ,
47- [string ] $macDriverVersion = ' 1.17.4 ' ,
43+ [string ] $appiumVersion = ' ' ,
44+ [string ] $windowsDriverVersion = ' ' ,
45+ [string ] $androidDriverVersion = ' ' ,
46+ [string ] $iOSDriverVersion = ' ' ,
47+ [string ] $macDriverVersion = ' ' ,
4848 [string ] $logsDir = ' ../appium-logs'
4949)
5050
51+ # By default, versions should be read from /eng/Versions.props
52+ $getLocation = $PSScriptRoot
53+ $versionPropsPath = [IO.Path ]::Combine($getLocation , ' ..' , ' Versions.props' )
54+
55+ Write-Output " Checking $versionPropsPath for versions..."
56+
57+ if (Test-Path $versionPropsPath )
58+ {
59+ Write-Output " Reading versions from Version.props..."
60+ [xml ]$versionProps = Get-Content $versionPropsPath
61+
62+ $versionPropsAppiumVersion = $versionProps.Project.PropertyGroup.AppiumVersion | Where-Object { $_ -ne $null } | Select-Object - Last 1
63+ if ($versionPropsAppiumVersion -ne $null ) {
64+ $appiumVersion = $versionPropsAppiumVersion
65+ }
66+
67+ $versionPropsWindowsDriverVersion = $versionProps.Project.PropertyGroup.AppiumWindowsDriverVersion | Where-Object { $_ -ne $null } | Select-Object - Last 1
68+ if ($versionPropsWindowsDriverVersion -ne $null ) {
69+ $windowsDriverVersion = $versionPropsWindowsDriverVersion
70+ }
71+
72+ $versionPropsUIAutomator2DriverVersion = $versionProps.Project.PropertyGroup.AppiumUIAutomator2DriverVersion | Where-Object { $_ -ne $null } | Select-Object - Last 1
73+ if ($versionPropsUIAutomator2DriverVersion -ne $null ) {
74+ $androidDriverVersion = $versionPropsUIAutomator2DriverVersion
75+ }
76+
77+ $versionPropsXCUItestDriverVersion = $versionProps.Project.PropertyGroup.AppiumXCUITestDriverVersion | Where-Object { $_ -ne $null } | Select-Object - Last 1
78+ if ($versionPropsXCUItestDriverVersion -ne $null ) {
79+ $iOSDriverVersion = $versionPropsXCUItestDriverVersion
80+ }
81+
82+ $versionPropsMac2DriverVersion = $versionProps.Project.PropertyGroup.AppiumMac2DriverVersion | Where-Object { $_ -ne $null } | Select-Object - Last 1
83+ if ($versionPropsMac2DriverVersion -ne $null ) {
84+ $macDriverVersion = $versionPropsMac2DriverVersion
85+ }
86+ }
87+ else {
88+ throw " The version.props file was not found at path: $versionPropsPath "
89+ }
90+
5191Write-Output " Welcome to the Appium installer"
5292
5393Write-Output " Node version"
@@ -87,11 +127,16 @@ if ($appiumCurrentVersion) {
87127 Write-Output " No Appium version installed"
88128}
89129
130+ # Check if we found a version of appium at all
131+ $missingAppium = [string ]::IsNullOrEmpty($appiumCurrentVersion )
132+
90133# If current version does not match the one we want, uninstall and install the new version
91- if ($appiumCurrentVersion -ne $appiumVersion ) {
92- Write-Output " Uninstalling appium $appiumCurrentVersion "
93- npm uninstall -- logs- dir= $logsDir -- loglevel $npmLogLevel - g appium
94- Write-Output " Uninstalled appium $appiumCurrentVersion "
134+ if ($missingAppium -or ($appiumCurrentVersion -ne $appiumVersion )) {
135+ if (-not $missingAppium ) {
136+ Write-Output " Uninstalling appium $appiumCurrentVersion "
137+ npm uninstall -- logs- dir= $logsDir -- loglevel $npmLogLevel - g appium
138+ Write-Output " Uninstalled appium $appiumCurrentVersion "
139+ }
95140
96141 Write-Output " Installing appium $appiumVersion "
97142 npm install -- logs- dir= $logsDir -- loglevel $npmLogLevel - g appium@$appiumVersion
0 commit comments