mirror of
https://github.com/actions/runner-images.git
synced 2025-12-12 20:26:49 +00:00
[Windows] Rename and refactor downloading function (#8906)
This commit is contained in:
committed by
GitHub
parent
bfe32a2b12
commit
7dba8776df
@@ -15,7 +15,7 @@ $downloadUrl = Resolve-GithubReleaseAssetUrl `
|
|||||||
-Asset "action-versions.zip"
|
-Asset "action-versions.zip"
|
||||||
|
|
||||||
Write-Host "Download Latest action-versions archive from $downloadUrl"
|
Write-Host "Download Latest action-versions archive from $downloadUrl"
|
||||||
$actionVersionsArchivePath = Start-DownloadWithRetry -Url $downloadUrl -Name "action-versions.zip"
|
$actionVersionsArchivePath = Invoke-DownloadWithRetry $downloadUrl
|
||||||
|
|
||||||
Write-Host "Expand action-versions archive"
|
Write-Host "Expand action-versions archive"
|
||||||
Expand-7ZipArchive -Path $actionVersionsArchivePath -DestinationPath $env:ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE
|
Expand-7ZipArchive -Path $actionVersionsArchivePath -DestinationPath $env:ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ $repoUrl = "https://api.github.com/repos/aliyun/aliyun-cli/releases/latest"
|
|||||||
$installerFileName = "aliyun-cli-windows"
|
$installerFileName = "aliyun-cli-windows"
|
||||||
$assets = (Invoke-RestMethod -Uri $repoUrl).assets
|
$assets = (Invoke-RestMethod -Uri $repoUrl).assets
|
||||||
$downloadUrl = ($assets.browser_download_url -ilike "*aliyun-cli-windows-*-amd64.zip*") | Select-Object -First 1
|
$downloadUrl = ($assets.browser_download_url -ilike "*aliyun-cli-windows-*-amd64.zip*") | Select-Object -First 1
|
||||||
$packagePath = Start-DownloadWithRetry -Url $downloadUrl -Name "$installerFileName.zip"
|
$packagePath = Invoke-DownloadWithRetry $downloadUrl
|
||||||
|
|
||||||
#region Supply chain security - Alibaba Cloud CLI
|
#region Supply chain security - Alibaba Cloud CLI
|
||||||
$fileHash = (Get-FileHash -Path $packagePath -Algorithm SHA256).Hash
|
$fileHash = (Get-FileHash -Path $packagePath -Algorithm SHA256).Hash
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ $androidToolset = (Get-ToolsetContent).android
|
|||||||
# Newer version(s) require Java 11 by default
|
# Newer version(s) require Java 11 by default
|
||||||
# See https://github.com/actions/runner-images/issues/6960
|
# See https://github.com/actions/runner-images/issues/6960
|
||||||
$cmdlineToolsUrl = $androidToolset.commandline_tools_url
|
$cmdlineToolsUrl = $androidToolset.commandline_tools_url
|
||||||
$cmdlineToolsArchPath = Start-DownloadWithRetry -Url $cmdlineToolsUrl -Name "cmdline-tools.zip"
|
$cmdlineToolsArchPath = Invoke-DownloadWithRetry $cmdlineToolsUrl
|
||||||
|
|
||||||
#region Supply chain security
|
#region Supply chain security
|
||||||
$localFileHash = (Get-FileHash -Path $cmdlineToolsArchPath -Algorithm SHA256).Hash
|
$localFileHash = (Get-FileHash -Path $cmdlineToolsArchPath -Algorithm SHA256).Hash
|
||||||
|
|||||||
@@ -7,13 +7,13 @@ $BuildComponentUri = "https://aka.ms/BuildComponentSetup.EN"
|
|||||||
$BuildComponentSignatureThumbprint = "8740DF4ACB749640AD318E4BE842F72EC651AD80"
|
$BuildComponentSignatureThumbprint = "8740DF4ACB749640AD318E4BE842F72EC651AD80"
|
||||||
|
|
||||||
Write-Host "Downloading BizTalk Project Build Component archive..."
|
Write-Host "Downloading BizTalk Project Build Component archive..."
|
||||||
$setupZipFile = Start-DownloadWithRetry -Url $BuildComponentUri -Name "BuildComponentSetup.EN.zip"
|
$zipFile = Invoke-DownloadWithRetry $BuildComponentUri
|
||||||
|
|
||||||
$setupPath = Join-Path $env:TEMP "BizTalkBuildComponent"
|
$setupPath = Join-Path $env:TEMP "BizTalkBuildComponent"
|
||||||
if (-not (Test-Path -Path $setupPath)) {
|
if (-not (Test-Path -Path $setupPath)) {
|
||||||
$null = New-Item -Path $setupPath -ItemType Directory -Force
|
$null = New-Item -Path $setupPath -ItemType Directory -Force
|
||||||
}
|
}
|
||||||
Expand-7ZipArchive -Path $setupZipFile -DestinationPath $setupPath
|
Expand-7ZipArchive -Path $zipFile -DestinationPath $setupPath
|
||||||
|
|
||||||
Write-Host "Installing BizTalk Project Build Component..."
|
Write-Host "Installing BizTalk Project Build Component..."
|
||||||
Install-Binary `
|
Install-Binary `
|
||||||
@@ -25,7 +25,4 @@ Install-Binary `
|
|||||||
-ExtraInstallArgs ("/l*v", "$setupPath\buildComponentSetup.log") `
|
-ExtraInstallArgs ("/l*v", "$setupPath\buildComponentSetup.log") `
|
||||||
-ExpectedSignature $BuildComponentSignatureThumbprint
|
-ExpectedSignature $BuildComponentSignatureThumbprint
|
||||||
|
|
||||||
Remove-Item $setupZipFile
|
|
||||||
Remove-Item $setupPath -Recurse -Force
|
|
||||||
|
|
||||||
Invoke-PesterTests -TestFile "BizTalk" -TestName "BizTalk Build Component Setup"
|
Invoke-PesterTests -TestFile "BizTalk" -TestName "BizTalk Build Component Setup"
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ if ($userPath) {
|
|||||||
|
|
||||||
# Verify and run choco installer
|
# Verify and run choco installer
|
||||||
$signatureThumbprint = "83AC7D88C66CB8680BCE802E0F0F5C179722764B"
|
$signatureThumbprint = "83AC7D88C66CB8680BCE802E0F0F5C179722764B"
|
||||||
$InstallScriptPath = Start-DownloadWithRetry -Url 'https://chocolatey.org/install.ps1'
|
$InstallScriptPath = Invoke-DownloadWithRetry 'https://chocolatey.org/install.ps1'
|
||||||
Test-FileSignature -FilePath $InstallScriptPath -ExpectedThumbprint $signatureThumbprint
|
Test-FileSignature -FilePath $InstallScriptPath -ExpectedThumbprint $signatureThumbprint
|
||||||
Invoke-Expression $InstallScriptPath
|
Invoke-Expression $InstallScriptPath
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ Write-Host "Chrome WebDriver version to install is $($ChromeDriverVersion.versio
|
|||||||
$ChromeDriverZipDownloadUrl = ($ChromeDriverVersion.downloads.chromedriver | Where-Object platform -eq "win64").url
|
$ChromeDriverZipDownloadUrl = ($ChromeDriverVersion.downloads.chromedriver | Where-Object platform -eq "win64").url
|
||||||
|
|
||||||
Write-Host "Download Chrome WebDriver from $ChromeDriverZipDownloadUrl..."
|
Write-Host "Download Chrome WebDriver from $ChromeDriverZipDownloadUrl..."
|
||||||
$ChromeDriverArchPath = Start-DownloadWithRetry -Url $ChromeDriverZipDownloadUrl
|
$ChromeDriverArchPath = Invoke-DownloadWithRetry $ChromeDriverZipDownloadUrl
|
||||||
|
|
||||||
Write-Host "Expand Chrome WebDriver archive (without using directory names)..."
|
Write-Host "Expand Chrome WebDriver archive (without using directory names)..."
|
||||||
Expand-7ZipArchive -Path $ChromeDriverArchPath -DestinationPath $ChromeDriverPath -ExtractMethod "e"
|
Expand-7ZipArchive -Path $ChromeDriverArchPath -DestinationPath $ChromeDriverPath -ExtractMethod "e"
|
||||||
|
|||||||
@@ -4,10 +4,9 @@
|
|||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
# Download the latest cf cli exe
|
# Download the latest cf cli exe
|
||||||
$CloudFoundryCliName = "cf-cli.zip"
|
|
||||||
$CloudFoundryCliUrl = "https://packages.cloudfoundry.org/stable?release=windows64-exe&source=github"
|
$CloudFoundryCliUrl = "https://packages.cloudfoundry.org/stable?release=windows64-exe&source=github"
|
||||||
|
|
||||||
$CloudFoundryArchPath = Start-DownloadWithRetry -Url $CloudFoundryCliUrl -Name $CloudFoundryCliName
|
$CloudFoundryArchPath = Invoke-DownloadWithRetry $CloudFoundryCliUrl
|
||||||
|
|
||||||
# Create directory for cf cli
|
# Create directory for cf cli
|
||||||
$CloudFoundryCliPath = "C:\cf-cli"
|
$CloudFoundryCliPath = "C:\cf-cli"
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ $TagName = "codeql-bundle-v" + $CliVersion
|
|||||||
Write-Host "Downloading CodeQL bundle $($CliVersion)..."
|
Write-Host "Downloading CodeQL bundle $($CliVersion)..."
|
||||||
# Note that this is the all-platforms CodeQL bundle, to support scenarios where customers run
|
# Note that this is the all-platforms CodeQL bundle, to support scenarios where customers run
|
||||||
# different operating systems within containers.
|
# different operating systems within containers.
|
||||||
$CodeQLBundlePath = Start-DownloadWithRetry -Url "https://github.com/github/codeql-action/releases/download/$($TagName)/codeql-bundle.tar.gz" -Name "codeql-bundle.tar.gz"
|
$CodeQLBundlePath = Invoke-DownloadWithRetry "https://github.com/github/codeql-action/releases/download/$($TagName)/codeql-bundle.tar.gz"
|
||||||
$DownloadDirectoryPath = (Get-Item $CodeQLBundlePath).Directory.FullName
|
$DownloadDirectoryPath = (Get-Item $CodeQLBundlePath).Directory.FullName
|
||||||
|
|
||||||
$CodeQLToolcachePath = Join-Path $Env:AGENT_TOOLSDIRECTORY -ChildPath "CodeQL" | Join-Path -ChildPath $CliVersion | Join-Path -ChildPath "x64"
|
$CodeQLToolcachePath = Join-Path $Env:AGENT_TOOLSDIRECTORY -ChildPath "CodeQL" | Join-Path -ChildPath $CliVersion | Join-Path -ChildPath "x64"
|
||||||
|
|||||||
@@ -21,14 +21,14 @@ if (-not $mobyRelease) {
|
|||||||
$mobyReleaseUrl = $dockerceUrl + $mobyRelease
|
$mobyReleaseUrl = $dockerceUrl + $mobyRelease
|
||||||
|
|
||||||
Write-Host "Install Moby $mobyRelease..."
|
Write-Host "Install Moby $mobyRelease..."
|
||||||
$mobyArchivePath = Start-DownloadWithRetry -Url $mobyReleaseUrl -Name $mobyRelease
|
$mobyArchivePath = Invoke-DownloadWithRetry $mobyReleaseUrl
|
||||||
Expand-Archive -Path $mobyArchivePath -DestinationPath $env:TEMP
|
Expand-Archive -Path $mobyArchivePath -DestinationPath $env:TEMP
|
||||||
$dockerPath = "$env:TEMP\docker\docker.exe"
|
$dockerPath = "$env:TEMP\docker\docker.exe"
|
||||||
$dockerdPath = "$env:TEMP\docker\dockerd.exe"
|
$dockerdPath = "$env:TEMP\docker\dockerd.exe"
|
||||||
|
|
||||||
Write-Host "Install Docker CE"
|
Write-Host "Install Docker CE"
|
||||||
$instScriptUrl = "https://raw.githubusercontent.com/microsoft/Windows-Containers/Main/helpful_tools/Install-DockerCE/install-docker-ce.ps1"
|
$instScriptUrl = "https://raw.githubusercontent.com/microsoft/Windows-Containers/Main/helpful_tools/Install-DockerCE/install-docker-ce.ps1"
|
||||||
$instScriptPath = Start-DownloadWithRetry -Url $instScriptUrl -Name "install-docker-ce.ps1"
|
$instScriptPath = Invoke-DownloadWithRetry $instScriptUrl
|
||||||
& $instScriptPath -DockerPath $dockerPath -DockerDPath $dockerdPath
|
& $instScriptPath -DockerPath $dockerPath -DockerDPath $dockerdPath
|
||||||
if ($LastExitCode -ne 0) {
|
if ($LastExitCode -ne 0) {
|
||||||
Write-Host "Docker installation failed with exit code $LastExitCode"
|
Write-Host "Docker installation failed with exit code $LastExitCode"
|
||||||
|
|||||||
@@ -12,6 +12,6 @@ Write-Host "Install-Package Docker-Compose v2"
|
|||||||
$dockerComposev2Url = "https://github.com/docker/compose/releases/latest/download/docker-compose-windows-x86_64.exe"
|
$dockerComposev2Url = "https://github.com/docker/compose/releases/latest/download/docker-compose-windows-x86_64.exe"
|
||||||
$cliPluginsDir = "C:\ProgramData\docker\cli-plugins"
|
$cliPluginsDir = "C:\ProgramData\docker\cli-plugins"
|
||||||
New-Item -Path $cliPluginsDir -ItemType Directory
|
New-Item -Path $cliPluginsDir -ItemType Directory
|
||||||
Start-DownloadWithRetry -Url $dockerComposev2Url -Name docker-compose.exe -DownloadPath $cliPluginsDir
|
Invoke-DownloadWithRetry -Url $dockerComposev2Url -Path "$cliPluginsDir\docker-compose.exe"
|
||||||
|
|
||||||
Invoke-PesterTests -TestFile "Docker" -TestName "DockerCompose"
|
Invoke-PesterTests -TestFile "Docker" -TestName "DockerCompose"
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ function Get-DockerWincredHash {
|
|||||||
Write-Host "Install docker-wincred"
|
Write-Host "Install docker-wincred"
|
||||||
$dockerCredLatestRelease = Invoke-RestMethod -Uri "https://api.github.com/repos/docker/docker-credential-helpers/releases/latest"
|
$dockerCredLatestRelease = Invoke-RestMethod -Uri "https://api.github.com/repos/docker/docker-credential-helpers/releases/latest"
|
||||||
$dockerCredDownloadUrl = $dockerCredLatestRelease.assets.browser_download_url -match "docker-credential-wincred-.+\.exe" | Select-Object -First 1
|
$dockerCredDownloadUrl = $dockerCredLatestRelease.assets.browser_download_url -match "docker-credential-wincred-.+\.exe" | Select-Object -First 1
|
||||||
Start-DownloadWithRetry -Url $dockerCredDownloadUrl -DownloadPath "C:\Windows\System32" -Name "docker-credential-wincred.exe"
|
Invoke-DownloadWithRetry -Url $dockerCredDownloadUrl -Path "C:\Windows\System32\docker-credential-wincred.exe"
|
||||||
|
|
||||||
#region Supply chain security
|
#region Supply chain security
|
||||||
$distributor_file_hash = Get-DockerWincredHash -Release $dockerCredLatestRelease.name
|
$distributor_file_hash = Get-DockerWincredHash -Release $dockerCredLatestRelease.name
|
||||||
|
|||||||
@@ -16,20 +16,19 @@
|
|||||||
function Get-SDKVersionsToInstall (
|
function Get-SDKVersionsToInstall (
|
||||||
$DotnetVersion
|
$DotnetVersion
|
||||||
) {
|
) {
|
||||||
$releaseJson = "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/${DotnetVersion}/releases.json"
|
$metadataJsonUri = "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/${DotnetVersion}/releases.json"
|
||||||
$releasesJsonPath = Start-DownloadWithRetry -Url $releaseJson -Name "releases-${DotnetVersion}.json"
|
$currentReleases = Invoke-DownloadWithRetry $metadataJsonUri | Get-Item | Get-Content | ConvertFrom-Json
|
||||||
$currentReleases = Get-Content -Path $releasesJsonPath | ConvertFrom-Json
|
|
||||||
# filtering out the preview/rc releases
|
# filtering out the preview/rc releases
|
||||||
$currentReleases = $currentReleases.'releases' | Where-Object { !$_.'release-version'.Contains('-') }
|
$currentReleases = $currentReleases.'releases' | Where-Object { !$_.'release-version'.Contains('-') }
|
||||||
|
|
||||||
$sdks = @()
|
$sdks = @()
|
||||||
ForEach ($release in $currentReleases)
|
ForEach ($release in $currentReleases) {
|
||||||
{
|
|
||||||
$sdks += $release.'sdk'
|
$sdks += $release.'sdk'
|
||||||
$sdks += $release.'sdks'
|
$sdks += $release.'sdks'
|
||||||
}
|
}
|
||||||
|
|
||||||
return $sdks.version | Sort-Object { [Version] $_ } -Unique `
|
return $sdks.version `
|
||||||
|
| Sort-Object { [Version] $_ } -Unique `
|
||||||
| Group-Object { $_.Substring(0, $_.LastIndexOf('.') + 2) } `
|
| Group-Object { $_.Substring(0, $_.LastIndexOf('.') + 2) } `
|
||||||
| Foreach-Object { $_.Group[-1] }
|
| Foreach-Object { $_.Group[-1] }
|
||||||
}
|
}
|
||||||
@@ -55,10 +54,8 @@ function InstallSDKVersion (
|
|||||||
$SdkVersion,
|
$SdkVersion,
|
||||||
$dotnetVersion,
|
$dotnetVersion,
|
||||||
$Warmup
|
$Warmup
|
||||||
)
|
) {
|
||||||
{
|
if (!(Test-Path -Path "C:\Program Files\dotnet\sdk\$sdkVersion")) {
|
||||||
if (!(Test-Path -Path "C:\Program Files\dotnet\sdk\$sdkVersion"))
|
|
||||||
{
|
|
||||||
Write-Host "Installing dotnet $sdkVersion"
|
Write-Host "Installing dotnet $sdkVersion"
|
||||||
$ZipPath = [System.IO.Path]::combine([System.IO.Path]::GetTempPath(), [System.IO.Path]::GetRandomFileName())
|
$ZipPath = [System.IO.Path]::combine([System.IO.Path]::GetTempPath(), [System.IO.Path]::GetRandomFileName())
|
||||||
.\dotnet-install.ps1 -Version $sdkVersion -InstallDir $(Join-Path -Path $env:ProgramFiles -ChildPath 'dotnet') -ZipPath $ZipPath -KeepZip
|
.\dotnet-install.ps1 -Version $sdkVersion -InstallDir $(Join-Path -Path $env:ProgramFiles -ChildPath 'dotnet') -ZipPath $ZipPath -KeepZip
|
||||||
@@ -69,9 +66,7 @@ function InstallSDKVersion (
|
|||||||
|
|
||||||
Use-ChecksumComparison -LocalFileHash $localFileHash -DistributorFileHash $distributorFileHash
|
Use-ChecksumComparison -LocalFileHash $localFileHash -DistributorFileHash $distributorFileHash
|
||||||
#endregion
|
#endregion
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
Write-Host "Sdk version $sdkVersion already installed"
|
Write-Host "Sdk version $sdkVersion already installed"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,8 +75,7 @@ function InstallSDKVersion (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function InstallAllValidSdks()
|
function InstallAllValidSdks() {
|
||||||
{
|
|
||||||
# Consider all channels except preview/eol channels.
|
# Consider all channels except preview/eol channels.
|
||||||
# Sort the channels in ascending order
|
# Sort the channels in ascending order
|
||||||
$dotnetToolset = (Get-ToolsetContent).dotnet
|
$dotnetToolset = (Get-ToolsetContent).dotnet
|
||||||
@@ -91,7 +85,7 @@ function InstallAllValidSdks()
|
|||||||
# Download installation script.
|
# Download installation script.
|
||||||
$installationName = "dotnet-install.ps1"
|
$installationName = "dotnet-install.ps1"
|
||||||
$installationUrl = "https://dot.net/v1/${installationName}"
|
$installationUrl = "https://dot.net/v1/${installationName}"
|
||||||
Start-DownloadWithRetry -Url $installationUrl -Name $installationName -DownloadPath ".\"
|
Invoke-DownloadWithRetry -Url $installationUrl -Path ".\$installationName"
|
||||||
|
|
||||||
ForEach ($dotnetVersion in $dotnetVersions)
|
ForEach ($dotnetVersion in $dotnetVersions)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,43 +6,32 @@
|
|||||||
# Disable Edge auto-updates
|
# Disable Edge auto-updates
|
||||||
Rename-Item -Path "C:\Program Files (x86)\Microsoft\EdgeUpdate\MicrosoftEdgeUpdate.exe" -NewName "Disabled_MicrosoftEdgeUpdate.exe" -ErrorAction Stop
|
Rename-Item -Path "C:\Program Files (x86)\Microsoft\EdgeUpdate\MicrosoftEdgeUpdate.exe" -NewName "Disabled_MicrosoftEdgeUpdate.exe" -ErrorAction Stop
|
||||||
|
|
||||||
# Install Microsoft Edge WebDriver
|
Write-Host "Get the Microsoft Edge WebDriver version..."
|
||||||
Write-Host "Install Edge WebDriver..."
|
$edgeBinaryPath = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\msedge.exe").'(default)'
|
||||||
$EdgeDriverPath = "$($env:SystemDrive)\SeleniumWebDrivers\EdgeDriver"
|
[version] $edgeVersion = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($edgeBinaryPath).ProductVersion
|
||||||
if (-not (Test-Path -Path $EdgeDriverPath)) {
|
|
||||||
New-Item -Path $EdgeDriverPath -ItemType Directory -Force
|
$edgeDriverPath = "$($env:SystemDrive)\SeleniumWebDrivers\EdgeDriver"
|
||||||
|
if (-not (Test-Path -Path $edgeDriverPath)) {
|
||||||
|
New-Item -Path $edgeDriverPath -ItemType Directory -Force
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host "Get the Microsoft Edge WebDriver version..."
|
$versionInfoUrl = "https://msedgedriver.azureedge.net/LATEST_RELEASE_$($edgeVersion.Major)_WINDOWS"
|
||||||
$RegistryPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths"
|
$versionInfoFile = Invoke-DownloadWithRetry -Url $versionInfoUrl -Path "$edgeDriverPath\versioninfo.txt"
|
||||||
$EdgePath = (Get-ItemProperty "$RegistryPath\msedge.exe").'(default)'
|
$latestVersion = Get-Content -Path $versionInfoFile
|
||||||
[version]$EdgeVersion = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($EdgePath).ProductVersion
|
|
||||||
$EdgeDriverVersionUrl = "https://msedgedriver.azureedge.net/LATEST_RELEASE_$($EdgeVersion.Major)_WINDOWS"
|
|
||||||
|
|
||||||
$EdgeDriverVersionFile = Start-DownloadWithRetry -Url $EdgeDriverVersionUrl -Name "versioninfo.txt" -DownloadPath $EdgeDriverPath
|
|
||||||
|
|
||||||
Write-Host "Download Microsoft Edge WebDriver..."
|
Write-Host "Download Microsoft Edge WebDriver..."
|
||||||
$EdgeDriverLatestVersion = Get-Content -Path $EdgeDriverVersionFile
|
$downloadUrl = "https://msedgedriver.azureedge.net/$latestVersion/edgedriver_win64.zip"
|
||||||
$EdgeDriverArchName = "edgedriver_win64.zip"
|
$archivePath = Invoke-DownloadWithRetry $downloadUrl
|
||||||
|
|
||||||
|
|
||||||
$EdgeDriverDownloadUrl = "https://msedgedriver.azureedge.net/${EdgeDriverLatestVersion}/${EdgeDriverArchName}"
|
|
||||||
|
|
||||||
$EdgeDriverArchPath = Start-DownloadWithRetry -Url $EdgeDriverDownloadUrl -Name $EdgeDriverArchName
|
|
||||||
|
|
||||||
Write-Host "Expand Microsoft Edge WebDriver archive..."
|
Write-Host "Expand Microsoft Edge WebDriver archive..."
|
||||||
Expand-7ZipArchive -Path $EdgeDriverArchPath -DestinationPath $EdgeDriverPath
|
Expand-7ZipArchive -Path $archivePath -DestinationPath $edgeDriverPath
|
||||||
|
|
||||||
#Validate the EdgeDriver signature
|
#Validate the EdgeDriver signature
|
||||||
$EdgeDriverSignatureThumbprint = "CB9C4FBEA1D87D2D468AC5A9CAAB0163F6AD8401"
|
$signatureThumbprint = "CB9C4FBEA1D87D2D468AC5A9CAAB0163F6AD8401"
|
||||||
Test-FileSignature -FilePath "$EdgeDriverPath\msedgedriver.exe" -ExpectedThumbprint $EdgeDriverSignatureThumbprint
|
Test-FileSignature -FilePath "$edgeDriverPath\msedgedriver.exe" -ExpectedThumbprint $signatureThumbprint
|
||||||
|
|
||||||
Write-Host "Setting the environment variables..."
|
Write-Host "Setting the environment variables..."
|
||||||
[Environment]::SetEnvironmentVariable("EdgeWebDriver", $EdgeDriverPath, "Machine")
|
[Environment]::SetEnvironmentVariable("EdgeWebDriver", $EdgeDriverPath, "Machine")
|
||||||
|
Add-MachinePathItem "$edgeDriverPath\"
|
||||||
$regEnvKey = 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\'
|
|
||||||
$PathValue = Get-ItemPropertyValue -Path $regEnvKey -Name 'Path'
|
|
||||||
$PathValue += ";$EdgeDriverPath\"
|
|
||||||
Set-ItemProperty -Path $regEnvKey -Name 'Path' -Value $PathValue
|
|
||||||
|
|
||||||
Invoke-PesterTests -TestFile "Browsers" -TestName "Edge"
|
Invoke-PesterTests -TestFile "Browsers" -TestName "Edge"
|
||||||
|
|||||||
@@ -42,10 +42,8 @@ $GeckoDriverVersion = $GeckoDriverJson.tag_name
|
|||||||
$GeckoDriverVersion.Substring(1) | Out-File -FilePath "$GeckoDriverPath\versioninfo.txt" -Force;
|
$GeckoDriverVersion.Substring(1) | Out-File -FilePath "$GeckoDriverPath\versioninfo.txt" -Force;
|
||||||
|
|
||||||
Write-Host "Download Gecko WebDriver WebDriver..."
|
Write-Host "Download Gecko WebDriver WebDriver..."
|
||||||
$GeckoDriverArchName = $GeckoDriverWindowsAsset.name
|
|
||||||
$GeckoDriverDownloadUrl = $GeckoDriverWindowsAsset.browser_download_url
|
$GeckoDriverDownloadUrl = $GeckoDriverWindowsAsset.browser_download_url
|
||||||
|
$GeckoDriverArchPath = Invoke-DownloadWithRetry $GeckoDriverDownloadUrl
|
||||||
$GeckoDriverArchPath = Start-DownloadWithRetry -Url $GeckoDriverDownloadUrl -Name $GeckoDriverArchName
|
|
||||||
|
|
||||||
Write-Host "Expand Gecko WebDriver archive..."
|
Write-Host "Expand Gecko WebDriver archive..."
|
||||||
Expand-7ZipArchive -Path $GeckoDriverArchPath -DestinationPath $GeckoDriverPath
|
Expand-7ZipArchive -Path $GeckoDriverArchPath -DestinationPath $GeckoDriverPath
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ $ghcupDownloadURL = "https://downloads.haskell.org/~ghcup/x86_64-mingw64-ghcup.e
|
|||||||
|
|
||||||
New-Item -Path "$ghcupPrefix\ghcup" -ItemType 'directory' -ErrorAction SilentlyContinue | Out-Null
|
New-Item -Path "$ghcupPrefix\ghcup" -ItemType 'directory' -ErrorAction SilentlyContinue | Out-Null
|
||||||
New-Item -Path "$ghcupPrefix\ghcup\bin" -ItemType 'directory' -ErrorAction SilentlyContinue | Out-Null
|
New-Item -Path "$ghcupPrefix\ghcup\bin" -ItemType 'directory' -ErrorAction SilentlyContinue | Out-Null
|
||||||
Start-DownloadWithRetry -Url $ghcupDownloadURL -Name "ghcup.exe" -DownloadPath "$ghcupPrefix\ghcup\bin"
|
Invoke-DownloadWithRetry -Url $ghcupDownloadURL -Path "$ghcupPrefix\ghcup\bin\ghcup.exe"
|
||||||
|
|
||||||
[System.Environment]::SetEnvironmentVariable("GHCUP_INSTALL_BASE_PREFIX", $ghcupPrefix, "Machine")
|
[System.Environment]::SetEnvironmentVariable("GHCUP_INSTALL_BASE_PREFIX", $ghcupPrefix, "Machine")
|
||||||
[System.Environment]::SetEnvironmentVariable("GHCUP_MSYS2", $msysPath, "Machine")
|
[System.Environment]::SetEnvironmentVariable("GHCUP_MSYS2", $msysPath, "Machine")
|
||||||
|
|||||||
@@ -10,13 +10,8 @@ $ieDriverUrl = Resolve-GithubReleaseAssetUrl `
|
|||||||
-Asset "IEDriverServer_x64_*.zip"
|
-Asset "IEDriverServer_x64_*.zip"
|
||||||
|
|
||||||
# Download IE selenium driver
|
# Download IE selenium driver
|
||||||
try {
|
|
||||||
Write-Host "Selenium IEDriverServer download and install..."
|
Write-Host "Selenium IEDriverServer download and install..."
|
||||||
$driverZipFile = Start-DownloadWithRetry -Url $ieDriverUrl -Name "SeleniumWebDrivers.zip"
|
$driverZipFile = Invoke-DownloadWithRetry $ieDriverUrl
|
||||||
} catch {
|
|
||||||
Write-Error "[!] Failed to download $ieDriverUrl"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
$ieDriverPath = "C:\SeleniumWebDrivers\IEDriver"
|
$ieDriverPath = "C:\SeleniumWebDrivers\IEDriver"
|
||||||
if (-not (Test-Path -Path $ieDriverPath)) {
|
if (-not (Test-Path -Path $ieDriverPath)) {
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ function Install-JavaJDK {
|
|||||||
|
|
||||||
# Download and extract java binaries to temporary folder
|
# Download and extract java binaries to temporary folder
|
||||||
$downloadUrl = $asset.binary.package.link
|
$downloadUrl = $asset.binary.package.link
|
||||||
$archivePath = Start-DownloadWithRetry -Url $downloadUrl -Name $([IO.Path]::GetFileName($downloadUrl))
|
$archivePath = Invoke-DownloadWithRetry $downloadUrl
|
||||||
|
|
||||||
#region Supply chain security - JDK
|
#region Supply chain security - JDK
|
||||||
$fileHash = (Get-FileHash -Path $archivePath -Algorithm SHA256).Hash
|
$fileHash = (Get-FileHash -Path $archivePath -Algorithm SHA256).Hash
|
||||||
@@ -137,7 +137,7 @@ $uri = 'https://repo1.maven.org/maven2/net/sourceforge/cobertura/cobertura/2.1.1
|
|||||||
$sha256sum = '79479DDE416B082F38ECD1F2F7C6DEBD4D0C2249AF80FD046D1CE05D628F2EC6'
|
$sha256sum = '79479DDE416B082F38ECD1F2F7C6DEBD4D0C2249AF80FD046D1CE05D628F2EC6'
|
||||||
$coberturaPath = "C:\cobertura-2.1.1"
|
$coberturaPath = "C:\cobertura-2.1.1"
|
||||||
|
|
||||||
$archivePath = Start-DownloadWithRetry -Url $uri -Name "cobertura.zip"
|
$archivePath = Invoke-DownloadWithRetry $uri
|
||||||
$fileHash = (Get-FileHash -Path $archivePath -Algorithm SHA256).Hash
|
$fileHash = (Get-FileHash -Path $archivePath -Algorithm SHA256).Hash
|
||||||
Use-ChecksumComparison $fileHash $sha256sum
|
Use-ChecksumComparison $fileHash $sha256sum
|
||||||
Expand-7ZipArchive -Path $archivePath -DestinationPath "C:\"
|
Expand-7ZipArchive -Path $archivePath -DestinationPath "C:\"
|
||||||
|
|||||||
@@ -11,17 +11,17 @@ $kotlinDownloadUrl = Resolve-GithubReleaseAssetUrl `
|
|||||||
-Repo "JetBrains/kotlin" `
|
-Repo "JetBrains/kotlin" `
|
||||||
-Version $kotlinVersion `
|
-Version $kotlinVersion `
|
||||||
-Asset "kotlin-compiler-*.zip"
|
-Asset "kotlin-compiler-*.zip"
|
||||||
$kotlinInstallerPath = Start-DownloadWithRetry -Url $kotlinDownloadUrl -Name "kotlin-compiler.zip"
|
$kotlinArchivePath = Invoke-DownloadWithRetry $kotlinDownloadUrl
|
||||||
|
|
||||||
#region Supply chain security
|
#region Supply chain security
|
||||||
$fileHash = (Get-FileHash -Path $kotlinInstallerPath -Algorithm SHA256).Hash
|
$fileHash = (Get-FileHash -Path $kotlinArchivePath -Algorithm SHA256).Hash
|
||||||
$externalHash = Get-HashFromGitHubReleaseBody -RepoOwner "JetBrains" -RepoName "kotlin" -FileName "$kotlinBinaryName-*.zip" -Version $kotlinVersion -WordNumber 2
|
$externalHash = Get-HashFromGitHubReleaseBody -RepoOwner "JetBrains" -RepoName "kotlin" -FileName "$kotlinBinaryName-*.zip" -Version $kotlinVersion -WordNumber 2
|
||||||
Use-ChecksumComparison $fileHash $externalHash
|
Use-ChecksumComparison $fileHash $externalHash
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
Write-Host "Expand Kotlin archive"
|
Write-Host "Expand Kotlin archive"
|
||||||
$kotlinPath = "C:\tools"
|
$kotlinPath = "C:\tools"
|
||||||
Expand-7ZipArchive -Path $kotlinInstallerPath -DestinationPath $kotlinPath
|
Expand-7ZipArchive -Path $kotlinArchivePath -DestinationPath $kotlinPath
|
||||||
|
|
||||||
# Add to PATH
|
# Add to PATH
|
||||||
Add-MachinePathItem "$kotlinPath\kotlinc\bin"
|
Add-MachinePathItem "$kotlinPath\kotlinc\bin"
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ $assets = (Invoke-RestMethod -Uri $repoUrl).assets
|
|||||||
[System.String] $kindDownloadLink = $assets.browser_download_url -match "kind-windows-amd64$"
|
[System.String] $kindDownloadLink = $assets.browser_download_url -match "kind-windows-amd64$"
|
||||||
$destFilePath = "C:\ProgramData\kind"
|
$destFilePath = "C:\ProgramData\kind"
|
||||||
$null = New-Item -Path $destFilePath -ItemType Directory -Force
|
$null = New-Item -Path $destFilePath -ItemType Directory -Force
|
||||||
$packagePath = Start-DownloadWithRetry -Url $kindDownloadLink -Name "kind.exe" -DownloadPath $destFilePath
|
$packagePath = Invoke-DownloadWithRetry -Url $kindDownloadLink -Path "$destFilePath\kind.exe"
|
||||||
|
|
||||||
#region Supply chain security - Kind
|
#region Supply chain security - Kind
|
||||||
$fileHash = (Get-FileHash -Path $packagePath -Algorithm SHA256).Hash
|
$fileHash = (Get-FileHash -Path $packagePath -Algorithm SHA256).Hash
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ if (Test-IsWin19) {
|
|||||||
throw "Unknown architecture $_"
|
throw "Unknown architecture $_"
|
||||||
}
|
}
|
||||||
|
|
||||||
$packagePath = Start-DownloadWithRetry -Url $url -Name "$_.7z"
|
$packagePath = Invoke-DownloadWithRetry $url
|
||||||
$hash = Get-FileHash -Path $packagePath -Algorithm SHA256
|
$hash = Get-FileHash -Path $packagePath -Algorithm SHA256
|
||||||
if ($hash.Hash -ne $sha256sum) {
|
if ($hash.Hash -ne $sha256sum) {
|
||||||
throw "Checksum verification failed for $packagePath"
|
throw "Checksum verification failed for $packagePath"
|
||||||
@@ -55,7 +55,7 @@ if (Test-IsWin19) {
|
|||||||
-Version "$version" `
|
-Version "$version" `
|
||||||
-Asset "$arch-*-release-$threads-$exceptions-$runtime-*.7z"
|
-Asset "$arch-*-release-$threads-$exceptions-$runtime-*.7z"
|
||||||
|
|
||||||
$packagePath = Start-DownloadWithRetry -Url $url -Name "$_.7z"
|
$packagePath = Invoke-DownloadWithRetry $url
|
||||||
Expand-7ZipArchive -Path $packagePath -DestinationPath "C:\"
|
Expand-7ZipArchive -Path $packagePath -DestinationPath "C:\"
|
||||||
|
|
||||||
# Make a copy of mingw-make.exe to make.exe, which is a more discoverable name
|
# Make a copy of mingw-make.exe to make.exe, which is a more discoverable name
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ function Install-Msys2 {
|
|||||||
|
|
||||||
# Download the latest msys2 x86_64, filename includes release date
|
# Download the latest msys2 x86_64, filename includes release date
|
||||||
Write-Host "Starting msys2 download using $($msys2Uri.split('/')[-1])"
|
Write-Host "Starting msys2 download using $($msys2Uri.split('/')[-1])"
|
||||||
$msys2File = Start-DownloadWithRetry -Url $msys2Uri
|
$msys2File = Invoke-DownloadWithRetry $msys2Uri
|
||||||
Write-Host "Finished download"
|
Write-Host "Finished download"
|
||||||
|
|
||||||
#region Supply chain security - Kind
|
#region Supply chain security - Kind
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ foreach($toolsetVersion in $toolsetVersions.versions)
|
|||||||
{
|
{
|
||||||
$filename = $latestMajorPyPyVersion.filename
|
$filename = $latestMajorPyPyVersion.filename
|
||||||
Write-Host "Found PyPy '$filename' package"
|
Write-Host "Found PyPy '$filename' package"
|
||||||
$tempPyPyPackagePath = Start-DownloadWithRetry -Url $latestMajorPyPyVersion.download_url -Name $filename
|
$tempPyPyPackagePath = Invoke-DownloadWithRetry $latestMajorPyPyVersion.download_url
|
||||||
|
|
||||||
#region Supply chain security
|
#region Supply chain security
|
||||||
$localFileHash = (Get-FileHash -Path $tempPyPyPackagePath -Algorithm SHA256).Hash
|
$localFileHash = (Get-FileHash -Path $tempPyPyPackagePath -Algorithm SHA256).Hash
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ foreach ($rubyVersion in $rubyToolVersions) {
|
|||||||
# Get url for the latest major Ruby version
|
# Get url for the latest major Ruby version
|
||||||
$url = $rubyLatestMajorVersions[$rubyVersion]
|
$url = $rubyLatestMajorVersions[$rubyVersion]
|
||||||
if ($url) {
|
if ($url) {
|
||||||
$tempRubyPackagePath = Start-DownloadWithRetry -Url $url
|
$tempRubyPackagePath = Invoke-DownloadWithRetry $url
|
||||||
Install-Ruby -PackagePath $tempRubyPackagePath
|
Install-Ruby -PackagePath $tempRubyPackagePath
|
||||||
} else {
|
} else {
|
||||||
Write-Host "Url not found for the '$rubyVersion' version"
|
Write-Host "Url not found for the '$rubyVersion' version"
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ Write-Host "Download latest Runner for GitHub Actions"
|
|||||||
$release = Invoke-RestMethod -Uri "https://api.github.com/repos/actions/runner/releases/latest"
|
$release = Invoke-RestMethod -Uri "https://api.github.com/repos/actions/runner/releases/latest"
|
||||||
$version = $release.tag_name.Trim("v")
|
$version = $release.tag_name.Trim("v")
|
||||||
$downloadUrl = ($release.assets.browser_download_url -ilike "*actions-runner-win-x64-${version}.zip*") | Select-Object -First 1
|
$downloadUrl = ($release.assets.browser_download_url -ilike "*actions-runner-win-x64-${version}.zip*") | Select-Object -First 1
|
||||||
|
$fileName = [System.IO.Path]::GetFileName($downloadUrl)
|
||||||
New-Item -Path "C:\ProgramData\runner" -ItemType Directory
|
New-Item -Path "C:\ProgramData\runner" -ItemType Directory
|
||||||
$packagePath = Start-DownloadWithRetry -Url $downloadUrl -DownloadPath "C:\ProgramData\runner"
|
Invoke-DownloadWithRetry -Url $downloadUrl -Path "C:\ProgramData\runner\$fileName"
|
||||||
|
|
||||||
Invoke-PesterTests -TestFile "RunnerCache"
|
Invoke-PesterTests -TestFile "RunnerCache"
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ $env:CARGO_HOME = "C:\Users\Default\.cargo"
|
|||||||
|
|
||||||
# Download the latest rustup-init.exe for Windows x64
|
# Download the latest rustup-init.exe for Windows x64
|
||||||
# See https://rustup.rs/#
|
# See https://rustup.rs/#
|
||||||
$rustupPath = Start-DownloadWithRetry -Url "https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-msvc/rustup-init.exe" -Name "rustup-init.exe"
|
$rustupPath = Invoke-DownloadWithRetry "https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-msvc/rustup-init.exe"
|
||||||
|
|
||||||
#region Supply chain security
|
#region Supply chain security
|
||||||
$localFileHash = (Get-FileHash -Path (Join-Path ${env:TEMP} 'rustup-init.exe') -Algorithm SHA256).Hash
|
$localFileHash = (Get-FileHash -Path (Join-Path ${env:TEMP} 'rustup-init.exe') -Algorithm SHA256).Hash
|
||||||
|
|||||||
@@ -9,21 +9,20 @@ New-Item -ItemType directory -Path $seleniumDirectory
|
|||||||
|
|
||||||
# Download Selenium
|
# Download Selenium
|
||||||
$seleniumMajorVersion = (Get-ToolsetContent).selenium.version
|
$seleniumMajorVersion = (Get-ToolsetContent).selenium.version
|
||||||
$seleniumFileName = "selenium-server.jar"
|
|
||||||
|
|
||||||
$seleniumDownloadUrl = Resolve-GithubReleaseAssetUrl `
|
$seleniumDownloadUrl = Resolve-GithubReleaseAssetUrl `
|
||||||
-Repo "SeleniumHQ/selenium" `
|
-Repo "SeleniumHQ/selenium" `
|
||||||
-Version "$seleniumMajorVersion.*" `
|
-Version "$seleniumMajorVersion.*" `
|
||||||
-Asset "selenium-server-*.jar"
|
-Asset "selenium-server-*.jar"
|
||||||
|
|
||||||
Start-DownloadWithRetry -Url $seleniumDownloadUrl -Name $seleniumFileName -DownloadPath $seleniumDirectory
|
$seleniumBinPath = Join-Path $seleniumDirectory "selenium-server.jar"
|
||||||
|
Invoke-DownloadWithRetry -Url $seleniumDownloadUrl -Path $seleniumBinPath
|
||||||
|
|
||||||
# Create an empty file to retrive Selenium version
|
# Create an empty file to retrive Selenium version
|
||||||
$seleniumFullVersion = $seleniumDownloadUrl.Split("-")[1].Split("/")[0]
|
$seleniumFullVersion = $seleniumDownloadUrl.Split("-")[1].Split("/")[0]
|
||||||
New-Item -Path $seleniumDirectory -Name "selenium-server-$seleniumFullVersion"
|
New-Item -Path $seleniumDirectory -Name "selenium-server-$seleniumFullVersion"
|
||||||
|
|
||||||
# Add SELENIUM_JAR_PATH environment variable
|
# Add SELENIUM_JAR_PATH environment variable
|
||||||
$seleniumBinPath = Join-Path $seleniumDirectory $seleniumFileName
|
|
||||||
[Environment]::SetEnvironmentVariable("SELENIUM_JAR_PATH", $seleniumBinPath, "Machine")
|
[Environment]::SetEnvironmentVariable("SELENIUM_JAR_PATH", $seleniumBinPath, "Machine")
|
||||||
|
|
||||||
Invoke-PesterTests -TestFile "Browsers" -TestName "Selenium"
|
Invoke-PesterTests -TestFile "Browsers" -TestName "Selenium"
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ $DownloadUrl = $StackReleasesJson.assets | Where-Object { $_.name.EndsWith($Down
|
|||||||
Write-Host "Download stack archive"
|
Write-Host "Download stack archive"
|
||||||
$StackToolcachePath = Join-Path $Env:AGENT_TOOLSDIRECTORY "stack\$Version"
|
$StackToolcachePath = Join-Path $Env:AGENT_TOOLSDIRECTORY "stack\$Version"
|
||||||
$DestinationPath = Join-Path $StackToolcachePath "x64"
|
$DestinationPath = Join-Path $StackToolcachePath "x64"
|
||||||
$StackArchivePath = Start-DownloadWithRetry -Url $DownloadUrl
|
$StackArchivePath = Invoke-DownloadWithRetry $DownloadUrl
|
||||||
|
|
||||||
#region Supply chain security - Stack
|
#region Supply chain security - Stack
|
||||||
$fileHash = (Get-FileHash -Path $StackArchivePath -Algorithm SHA256).Hash
|
$fileHash = (Get-FileHash -Path $StackArchivePath -Algorithm SHA256).Hash
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ Function Install-Asset {
|
|||||||
|
|
||||||
$releaseAssetName = [System.IO.Path]::GetFileNameWithoutExtension($ReleaseAsset.filename)
|
$releaseAssetName = [System.IO.Path]::GetFileNameWithoutExtension($ReleaseAsset.filename)
|
||||||
$assetFolderPath = Join-Path $env:TEMP $releaseAssetName
|
$assetFolderPath = Join-Path $env:TEMP $releaseAssetName
|
||||||
$assetArchivePath = Start-DownloadWithRetry -Url $ReleaseAsset.download_url -Name $ReleaseAsset.filename
|
$assetArchivePath = Invoke-DownloadWithRetry $ReleaseAsset.download_url
|
||||||
|
|
||||||
Write-Host "Extract $($ReleaseAsset.filename) content..."
|
Write-Host "Extract $($ReleaseAsset.filename) content..."
|
||||||
if ($assetArchivePath.EndsWith(".tar.gz")) {
|
if ($assetArchivePath.EndsWith(".tar.gz")) {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
$url = "https://api.github.com/repos/facebook/zstd/releases/latest"
|
$url = "https://api.github.com/repos/facebook/zstd/releases/latest"
|
||||||
# Explicitly set type to string since match returns array by default
|
# Explicitly set type to string since match returns array by default
|
||||||
[System.String] $zstdLatest = (Invoke-RestMethod -Uri $url).assets.browser_download_url -match "zstd-.+-win64.zip$"
|
[System.String] $zstdLatest = (Invoke-RestMethod -Uri $url).assets.browser_download_url -match "zstd-.+-win64.zip$"
|
||||||
$zstdArchivePath = Start-DownloadWithRetry -Url $zstdLatest -Name "zstd-win64.zip"
|
$zstdArchivePath = Invoke-DownloadWithRetry $zstdLatest
|
||||||
|
|
||||||
$toolPath = "C:\tools"
|
$toolPath = "C:\tools"
|
||||||
$zstdPath = Join-Path $toolPath zstd
|
$zstdPath = Join-Path $toolPath zstd
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ Export-ModuleMember -Function @(
|
|||||||
'Get-ToolsetContent'
|
'Get-ToolsetContent'
|
||||||
'Get-TCToolVersionPath'
|
'Get-TCToolVersionPath'
|
||||||
'Get-TCToolPath'
|
'Get-TCToolPath'
|
||||||
'Start-DownloadWithRetry'
|
'Invoke-DownloadWithRetry'
|
||||||
'Get-VsixExtenstionFromMarketplace'
|
'Get-VsixExtenstionFromMarketplace'
|
||||||
'Install-VSIXFromFile'
|
'Install-VSIXFromFile'
|
||||||
'Install-VSIXFromUrl'
|
'Install-VSIXFromUrl'
|
||||||
|
|||||||
@@ -66,9 +66,11 @@ function Install-Binary {
|
|||||||
if ($Type -ne "MSI" -and $Type -ne "EXE") {
|
if ($Type -ne "MSI" -and $Type -ne "EXE") {
|
||||||
throw "Cannot determine the file type from the URL. Please specify the Type parameter."
|
throw "Cannot determine the file type from the URL. Please specify the Type parameter."
|
||||||
}
|
}
|
||||||
}
|
$fileName = [System.IO.Path]::GetFileName($Url)
|
||||||
|
} else {
|
||||||
$fileName = [System.IO.Path]::GetFileNameWithoutExtension([System.IO.Path]::GetRandomFileName()) + ".$Type".ToLower()
|
$fileName = [System.IO.Path]::GetFileNameWithoutExtension([System.IO.Path]::GetRandomFileName()) + ".$Type".ToLower()
|
||||||
$filePath = Start-DownloadWithRetry -Url $Url -Name $fileName
|
}
|
||||||
|
$filePath = Invoke-DownloadWithRetry -Url $Url -Path "${env:Temp}\$fileName"
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($PSBoundParameters.ContainsKey('ExpectedSignature')) {
|
if ($PSBoundParameters.ContainsKey('ExpectedSignature')) {
|
||||||
@@ -130,49 +132,53 @@ function Install-Binary {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function Start-DownloadWithRetry {
|
function Invoke-DownloadWithRetry {
|
||||||
Param
|
Param
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory)]
|
[Parameter(Mandatory)]
|
||||||
[string] $Url,
|
[string] $Url,
|
||||||
[string] $Name,
|
[Alias("Destination")]
|
||||||
[string] $DownloadPath = "${env:Temp}",
|
[string] $Path
|
||||||
[int] $Retries = 20
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if ([String]::IsNullOrEmpty($Name)) {
|
if (-not $Path) {
|
||||||
$Name = [IO.Path]::GetFileName($Url)
|
$invalidChars = [IO.Path]::GetInvalidFileNameChars() -join ''
|
||||||
|
$re = "[{0}]" -f [RegEx]::Escape($invalidChars)
|
||||||
|
$fileName = [IO.Path]::GetFileName($Url) -replace $re
|
||||||
|
|
||||||
|
if ([String]::IsNullOrEmpty($fileName)) {
|
||||||
|
$fileName = [System.IO.Path]::GetRandomFileName()
|
||||||
|
}
|
||||||
|
$Path = Join-Path -Path "${env:Temp}" -ChildPath $fileName
|
||||||
}
|
}
|
||||||
|
|
||||||
$filePath = Join-Path -Path $DownloadPath -ChildPath $Name
|
Write-Host "Downloading package from $Url to $Path..."
|
||||||
$downloadStartTime = Get-Date
|
|
||||||
|
|
||||||
# Default retry logic for the package.
|
$interval = 30
|
||||||
Write-Host "Downloading package from: $Url to path $filePath."
|
$downloadStartTime = Get-Date
|
||||||
while ($Retries -gt 0) {
|
for ($retries = 20; $retries -gt 0; $retries--) {
|
||||||
try {
|
try {
|
||||||
$downloadAttemptStartTime = Get-Date
|
$attemptStartTime = Get-Date
|
||||||
(New-Object System.Net.WebClient).DownloadFile($Url, $filePath)
|
(New-Object System.Net.WebClient).DownloadFile($Url, $Path)
|
||||||
|
$attemptSeconds = [math]::Round(($(Get-Date) - $attemptStartTime).TotalSeconds, 2)
|
||||||
|
Write-Host "Package downloaded in $attemptSeconds seconds"
|
||||||
break
|
break
|
||||||
} catch {
|
} catch {
|
||||||
$failTime = [math]::Round(($(Get-Date) - $downloadStartTime).TotalSeconds, 2)
|
$attemptSeconds = [math]::Round(($(Get-Date) - $attemptStartTime).TotalSeconds, 2)
|
||||||
$attemptTime = [math]::Round(($(Get-Date) - $downloadAttemptStartTime).TotalSeconds, 2)
|
Write-Warning "Package download failed in $attemptSeconds seconds"
|
||||||
Write-Host "There is an error encounterd after $attemptTime seconds during package downloading:`n$($_.Exception.ToString())"
|
Write-Warning $_.Exception.Message
|
||||||
$Retries--
|
|
||||||
|
|
||||||
if ($Retries -eq 0) {
|
|
||||||
Write-Host "Package download failed after $failTime seconds"
|
|
||||||
exit 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host "Waiting 30 seconds before retrying. Retries left: $Retries"
|
if ($retries -eq 0) {
|
||||||
Start-Sleep -Seconds 30
|
$totalSeconds = [math]::Round(($(Get-Date) - $downloadStartTime).TotalSeconds, 2)
|
||||||
}
|
throw "Package download failed after $totalSeconds seconds"
|
||||||
}
|
}
|
||||||
|
|
||||||
$downloadCompleteTime = [math]::Round(($(Get-Date) - $downloadStartTime).TotalSeconds, 2)
|
Write-Warning "Waiting $interval seconds before retrying (retries left: $retries)..."
|
||||||
Write-Host "Package downloaded successfully in $downloadCompleteTime seconds"
|
Start-Sleep -Seconds $interval
|
||||||
return $filePath
|
}
|
||||||
|
|
||||||
|
return $Path
|
||||||
}
|
}
|
||||||
|
|
||||||
function Get-VsixExtenstionFromMarketplace {
|
function Get-VsixExtenstionFromMarketplace {
|
||||||
@@ -273,8 +279,7 @@ function Install-VSIXFromUrl {
|
|||||||
[int] $Retries = 20
|
[int] $Retries = 20
|
||||||
)
|
)
|
||||||
|
|
||||||
$name = [System.IO.Path]::GetFileNameWithoutExtension([System.IO.Path]::GetRandomFileName()) + ".vsix"
|
$filePath = Invoke-DownloadWithRetry $Url
|
||||||
$filePath = Start-DownloadWithRetry -Url $Url -Name $Name
|
|
||||||
Install-VSIXFromFile -FilePath $filePath -Retries $Retries
|
Install-VSIXFromFile -FilePath $filePath -Retries $Retries
|
||||||
Remove-Item -Force -Confirm:$false $filePath
|
Remove-Item -Force -Confirm:$false $filePath
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,8 +38,7 @@ Function Install-VisualStudio {
|
|||||||
$productId = "Microsoft.VisualStudio.Product.${Edition}"
|
$productId = "Microsoft.VisualStudio.Product.${Edition}"
|
||||||
|
|
||||||
Write-Host "Downloading Bootstrapper ..."
|
Write-Host "Downloading Bootstrapper ..."
|
||||||
$BootstrapperName = [IO.Path]::GetFileName($BootstrapperUrl)
|
$bootstrapperFilePath = Invoke-DownloadWithRetry $BootstrapperUrl
|
||||||
$bootstrapperFilePath = Start-DownloadWithRetry -Url $BootstrapperUrl -Name $BootstrapperName
|
|
||||||
|
|
||||||
# Verify that the bootstrapper is signed by Microsoft
|
# Verify that the bootstrapper is signed by Microsoft
|
||||||
Test-FileSignature -FilePath $bootstrapperFilePath -ExpectedThumbprint $SignatureThumbprint
|
Test-FileSignature -FilePath $bootstrapperFilePath -ExpectedThumbprint $SignatureThumbprint
|
||||||
@@ -85,8 +84,7 @@ Function Install-VisualStudio {
|
|||||||
|
|
||||||
# Try to download tool to collect logs
|
# Try to download tool to collect logs
|
||||||
$collectExeUrl = "https://aka.ms/vscollect.exe"
|
$collectExeUrl = "https://aka.ms/vscollect.exe"
|
||||||
$collectExeName = [IO.Path]::GetFileName($collectExeUrl)
|
$collectExePath = Invoke-DownloadWithRetry -Url $collectExeUrl
|
||||||
$collectExePath = Start-DownloadWithRetry -Url $collectExeUrl -Name $collectExeName
|
|
||||||
|
|
||||||
# Collect installation logs using the collect.exe tool and check if it is successful
|
# Collect installation logs using the collect.exe tool and check if it is successful
|
||||||
& "$collectExePath"
|
& "$collectExePath"
|
||||||
|
|||||||
Reference in New Issue
Block a user