param ( [Parameter(Mandatory=$true)][String]$Package, [Parameter(Mandatory=$true)][String]$FileName, [Parameter(Mandatory=$true)][String]$Version, [Parameter(Mandatory=$true)][String]$Operation, [String]$OpenJDKVersion, [String[]]$RequestedAVDs, [String]$AndroidHome ) <# Download and install Android SDK #> Function Invoke-InteractiveProcess([String]$FilePath, [string[]]$ArgumentList) { $startInfo = New-Object System.Diagnostics.ProcessStartInfo $startInfo.FileName = $FilePath $startInfo.Arguments = $ArgumentList $startInfo.UseShellExecute = $false $startInfo.RedirectStandardInput = $true $startInfo.RedirectStandardOutput = $true $startInfo.CreateNoWindow = $true $process = [System.Diagnostics.Process]::Start($startInfo) return $process } # Android helper functions Function Get-AndroidHomeFromRegistry { Write-Host "Android home not specified - getting from registry." $ProgramFilesx86 = [environment]::GetEnvironmentVariable("ProgramFiles(x86)") # if ([Environment]::Is64BitOperatingSystem) # powershell v1 doesn't have is 64 bit flag. if ($ProgramFilesx86) { $androidRegistryKey = "HKLM:\SOFTWARE\Wow6432Node\Android SDK Tools" #Set the default value to use in case the reg key isn't set $path = "$ProgramFilesx86\Android\android-sdk" } else { $androidRegistryKey = "HKLM:\SOFTWARE\Android SDK Tools" #Set the default value to use in case the reg key isn't set $ProgramFiles = [environment]::GetEnvironmentVariable("ProgramFiles") $path = "$ProgramFiles\Android\android-sdk" } if (Test-Path $androidRegistryKey) { $path = (Get-ItemProperty $androidRegistryKey Path).Path } return $path } Function Format-List([string[]]$List) { if ($List.Count -gt 0) { return $List -join ", " } return "(none)" } Function Uninstall-Package ([string]$PackageName, [string]$Version) { Write-Host "`nUninstall requested for package '$PackageName' version $Version" $startTime = Get-Date $installPath = Get-InstallRoot -PackageName $PackageName $currentVersion = Get-CurrentPackageVersion -PackageName $PackageName -InstallPath $installPath $requiredVersion = New-Object System.Version (Get-ThreeDigitVerion -TestVersion $Version) if ($currentVersion -ne $requiredVersion) { Write-Host "- Skipping uninstall, since not installed or installed version does not match" } else { Uninstall-Folder -Path (Join-Path $AndroidHome $installPath) Write-Host "- Done. Elapsed time: $((Get-Date).Subtract($startTime).TotalSeconds) second(s)" } } Function Install-Package ([string]$PackageName, [string]$Operation) { Write-Host "`nInstalling package $PackageName" Write-Host "- Requested version: $Version" $installPath = Get-InstallRoot -PackageName $PackageName if ($Operation -ne "Repair") { $currentVersion = Get-CurrentPackageVersion -PackageName $PackageName -InstallPath $installPath $requiredVersion = New-Object System.Version (Get-ThreeDigitVerion -TestVersion $Version) if ($currentVersion -ge $requiredVersion) { Write-Host "- Nothing to do, since version $currentVersion is already installed" return $true } } $result = $true try { # Kill ADB process to avoid access denied errors Kill-ADB $targetInstallFolder = Join-Path $AndroidHome $installPath if (Test-Path $targetInstallFolder) { # Try to create a temporary folder to back up the existing package folder. We back it up to # another folder in the same parent folder to ensure we have access rights to this folder. # We do this first so we don't waste our time continuing if we don't have access rights. $currentPackageTempPath = Create-TempFolder -Parent $AndroidHome -Reason "backup of existing package" $currentPackageTempPathPackageFolder = Join-Path $currentPackageTempPath $installPath New-Item -ItemType Directory -Path $currentPackageTempPath -ErrorAction SilentlyContinue } $packageTargetFile = Join-Path $PSScriptRoot $FileName # Backup existing package if it exists if (Test-Path $targetInstallFolder) { Move-FolderWithRetry -Path $targetInstallFolder -Destination $currentPackageTempPath -Reason "Moving existing package to temporary folder" $existingPackageBackedUp = $true } # Unzip package to temp folder in android-sdk folder (this is important to get correct permissions) $newPackageTempPath = Create-TempFolder -Parent $AndroidHome -Reason "new package" Unzip-File -Source $packageTargetFile -Destination $newPackageTempPath # If we're installing an Emulator package and there's a package.xml file next to the script that means # we want to add it to the root of the package directory. $packageXmlFileSource = Join-Path $PSScriptRoot "package.xml" if ($PackageName -eq "emulator" -and [System.IO.File]::Exists($packageXmlFileSource)) { Write-Host "Copying emulator package.xml file from $packageXmlFileSource" $packageXmlFileDestFolder = Join-Path $newPackageTempPath $installPath Copy-Item $packageXmlFileSource -Destination $packageXmlFileDestFolder } # Move the correct contents of the zip file to the destination. If the zip file contained a single root # folder, then we copy the contents of that folder. Otherwise we just copy the contents of the zip file. # This is based on the Android SDK Manager logic. $packageSourcePath = $newPackageTempPath $zipContents = Get-ChildItem -Path $newPackageTempPath if ($zipContents -and $zipContents.GetType().Name -eq "DirectoryInfo") { $packageSourcePath = Join-Path $packageSourcePath $zipContents.Name } $packageDestinationPath = Join-Path $AndroidHome $installPath Move-FolderContentsWithRetry -Path $packageSourcePath -Destination $packageDestinationPath -Reason "Moving new package into place" # Make any required updates to source.properties Update-SourceProperties -PackageName $PackageName -InstallPath $installPath $newPackageInstalled = $true } catch { $innerException = Get-InnermostException -Exception $_.Exception Write-Host " - $($innerException.Message)" $result = $false # Output a list of running processes, which can be useful infomation in the case of access denied errors, for example Write-Host "`nRunning processes: $((Get-Process | Select-Object -ExpandProperty processname | Group-Object | % { "$($_.Name) ($($_.Count))" }) -join ", ")" } finally { Write-Host "- Cleaning up..." if ($existingPackageBackedUp -and -not $newPackageInstalled) { # If we succeeded in backing up the existing package, but failed to install the new one, try to move the existing package back. try { Move-FolderContentsWithRetry -Path $currentPackageTempPathPackageFolder -Destination $targetInstallFolder -Reason "Restoring existing package" } catch { $innerException = Get-InnermostException -Exception $_.Exception Write-Host " - WARNING: Restoring existing package failed: $($innerException.Message)" $result = $false # presumably this will already have been set, but good to be sure } } if ($currentPackageTempPath) { Write-Host " - Removing temporary folder created to back up existing package" Remove-Folder $currentPackageTempPath } if ($newPackageTempPath) { Write-Host " - Removing temporary folder created to unzip new package" Remove-Folder $newPackageTempPath } } return $result } Function Get-InstallRoot([string]$PackageName) { # Determines the install root folder from the package name (note this only works for package types we currently care about). if ($PackageName -eq "tools" -or $PackageName -eq "platform-tools" -or $PackageName -eq "emulator") { return $PackageName } if ($PackageName.StartsWith("android-")) { return "platforms\$PackageName" } if ($PackageName.StartsWith("addon-")) { return "add-ons\$PackageName" } $packageNameArray = $PackageName.split("-") if ($PackageName.StartsWith("extra-")) { return "extras\$($packageNameArray[1])\$($packageNameArray[2])" } if ($PackageName.StartsWith("build-tools-")) { return "build-tools\$($packageNameArray[2])" } if ($PackageName.StartsWith("cmdline-tools-")) { return "cmdline-tools\$($packageNameArray[2])" } if ($PackageName.StartsWith("patcher-")) { return "patcher\$($packageNameArray[1])" } if ($PackageName.StartsWith("sys-img-")) { $apiLevel = $packageNameArray[$packageNameArray.Length - 1] $type = $packageNameArray[$packageNameArray.Length - 2] if ($type -eq "android") { $type = "default" } $proc = $packageNameArray[2..($packageNameArray.Length - 3)] -join "-" return "system-images\android-$apiLevel\$type\$proc" } throw "Unknown package type: $PackageName" } Function Uninstall-Folder([string]$Path) { if (-not [System.IO.Directory]::Exists($Path)) { Write-Host "- WARNING: Path '$Path' does not exist or is not a directory." return } Write-Host "- Uninstalling folder $Path" Remove-Folder -Path $Path $parentPath = [System.IO.Directory]::GetParent($Path) while ((Get-ChildItem $parentPath -force).Count -eq 0) { Write-Host "- Removing empty folder $parentPath" Remove-Folder -Path $parentPath $parentPath = [System.IO.Directory]::GetParent($parentPath) } } Function Remove-Folder([string]$Path) { Remove-Item $Path -Recurse -Force -ErrorAction SilentlyContinue -ErrorVariable ErrorOut if ($ErrorOut) { # If it fails, it could be because of long paths. Fall back to ROBOCOPY trick # (which empties the directory, then we have to delete it again). $exception = Get-InnermostException -Exception $ErrorOut.Exception[0] Write-Host " - Removing folder '$Path' failed with error: $($exception.message)" Write-Host " - Trying again using ROBOCOPY." $emptyFolder = Create-TempFolder -Parent ([System.IO.Path]::GetTempPath()) robocopy $emptyFolder $path /MIR Remove-Item $Path -Recurse -Force -ErrorAction SilentlyContinue Remove-Item $emptyFolder -Recurse -Force -ErrorAction SilentlyContinue } } Function Update-SourceProperties([string]$PackageName, [string]$InstallPath) { # Some packages (like HAXM) don't include source.properties, so we write it out with enough information # that we don't try to update it again (version) and SDK Manager recognizes it. $sourcePropertiesPath = Join-Path $AndroidHome (Join-Path $InstallPath "source.properties") if (-not (Test-Path $sourcePropertiesPath)) { # When writing out Pkg.Revision for an addon package, we have probably been passed a version in the form "x.0.0" # (because we get passed a version in the same form as used for the Willow package, to keep Willow authoring simple). # However, Android SDK expects just a single number. So tweak that here. $packageRevision = $Version if ($PackageName.StartsWith("addon-") -and $packageRevision.EndsWith(".0.0")) { $packageRevision = $packageRevision.Split(".")[0] } Write-Host "- Writing Pkg.Revision=$packageRevision to source.properties" Add-Content $sourcePropertiesPath "Pkg.Revision=$packageRevision" # Determine if there are other properties we need to add for this package $packageNameArray = $PackageName.split("-") if ($packageNameArray[0] -eq "addon") { # For 'addon' packages, need to include AndroidVersion.ApiLevel, Addon.NameId and Addon.VendorId Add-SourceProperty -SourcePropertiesPath $sourcePropertiesPath -PropertyName "Addon.NameId" -PropertyValue $packageNameArray[1] Add-SourceProperty -SourcePropertiesPath $sourcePropertiesPath -PropertyName "Addon.VendorId" -PropertyValue $packageNameArray[2] Add-SourceProperty -SourcePropertiesPath $sourcePropertiesPath -PropertyName "AndroidVersion.ApiLevel" -PropertyValue $packageNameArray[3] } ElseIf ($packageNameArray[0] -eq "extra") { # For 'extra' packages, need to include Extra.VendorId if it isn't android $vendorId = $packageNameArray[1] if ($vendorId -ne "android") { Add-SourceProperty -SourcePropertiesPath $sourcePropertiesPath -PropertyName "Extra.VendorId" -PropertyValue $packageNameArray[1] } } } # The SDK Manager overwrites source.properties even if the package contains it. Usually what's in the package # is all we need, but sometimes it contains properties that confuse the SDK Manager (meaning it detects the # package as broken). Remove those if needed. if ($PackageName.StartsWith("sys-img")) { # For system images, need to remove Addon.VendorId $sourceProperties = (Get-Content $sourcePropertiesPath) -join "`n" $propertyToRemove = "Addon.VendorId" $removePropertyRegex = "$propertyToRemove=.+" $match = ([regex]::Matches($sourceProperties, $removePropertyRegex)) if ($match -and $match[0].Groups) { Write-Host "- Removing $($match[0].Groups[0].Value) from source.properties" $index = $match[0].Groups[0].Index $length = $match[0].Groups[0].Length + 1 # add 1 to remove line break $sourceProperties = $sourceProperties.remove($index,$length) } Set-Content -Path $sourcePropertiesPath -Value $sourceProperties } } Function Add-SourceProperty([string]$SourcePropertiesPath, [string]$PropertyName, [string]$PropertyValue) { Write-Host "- Writing $PropertyName=$PropertyValue to source.properties" Add-Content $sourcePropertiesPath "$PropertyName=$PropertyValue" } Function Get-CurrentPackageVersion([string]$PackageName, [string]$InstallPath) { Write-Host("Getting version of $PackageName with install path $InstallPath") $sourcePropertiesPath = Join-Path $AndroidHome (Join-Path $InstallPath "source.properties") if (Test-Path $sourcePropertiesPath) { $sourceProperties = Get-Content $sourcePropertiesPath $packageRevisionRegex = 'Pkg.Revision=([0-9.]+)' $packageRevision = ([regex]::Matches($sourceProperties, $packageRevisionRegex)) $packageRevision = If ($packageRevision -and $packageRevision[0].Groups) {$packageRevision[0].Groups[1].Value} Else {"0.0.0"} # Ensure we have 3 numbers $packageRevision = Get-ThreeDigitVerion -TestVersion $packageRevision Write-Host "- Currently installed version: $packageRevision" } else { Write-Host "- Not currently installed" $packageRevision = "0.0.0" } return New-Object System.Version $packageRevision } Function Get-ThreeDigitVerion([string]$TestVersion) { $versionArray = $TestVersion.split(".") while ($versionArray.Count -lt 3) { $versionArray += "0" } return $versionArray -join "." } Function Unzip-File([String]$Source, [String]$Destination) { $startTime = Get-Date Write-Host "- Expanding '$Source' to '$Destination'"; if ($PSVersionTable.PSVersion.Major -ge 3) { # Experience has shown that ZipFile.ExtractToDirectory() will sometimes fail because a target file gets locked # (by anti-virus software, typically). So we roll our own, retrying on failure. Add-Type -assembly "System.IO.Compression.FileSystem" $zipArchive = [System.IO.Compression.ZipFile]::OpenRead($Source) foreach ($zipArchiveEntry in $zipArchive.Entries) { $entryDestinationFilePath = [System.IO.Path]::Combine($Destination, $zipArchiveEntry.FullName) $entryDirectory = [System.IO.Path]::GetDirectoryName($entryDestinationFilePath) # Create the directory for this entry if (!(Test-Path $entryDirectory)) { New-Item -ItemType Directory -Path $entryDirectory | Out-Null } # If this entry is a file (as opposed to a directory), extract it if(!$entryDestinationFilePath.EndsWith("\") -and !$entryDestinationFilePath.EndsWith("/")) { Extract-ToFileWithRetry -ZipArchiveEntry $zipArchiveEntry -EntryDestinationFilePath $entryDestinationFilePath } } } else { # Failure because of locked files does not seem to be a problem with this approach, but it is *really* slow, so # we only use it if we have to. $shell = New-Object -com shell.application $zip = $shell.NameSpace($Source) $dest = $shell.NameSpace($Destination) # Option flags 4: No progress box, 16: Click Yes to All, 512: Don't Confirm new Dir, 1024: Suppress error UI $dest.CopyHere($zip.Items(), 4 + 16 + 512 + 1024) } Write-Host "- Expand took $((Get-Date).Subtract($startTime).TotalSeconds) second(s)" } Function Extract-ToFileWithRetry($ZipArchiveEntry, $EntryDestinationFilePath) { $i = 0 do { try { [System.IO.Compression.ZipFileExtensions]::ExtractToFile($ZipArchiveEntry, $EntryDestinationFilePath, $true); return } catch { Write-Host " - $($_.Exception.Message)" Write-Host " - Retrying." Start-Sleep -Milliseconds 1000 $i++ } } until ($i -ge 30) #30 seconds have passed and it's still failing. Try one last time without #catching the error so it gets thrown [System.IO.Compression.ZipFileExtensions]::ExtractToFile($ZipArchiveEntry, $EntryDestinationFilePath, $true); } Function Create-TempFolder($Parent, $Reason) { if (-not $Parent) { $Parent = [System.IO.Path]::GetTempPath() } # Passing a max length of 5, since that is the length of the shortest target folder ("tools"), so that our temp # path is never longer than the target path (so we don't introduce unnecessary max path problems) [string]$dirName = Get-RandomFileName -MaxLength 5 $targetTempPath = Join-Path $Parent $dirName if ($Reason) { Write-Host "- Creating temporary folder '$targetTempPath' for $Reason" } $createdTempPath = New-Item -ItemType Directory -Path $targetTempPath -ErrorAction SilentlyContinue -ErrorVariable ErrorOut if (-not $createdTempPath) { throw $ErrorOut.Exception } return $createdTempPath } Function Get-RandomFileName($MaxLength) { $randomFilename = [System.IO.Path]::GetFileNameWithoutExtension([System.IO.Path]::GetRandomFileName()) if ($MaxLength -and $randomFilename.Length -gt $MaxLength) { $randomFilename = $randomFilename.Substring(0, $MaxLength) } return $randomFilename } Function Move-FolderContentsWithRetry($Path, $Destination, $Reason) { $i = 0 do { try { Move-FolderContents -Path $Path -Destination $Destination -Reason $Reason return } catch { Write-Host " - $($_.Exception.Message)" Write-Host " - Retrying." $i++ } } until ($i -ge 30) #30 seconds have passed and it's still failing. Try one last time without #catching the error so it gets thrown Move-FolderContents -Path $Path -Destination $Destination -Reason $Reason } Function Move-FolderContents($Path, $Destination, $Reason) { Write-Host "- $($Reason): Moving folder contents from '$Path' to '$Destination'" # Wait a second before trying to move a folder's contents, to help ensure previous actions are fully processed. Start-Sleep -Milliseconds 1000 if (!(Test-Path $Destination)) { New-Item -ItemType Directory -Path $Destination -ErrorAction SilentlyContinue -ErrorVariable ErrorOut if ($ErrorOut) { throw $ErrorOut.Exception } } Get-ChildItem -Path $Path | Move-Item -Destination $Destination -ErrorAction SilentlyContinue -ErrorVariable ErrorOut if ($ErrorOut) { throw $ErrorOut.Exception } } Function Move-FolderWithRetry($Path, $Destination, $Reason) { $i = 0 do { try { Move-Folder -Path $Path -Destination $Destination -Reason $Reason return } catch { Write-Host " - $($_.Exception.Message)" Write-Host " - Retrying." $i++ } } until ($i -ge 30) #30 seconds have passed and it's still failing. Try one last time without #catching the error so it gets thrown Move-Folder -Path $Path -Destination $Destination -Reason $Reason } Function Move-Folder($Path, $Destination, $Reason) { Write-Host "- $($Reason): Moving folder '$Path' to '$Destination'" # Wait a second before trying to move a folder, to help ensure previous actions are fully processed. Start-Sleep -Milliseconds 1000 if (!(Test-Path $Destination)) { New-Item -ItemType Directory -Path $Destination -ErrorAction SilentlyContinue -ErrorVariable ErrorOut if ($ErrorOut) { throw $ErrorOut.Exception } } Move-Item -Path $Path -Destination $Destination -ErrorAction SilentlyContinue -ErrorVariable ErrorOut if ($ErrorOut) { throw $ErrorOut.Exception } } Function Get-InnermostException($Exception) { if ($Exception.InnerException -and $Exception.InnerException -ne $Exception) { return Get-InnermostException -Exception $Exception.InnerException } return $Exception } Function Kill-ADB { # We need to kill adb process before installing packages, otherwise it can cause an access violation, # and after installing, otherwise it can cause the setup process to stop responding. Also, need to have -erroraction # silentlycontinue, otherwise we'll get an error when adb doesn't exist. $processAdb = Get-Process adb -erroraction silentlycontinue if ($processAdb) { Write-Host "- Stopping ADB process" $processAdb.Kill() } } Function Get-AVDConfiguration([String]$FilePath) { $result = @{} if (Test-Path $FilePath) { ForEach ($pair in (Get-Content $FilePath) -split "`n") { $pair = $pair -split "=" if ($pair.Count -eq 2) { $result[$pair[0]] = $pair[1] } } } return $result } Function Set-AVDConfiguration([String]$FilePath, [Hashtable]$configHashtable) { Remove-Item $FilePath ForEach ($key in $configHashtable.Keys | Sort-Object) { $keyValuePair = "$key=$($configHashtable[$key])" Add-Content $FilePath $keyValuePair } } Function Get-AVDPath([string]$AVDName, [string]$AndroidBatch) { $packageRegex = "Path: ((?:.*)\\$AVDName.avd)" [array]$avdListArray = & $AndroidBatch list avd $avdListString = ($avdListArray -join "`n") $availablePackages = [regex]::Matches($avdListString, $packageRegex) if ($availablePackages.Count -eq 0) { return $null; } return $availablePackages[0].Groups[1]; } Function Create-AVD([string]$AndroidBatch, [string]$Name, [string]$ABI, [string]$Target, [hashtable]$ConfigurationOptions) { if (-not $Name -or -not $ABI -or -not $Target) { return } Write-Host "- Creating AVD '$Name'" $processArgs = @("create avd", "-n $Name", "-t $Target", "-b $ABI", "--sdcard 512M", "--force") # Create the AVD $process = Invoke-InteractiveProcess ` -FilePath "$AndroidBatch" ` -ArgumentList $processArgs Write-Host " - Command: ""$AndroidBatch"" $processArgs" while (-not $process.StandardOutput.EndOfStream) { # Answer 'no' to: Do you wish to create a custom hardware profile [no] $firstChar = $process.StandardOutput.Peek() if ($firstChar -eq 68) { $process.StandardInput.WriteLine("no") } $line = $process.StandardOutput.ReadLine() Write-Host " - $line" } Cleanup -Process $process $avdPath = Get-AVDPath -AVDName $Name -AndroidBatch $AndroidBatch if ($avdPath) { $avdConfigFile = "$avdPath\config.ini" if (Test-Path $avdConfigFile) { $configHashtable = Get-AVDConfiguration $avdConfigFile foreach ($key in $ConfigurationOptions.Keys) { $configHashtable[$key] = $ConfigurationOptions[$key] } Set-AVDConfiguration $avdConfigFile $configHashtable Write-Host " - Updating AVD '$Name' to the following hardware config:$([Environment]::NewLine)" Get-Content $avdConfigFile Write-Host "$([Environment]::NewLine)" } } } ################################################################################ #Xamarin methods - separated to invoke the new avdmanager instead of android.bat Function Get-JavaHome { Write-Host "Getting JDK value." #try to locate private Eclipse Foundation JDK 8 $javaHome = Get-OpenJDK "Android" "jdk" if(($javaHome -ne $null) -and (Test-Path "$javaHome")) { Write-Host("Detected OpenJDK at $javaHome") return $javaHome } #try to find Microsoft OpenJDK 11 # Disabled until all installation processes run under JDK 11 #$javaHome = Get-OpenJDK "Microsoft" "" #if(($javaHome -ne $null) -and (Test-Path "$javaHome")) #{ # Write-Host("Detected OpenJDK at $javaHome") # return $javaHome #} Write-Host("Default OpenJDK distributions not located.") #fallback on Oracle JDK - two ways $javaHome = (Get-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\JavaSoft\Java Development Kit\1.8" -Name JavaHome -ErrorAction SilentlyContinue -ErrorVariable jdkError).JavaHome if(($javaHome -ne $null) -and (Test-Path "$javaHome")) { Write-Host("Falling back on 64bit Oracle JDK in WOW6432Node at $javaHome") return $javaHome } else { Write-Host("OracleJDK detection for 64bit failed with: $jdkError") $javaHome = (Get-ItemProperty -Path "HKLM:\SOFTWARE\JavaSoft\Java Development Kit\1.8" -Name JavaHome -ErrorAction SilentlyContinue -ErrorVariable jdkError).JavaHome if(($javaHome -ne $null) -and (Test-Path "$javaHome")) { Write-Host("Falling back on 32bit Oracle JDK at $javaHome") return $javaHome } else { Write-Host("OracleJDK detection for 32bit failed with: $jdkError") #if no valid JDK at any location, return an error Write-Host("Error: No JDK detected. Please do a repair install or install JDK manually") exit 3 } } } Function Get-OpenJDK ([string]$pathVendor, [string]$subPathVendor){ $Arch = (Get-WmiObject Win32_OperatingSystem).OSArchitecture if ($Arch -like '64*') { $ProgramFiles=[Environment]::GetEnvironmentVariable("ProgramW6432") Write-Host("Using 64-bit Program Files at $ProgramFiles") } else { $ProgramFiles=[Environment]::GetEnvironmentVariable("ProgramFiles") Write-Host("Using 32-bit Program Files at $ProgramFiles") } $Versions = New-Object System.Collections.Generic.List[System.Object] $rootPathAndroid = Join-Path -Path $ProgramFiles -ChildPath $pathVendor $rootPath = Join-Path -Path $rootPathAndroid -ChildPath $subPathVendor if (Test-Path $rootPath) { $jdkPaths = (Get-ChildItem -Path $rootPath | ?{ $_.PSIsContainer } | Select -expand Name) foreach ($path in $jdkPaths) { if($path -match '^jdk-(?(?:(\d+)\.)?(?:(\d+)\.)?(?:(\d+)\.\d+))(?:-.*)') { $Versions.Add($Matches.Ver) } } $OpenJDKVersion = $Versions | Sort-Object | Select-Object -Last 1 $filteredJdkFolder = $jdkPaths | ?{ $_ -match $OpenJDKVersion } | Select-Object -Last 1 $filteredJdkPath = Get-ChildItem -Path (Join-Path -Path $rootPath -ChildPath $filteredJdkFolder) -Include "jre" -Directory -Recurse | %{$_.Parent.FullName} | Select-Object -First 1 return $filteredJdkPath } else { Write-Host("$rootPath is not a valid location on this system") } } Function Get-AVDPath-Xamarin([string]$AVDName, [string]$AvdManager) { $packageRegex = "Path: ((?:.*)\\$AVDName.avd)" [array]$avdListArray = & $AvdManager list avd $avdListString = ($avdListArray -join "`n") $availablePackages = [regex]::Matches($avdListString, $packageRegex) if ($availablePackages.Count -eq 0) { return $null; } return $availablePackages[0].Groups[1]; } Function Create-AVD-Xamarin([string]$AvdManager, [string]$Name, [string]$ABI, [string]$Target, [string]$Chipset, [hashtable]$ConfigurationOptions) { if (-not $Name -or -not $ABI -or -not $Target -or -not $Chipset) { Write-Host "Missing parameters passed to AVD creation method; AVD could not be created: `n" + ` "* Name: $Name `n" + ` "* ABI: $ABI `n" + ` "* Target: $Target `n" + ` "* Chipset: $Chipset " return } #Command is in the form of: #avdmanager -v create avd -n NAME -k “system-image;android-27;google_apis;x86” -c 512M -f $SdkId = "`"system-images;$Target;$ABI;$Chipset`"" Write-Host "- Creating AVD '$Name'" $processArgs = @("-v", "create avd", "-n $Name", "-k $SdkId", "-c 512M", "-f") # Create the AVD $process = Invoke-InteractiveProcess ` -FilePath "$AvdManager" ` -ArgumentList $processArgs Write-Host " - Command: ""$AvdManager"" $processArgs" while (-not $process.StandardOutput.EndOfStream) { # Answer 'no' to: Do you wish to create a custom hardware profile [no] $firstChar = $process.StandardOutput.Peek() if ($firstChar -eq 68) { $process.StandardInput.WriteLine("no") } $line = $process.StandardOutput.ReadLine() Write-Host " - $line" } Cleanup -Process $process $avdPath = Get-AVDPath-Xamarin -AVDName $Name -AvdManager $AvdManager if ($avdPath) { $avdConfigFile = "$avdPath\config.ini" if (Test-Path $avdConfigFile) { $configHashtable = Get-AVDConfiguration $avdConfigFile foreach ($key in $ConfigurationOptions.Keys) { $configHashtable[$key] = $ConfigurationOptions[$key] } Set-AVDConfiguration $avdConfigFile $configHashtable Write-Host " - Updating AVD '$Name' to the following hardware config:$([Environment]::NewLine)" Get-Content $avdConfigFile Write-Host "$([Environment]::NewLine)" } } } # End of Xamarin helper methods ################################################################################ Function Get-CannotInstallHaxmReason { $PF_VIRT_FIRMWARE_ENABLED = 21 if (-not (Get-IsProcessorFeaturePresent $PF_VIRT_FIRMWARE_ENABLED)) { return "Intel HAXM requires hardware virtualization, which is not available. This could be because:`n" + ` "* Your hardware does not support hardware virtualization.`n" + ` "* Hardware virtualization is not enabled in your BIOS.`n" + ` "* You are running in a virtual machine.`n" + ` "* Hyper-V or DeviceGuard is running." } $ProcessorManufacturer = (Get-Item HKLM:\HARDWARE\DESCRIPTION\System\CentralProcessor\0).GetValue("VendorIdentifier") if ($ProcessorManufacturer -ne "GenuineIntel") { return "Intel HAXM requires an Intel processor. This machine reports the manufacturer as '$ProcessorManufacturer'." } $PF_NX_ENABLED = 12 if (-not (Get-IsProcessorFeaturePresent $PF_NX_ENABLED)) { return "Intel HAXM requires the Execute Disable bit enabled. It is either not supported by your hardware, or not enabled in your BIOS." } return $null } Function Get-IsProcessorFeaturePresent([uint32] $processorFeature) { $assemblyName = New-Object System.Reflection.AssemblyName("Kernel32Lib") $assembly = [AppDomain]::CurrentDomain.DefineDynamicAssembly($assemblyName, "Run") $module = $assembly.DefineDynamicModule("Kernel32Lib", $False) $type = $module.DefineType("Kernel32", "Public, Class") $method = $type.DefineMethod( "IsProcessorFeaturePresent", "Public, Static", [Bool], [Type[]] @([uint32])) $ctor = [Runtime.InteropServices.DllImportAttribute].GetConstructor(@([String])) $attr = New-Object Reflection.Emit.CustomAttributeBuilder $ctor, @("kernel32.dll") $method.SetCustomAttribute($attr) $kernel32 = $type.CreateType() return $kernel32::IsProcessorFeaturePresent($processorFeature) } Function Get-IsHaxmInstalled { $HaxmServiceInfo = Get-Service -Name IntelHaxm -ErrorAction SilentlyContinue return [boolean]$HaxmServiceInfo } Function Cleanup([System.Diagnostics.Process]$Process) { # We need to kill adb process after installing packages, otherwise it can cause the setup proces to stop responding. # need to have -erroraction silentlycontinue, otherwise we'll get an error when adb doesn't exist. $processAdb = Get-Process adb -erroraction silentlycontinue if ($processAdb) { $processAdb.Kill() } if (!$Process.HasExited) { $Process.CloseMainWindow() } $Process.Dispose() } # INPUT: # [String]$Package, # [String]$FileName, # [String]$Version, # [String]$Operation, # [String[]]$RequestedAVDs, # [String]$AndroidHome # Get Start Time $startDTM = (Get-Date) $sdkInstallLogMessage = "AndroidSDKInstall: -Package $Package -FileName $FileName -Version $Version -Operation $Operation" if ($RequestedAVDs) { $sdkInstallLogMessage += " -RequestedAVDs $RequestedAVDs" } Write-Host $sdkInstallLogMessage Write-Host "Android SDK Install starting ..." if (-not $AndroidHome) { $AndroidHome = Get-AndroidHomeFromRegistry if (!$AndroidHome) { Write-Host "Error: No Android SDK detected." exit 3 } } $haxmPackage = "extra-intel-Hardware_Accelerated_Execution_Manager" $sdkToolsPackage = "tools" $cmdLineToolsPackage = "cmdline-tools-5.0" Write-Host "AndroidHome: $AndroidHome" Write-Host "Windows version: $([System.Environment]::OSVersion.Version) ($((Get-WmiObject -Class Win32_OperatingSystem -ea 0).OSArchitecture))" Write-Host "PowerShell version: $($PSVersionTable.PSVersion)" if (!$PSScriptRoot) { $PSScriptRoot = Split-Path $script:MyInvocation.MyCommand.Path } if ($Operation -eq "Uninstall") { # Uninstall will remove the Android SDK package if it is the expected version, but it does't uninstall HAXM or delete AVDs Uninstall-Package -PackageName $Package -Version $Version exit 0 } $haxmRequested = $Package -eq $haxmPackage $skipHaxmReason = $null if ($haxmRequested) { # Don't try to download or install HAXM if this machine doesn't support it $skipHaxmReason = Get-CannotInstallHaxmReason if (-not $skipHaxmReason -and $Operation -ne "Repair" -and (Get-IsHaxmInstalled)) { # If HAXM is already installed, don't try to download it (that is, don't ask Android SDK # to "install" it), unless we're doing a repair. $skipHaxmReason = "Intel HAXM is already installed." } } $startTime = Get-Date if ($haxmRequested -and $skipHaxmReason) { Write-Host "`nSkipping package $($haxmPackage): $skipHaxmReason" } else { $result = Install-Package -PackageName $Package -Operation $Operation # Kill ADB process to prevent the setup becoming unresponsive Kill-ADB if ($result -eq $false) { Write-Host "`nError: The package failed to install" exit 1 } } Write-Host "`nAndroid SDK package successfully updated" Write-Host "Elapsed time: $((Get-Date).Subtract($startTime).TotalSeconds) second(s)" if ($haxmRequested -and -not $skipHaxmReason) { # Since "installing" HAXM using the Android SDK just downloads the installer, we now have to run it. # But only if it isn't already installed, or repair was requested. $haxmPath = "$AndroidHome\extras\intel\Hardware_Accelerated_Execution_Manager" Write-Host "`nRunning Intel HAXM installer..." $haxmInstallProcess = Start-Process -WorkingDirectory $haxmPath -FilePath silent_install.bat -Wait -PassThru -WindowStyle Hidden -ArgumentList $("-log", "output.log") -ErrorAction SilentlyContinue # Might be null if Android SDK Manager install process above failed for some reason if ($haxmInstallProcess) { # Write content of HAXM installer output to our log, ignoring blank lines and start and end times $haxmLog = Get-Content $haxmPath\output.log -ErrorAction SilentlyContinue $processedHaxmLog = "" if ($haxmLog) { ForEach ($haxmLogLine in $haxmLog) { if ($haxmLogLine.StartsWith("=== Logging stopped")) { break } if ($haxmLogLine -and -not $haxmLogLine.StartsWith("==")) { if (-not $processedHaxmLog) { $processedHaxmLog = ">> $haxmLogLine" } else { $processedHaxmLog = $processedHaxmLog + "`n>> $haxmLogLine" } } } } if ($processedHaxmLog) { Write-Host "Intel HAXM installer log:" Write-Host $processedHaxmLog } if ($haxmInstallProcess.ExitCode -eq 0) { Write-Host "Intel HAXM install successful." } else { Write-Host "Intel HAXM install failed." } } } # If specific AVDs are requested, create them if they don't already exist if ($RequestedAVDs) { Write-Host "Creating requested AVDs:" $configurationOptions = @{"avd.ini.encoding" = "UTF-8"; "disk.dataPartition.size" = "800M"; "hw.accelerometer" = "yes"; "hw.audioInput" = "yes"; "hw.audioOutput" = "yes"; "hw.battery" = "yes"; "hw.camera.back" = "emulated"; "hw.camera.front" = "emulated"; "hw.dPad" = "no"; "hw.gps" = "yes"; "hw.gpu.enabled" = "yes"; "hw.gpu.mode" = "host"; "hw.initialOrientation" = "Portrait"; "hw.keyboard" = "yes"; "hw.lcd.density" = "480"; "hw.mainKeys" = "yes"; "hw.ramSize" = "512"; "hw.sdCard" = "yes"; "hw.sensors.orientation" = "yes"; "hw.sensors.proximity" = "yes"; "hw.trackBall" = "yes"; "runtime.network.latency" = "none"; "runtime.network.speed" = "full"; "sdcard.size" = "512M"; "showDeviceFrame" = "yes"; "skin.dynamic" = "no"; "tag.display" = "Google APIs"; "tag.id" = "google_apis"; "vm.heapSize" = "64"} #Check for tools versions so we know what script to call $sdkToolsInstallPath = Get-InstallRoot -PackageName $sdkToolsPackage $sdkToolsVersion = Get-CurrentPackageVersion -PackageName $sdkToolsPackage -InstallPath $sdkToolsInstallPath $cmdLineToolsInstallPath = Get-InstallRoot -PackageName $cmdLineToolsPackage $cmdLineToolsVersion = Get-CurrentPackageVersion -PackageName $cmdLineToolsPackage -InstallPath $cmdLineToolsInstallPath #Get JDK location so we can use it to set JAVA_HOME later Write-Host("Getting JDK location") $JavaHome = Get-JavaHome if ($cmdLineToolsVersion.Major -ge 5) { Write-Host "$cmdLineToolsPackage $sdkToolsVersion is 5 or greater - using new avdmanager" # set JAVA_HOME for process level [environment]::SetEnvironmentVariable("JAVA_HOME", $JavaHome, [System.EnvironmentVariableTarget]::Process) $avdManager = Join-Path $AndroidHome (Join-Path $cmdLineToolsInstallPath "bin\avdmanager.bat") if (-not (Test-Path $avdManager)) { Write-Host "Error: Unable to create AVDs - $avdManager not found" exit 2 } # If we're not repairing, only create AVDs that don't already exist if ($Operation -ne "Repair") { [array]$existingAVDs = & $avdManager list avd -c } ForEach ($avd in $RequestedAVDs) { $avd = $avd.split("\") $deviceType = $avd[0] #ex: phone $avdAbi = $avd[1] #ex: google_apis $avdTarget = $avd[3] #ex: android-27 $avdChipset = $avd[4] #ex: x86 $avdName = $avd[5] Write-Host "Looking for AVD '$avdName' ..." if ($Operation -ne "Repair" -and $existingAVDs -icontains $avdName) { Write-Host "- Skipping creating AVD '$avdName' as it already exists" } else { $configurationOptions["skin.name"] = $avd[2] $configurationOptions["skin.path"] = $avd[2] Create-AVD-Xamarin ` -AvdManager $avdManager ` -Name $avdName ` -ABI $avdAbi ` -Target $avdTarget ` -Chipset $avdChipset ` -ConfigurationOptions $configurationOptions } } } #Cordova and old SDK tools code path follows elseif ($sdkToolsVersion.Major -le 26) { Write-Host "SDK tools $sdkToolsVersion is less than 26 - falling back on android.bat" # If JAVA_HOME is not set for system or is invalid, set it for MDD. $java_home = [Environment]::GetEnvironmentVariable("JAVA_HOME", "Machine") if (($java_home -eq $null) -Or (-not (Test-Path $java_home))) { Write-Host("Setting JAVA_HOME environment variable") [environment]::SetEnvironmentVariable("JAVA_HOME", $JavaHome, [System.EnvironmentVariableTarget]::Machine) } else { Write-Host("Found valid JAVA_HOME environment variable with value $java_home") } # Set JAVA_HOME for process level as the following scripts look for JAVA_HOME. [environment]::SetEnvironmentVariable("JAVA_HOME", $JavaHome, [System.EnvironmentVariableTarget]::Process) $androidBatch = Join-Path $AndroidHome "tools\android.bat" if (-not (Test-Path $androidBatch)) { Write-Host "Error: Unable to create AVDs - $androidBatch not found" exit 2 } # If we're not repairing, only create AVDs that don't already exist if ($Operation -ne "Repair") { [array]$existingAVDs = & $androidBatch list avd -c } ForEach ($avd in $RequestedAVDs) { # Each AVD should be provided in the form device\abi\skin\target\chipset\name (for example, # "phone\google_apis/x86\768x1280\android-23\x86\Android_Accelerated_x86" or "tablet\google_apis/armeabi-v7a\768x1280\android-23\arm") $avd = $avd.split("\") $deviceType = $avd[0] $avdAbi = $avd[1] $avdTarget = $avd[3] $avdChipset = $avd[4] $avdName = "VisualStudio_$($avdTarget)_$($avdChipset)_$deviceType" if ($Operation -ne "Repair" -and $existingAVDs -icontains $avdName) { Write-Host "- Skipping creating AVD '$avdName' as it already exists" } else { $configurationOptions["skin.name"] = $avd[2] $configurationOptions["skin.path"] = $avd[2] Create-AVD ` -AndroidBatch $androidBatch ` -Name $avdName ` -ABI $avdAbi ` -Target $avdTarget ` -ConfigurationOptions $configurationOptions } } } else { Write-Host "Unexpected tools combination - $sdkToolsPackage = $sdkToolsVersion, $cmdLineToolsPackage = $cmdLineToolsVersion" exit 4 } } Write-Host "`nAndroid SDK Install is successful." # Get End Time $endDTM = (Get-Date) Write-Host "Elapsed Time: $(($endDTM-$startDTM).totalseconds) seconds" exit 0 # SIG # Begin signature block # MIInngYJKoZIhvcNAQcCoIInjzCCJ4sCAQExDzANBglghkgBZQMEAgEFADB5Bgor # BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG # KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCCooZGQC6xt/O+B # 9He+oVIgAREQIQfa7hdSet+l3rZG/qCCDYEwggX/MIID56ADAgECAhMzAAACUosz # qviV8znbAAAAAAJSMA0GCSqGSIb3DQEBCwUAMH4xCzAJBgNVBAYTAlVTMRMwEQYD # VQQIEwpXYXNoaW5ndG9uMRAwDgYDVQQHEwdSZWRtb25kMR4wHAYD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