Switch Expand-Archive to 7zip on Windows image generation (#861)

* switch expand-archive to 7zip on windows
This commit is contained in:
Dibir Magomedsaygitov
2020-05-13 08:02:08 +03:00
committed by GitHub
parent ffa2110464
commit 3e9c8e5afc
10 changed files with 37 additions and 17 deletions

View File

@@ -29,4 +29,5 @@ Export-ModuleMember -Function @(
'Test-IsWin19'
'Test-IsWin16'
'Choco-Install'
'Extract-7Zip'
)

View File

@@ -386,3 +386,22 @@ function Test-IsWin16
{
(Get-WinVersion) -match "2016"
}
function Extract-7Zip {
param
(
[Parameter(Mandatory=$true)]
[string]$Path,
[Parameter(Mandatory=$true)]
[string]$DestinationPath
)
Write-Host "Expand archive '$PATH' to '$DestinationPath' directory"
7z.exe x "$Path" -o"$DestinationPath" -y | Out-Null
if ($LASTEXITCODE -ne 0)
{
Write-Host "There is an error during expanding '$Path' to '$DestinationPath' directory"
exit 1
}
}

View File

@@ -66,7 +66,7 @@ $ChromeDriverZipDownloadUrl = "https://chromedriver.storage.googleapis.com/${Chr
$ChromeDriverArchPath = Start-DownloadWithRetry -Url $ChromeDriverZipDownloadUrl -Name $ChromeDriverArchName
Write-Host "Expand Chrome WebDriver archive..."
Expand-Archive -Path $ChromeDriverArchPath -DestinationPath $ChromeDriverPath -Force
Extract-7Zip -Path $ChromeDriverArchPath -DestinationPath $ChromeDriverPath
Write-Host "Setting the environment variables..."
setx ChromeWebDriver "$ChromeDriverPath" /M

View File

@@ -17,7 +17,7 @@ New-Item -Path $CloudFoundryCliPath -ItemType Directory -Force
# Extract the zip archive
Write-Host "Extracting cf cli..."
Expand-Archive -Path $CloudFoundryArchPath -DestinationPath $CloudFoundryCliPath -Force
Extract-7Zip -Path $CloudFoundryArchPath -DestinationPath $CloudFoundryCliPath
# Add cf to path
Add-MachinePathItem $CloudFoundryCliPath

View File

@@ -29,7 +29,7 @@ $EdgeDriverDownloadUrl="https://msedgedriver.azureedge.net/${EdgeDriverLatestVer
$EdgeDriverArchPath = Start-DownloadWithRetry -Url $EdgeDriverDownloadUrl -Name $EdgeDriverArchName
Write-Host "Expand Microsoft Edge WebDriver archive..."
Expand-Archive -Path $EdgeDriverArchPath -DestinationPath $EdgeDriverPath -Force
Extract-7Zip -Path $EdgeDriverArchPath -DestinationPath $EdgeDriverPath
Write-Host "Setting the environment variables..."
setx EdgeWebDriver "$EdgeDriverPath" /M

View File

@@ -45,7 +45,7 @@ $GeckoDriverDownloadUrl = $GeckoDriverWindowsAsset.browser_download_url
$GeckoDriverArchPath = Start-DownloadWithRetry -Url $GeckoDriverDownloadUrl -Name $GeckoDriverArchName
Write-Host "Expand Gecko WebDriver archive..."
Expand-Archive -Path $GeckoDriverArchPath -DestinationPath $GeckoDriverPath -Force
Extract-7Zip -Path $GeckoDriverArchPath -DestinationPath $GeckoDriverPath
Write-Host "Setting the environment variables..."
Add-MachinePathItem -PathItem $GeckoDriverPath

View File

@@ -15,7 +15,7 @@ function Install-GoVersion
[Switch] $addToDefaultPath
)
$latestVersionObject = $refsJson | Where-Object { $_.ref -Match "refs/tags/go$goVersion[./d]*" } | Select-Object -Last 1
$latestVersionObject = $refsJson | Where-Object { $_.ref -Match "refs/tags/go$goVersion[./d]*" } | Select-Object -Last 1
$latestVersion = $latestVersionObject.ref.replace('refs/tags/go','')
# Download the Go zip archive.
@@ -30,7 +30,7 @@ function Install-GoVersion
# Extract the zip archive. It contains a single directory named "go".
Write-Host "Extracting Go $latestVersion..."
$toolDirectory = Join-Path $env:AGENT_TOOLSDIRECTORY "go\$latestVersion"
7z.exe x $goArchPath -o"$toolDirectory" -y | Out-Null
Extract-7Zip -Path $goArchPath -DestinationPath $toolDirectory
# Rename the extracted "go" directory to "x64" for full path "C:\hostedtoolcache\windows\Go\1.14.2\x64\..."
Rename-Item -path "$toolDirectory\go" -newName "x64"

View File

@@ -2,21 +2,21 @@
## File: Install-SeleniumWebDrivers.ps1
## Desc: Install Selenium Web Drivers
################################################################################
$DestinationPath = "$($env:SystemDrive)\";
$DestinationPath = "$($env:SystemDrive)\"
$DriversZipFile = "SeleniumWebDrivers.zip"
Write-Host "Destination path: [$DestinationPath]";
Write-Host "Selenium drivers download and install...";
Write-Host "Destination path: [$DestinationPath]"
Write-Host "Selenium drivers download and install..."
try {
Invoke-WebRequest -UseBasicParsing -Uri "https://seleniumwebdrivers.blob.core.windows.net/seleniumwebdrivers/${DriversZipFile}" -OutFile $DriversZipFile;
Invoke-WebRequest -UseBasicParsing -Uri "https://seleniumwebdrivers.blob.core.windows.net/seleniumwebdrivers/${DriversZipFile}" -OutFile $DriversZipFile
}
catch {
Write-Error "[!] Failed to download $DriversZipFile";
exit 1;
Write-Error "[!] Failed to download $DriversZipFile"
exit 1
}
$TempSeleniumDir = Join-Path $Env:TEMP "SeleniumWebDrivers"
Expand-Archive -Path $DriversZipFile -DestinationPath $Env:TEMP -Force;
Remove-Item $DriversZipFile;
Extract-7Zip -Path $DriversZipFile -DestinationPath $Env:TEMP
Remove-Item $DriversZipFile
$SeleniumWebDriverPath = Join-Path $DestinationPath "SeleniumWebDrivers"
$IEDriverPathTemp = Join-Path $TempSeleniumDir 'IEDriver'
@@ -29,4 +29,4 @@ Move-Item -Path "$IEDriverPathTemp" -Destination $SeleniumWebDriverPath
Write-Host "Setting the environment variables"
setx IEWebDriver "C:\SeleniumWebDrivers\IEDriver" /M;
setx IEWebDriver "C:\SeleniumWebDrivers\IEDriver" /M

View File

@@ -82,6 +82,6 @@ $uri = 'https://ayera.dl.sourceforge.net/project/cobertura/cobertura/2.1.1/cober
$coberturaPath = "C:\cobertura-2.1.1"
$archivePath = Start-DownloadWithRetry -Url $uri -Name "cobertura.zip"
Expand-Archive -Path $archivePath -DestinationPath "C:\"
Extract-7Zip -Path $archivePath -DestinationPath "C:\"
setx COBERTURA_HOME $coberturaPath /M

View File

@@ -22,7 +22,7 @@ Install-Binary -Url $InstallerURI -Name $InstallerName -ArgumentList $ArgumentLi
$mysqlArchPath = Start-DownloadWithRetry -Url $MysqlVersionUrl -Name "mysql.zip"
# Expand the zip
Expand-Archive -Path $mysqlArchPath -DestinationPath "C:\" -Force
Extract-7Zip -Path $mysqlArchPath -DestinationPath "C:\"
# Adding mysql in system environment path
Add-MachinePathItem $mysqlPath