[Windows] Implement installation helpers refactoring (#8865)

* [Windows] Refactor base Installer helper functions

* Fix helper name

* Fix name gen logic and improve error handling

* Fix hash checking logic

* Fix Install-VsixExtension invocation

* Fix variable name in Install-OpenSSL.ps1

* Fix type for git downloadUrl
This commit is contained in:
Vasilii Polikarpov
2023-11-22 15:14:08 +01:00
committed by GitHub
parent 46f21c4413
commit d3e630f774
46 changed files with 361 additions and 462 deletions
@@ -5,26 +5,21 @@
################################################################################
# Install AWS CLI
Choco-Install -PackageName awscli
Install-ChocoPackage awscli
# Install Session Manager Plugin for the AWS CLI
$sessionManagerName = "SessionManagerPluginSetup.exe"
$sessionManagerUrl = "https://s3.amazonaws.com/session-manager-downloads/plugin/latest/windows/$sessionManagerName"
$sessionManagerSignatureThumbprint = "FF457E5732E98A9F156E657F8CC7C4432507C3BB"
Install-Binary -Url $sessionManagerUrl -Name $sessionManagerName -ArgumentList ("/silent", "/install") -ExpectedSignature $sessionManagerSignatureThumbprint
Install-Binary `
-Url "https://s3.amazonaws.com/session-manager-downloads/plugin/latest/windows/SessionManagerPluginSetup.exe" `
-InstallArgs ("/silent", "/install") `
-ExpectedSignature "FF457E5732E98A9F156E657F8CC7C4432507C3BB"
$env:Path = $env:Path + ";$env:ProgramFiles\Amazon\SessionManagerPlugin\bin"
# Install AWS SAM CLI
$packageName = "AWS_SAM_CLI_64_PY3.msi"
$packageUrl = "https://github.com/awslabs/aws-sam-cli/releases/latest/download/$packageName"
$packagePath = Start-DownloadWithRetry -Url $packageUrl -Name $packageName
#region Supply chain security - AWS SAM CLI
$fileHash = (Get-FileHash -Path $packagePath -Algorithm SHA256).Hash
$externalHash = Get-HashFromGitHubReleaseBody -RepoOwner "awslabs" -RepoName "aws-sam-cli" -FileName $packageName
Use-ChecksumComparison $fileHash $externalHash
#endregion
Install-Binary -FilePath $packagePath
Install-Binary `
-Url $packageUrl `
-ExpectedSHA256Sum $externalHash
Invoke-PesterTests -TestFile "CLI.Tools" -TestName "AWS"
@@ -8,7 +8,7 @@ Stop-Service -Name w3svc | Out-Null
# Install latest apache in chocolatey
$installDir = "C:\tools"
Choco-Install -PackageName apache-httpd -ArgumentList "--force", "--params", "/installLocation:$installDir /port:80"
Install-ChocoPackage apache-httpd -ArgumentList "--force", "--params", "/installLocation:$installDir /port:80"
# Stop and disable Apache service
Stop-Service -Name Apache
@@ -11,9 +11,9 @@ $azureCliConfigPath = 'C:\azureCli'
# make variable to be available in the current session
${env:AZURE_CONFIG_DIR} = $azureCliConfigPath
$azCliUrl = 'https://aka.ms/installazurecliwindowsx64'
$azCliSignatureThumbprint = "72105B6D5F370B62FD5C82F1512F7AD7DEE5F2C0"
Install-Binary -Url $azCliUrl -Name 'azure-cli.msi' -ExpectedSignature $azCliSignatureThumbprint
Install-Binary -Type MSI `
-Url 'https://aka.ms/installazurecliwindowsx64' `
-ExpectedSignature '72105B6D5F370B62FD5C82F1512F7AD7DEE5F2C0'
$azureCliExtensionPath = Join-Path $Env:CommonProgramFiles 'AzureCliExtensionDirectory'
$null = New-Item -ItemType 'Directory' -Path $azureCliExtensionPath
@@ -3,10 +3,8 @@
## Desc: Install Azure CosmosDb Emulator
####################################################################################
$InstallerName = "AzureCosmosDBEmulator.msi"
$InstallerUrl = "https://aka.ms/cosmosdb-emulator"
$SignatureThumbprint = "F372C27F6E052A6BE8BAB3112B465C692196CD6F"
Install-Binary -Url $InstallerUrl -Name $InstallerName -ExpectedSignature $SignatureThumbprint
Install-Binary -Type MSI `
-Url "https://aka.ms/cosmosdb-emulator" `
-ExpectedSignature "F372C27F6E052A6BE8BAB3112B465C692196CD6F"
Invoke-PesterTests -TestFile "Tools" -TestName "Azure Cosmos DB Emulator"
@@ -3,8 +3,8 @@
## Desc: Install Bazel and Bazelisk (A user-friendly launcher for Bazel)
################################################################################
Choco-Install -PackageName bazel
Install-ChocoPackage bazel
npm install -g @bazel/bazelisk
Invoke-PesterTests -TestFile "Tools" -TestName "Bazel"
Invoke-PesterTests -TestFile "Tools" -TestName "Bazel"
@@ -3,86 +3,29 @@
## Desc: Install BizTalk Project Build Component
################################################################################
function Install-Msi
{
<#
.SYNOPSIS
A helper function to install executables.
$BuildComponentUri = "https://aka.ms/BuildComponentSetup.EN"
$BuildComponentSignatureThumbprint = "8740DF4ACB749640AD318E4BE842F72EC651AD80"
.DESCRIPTION
install .exe or .msi binaries from specified Path.
Write-Host "Downloading BizTalk Project Build Component archive..."
$setupZipFile = Start-DownloadWithRetry -Url $BuildComponentUri -Name "BuildComponentSetup.EN.zip"
.PARAMETER MsiPath
Msi or exe path. Required parameter.
.PARAMETER LogPath
The log file path where installation will write log to. Required parameter.
.EXAMPLE
Install-Msi -MsiPath "c:\temp\abc.msi" -LogPath "c:\abc.log"
#>
Param
(
[Parameter(Mandatory)]
[String] $MsiPath,
[Parameter(Mandatory)]
[String] $LogPath
)
try
{
$filePath = "msiexec.exe"
Write-Host "Starting Install $MsiPath..."
$ArgumentList = ('/i', $MsiPath, '/QN', '/norestart', "/l*v",$LogPath)
$process = Start-Process -FilePath $filePath -ArgumentList $ArgumentList -Wait -PassThru -Verb runAs
$exitCode = $process.ExitCode
if ($exitCode -eq 0 -or $exitCode -eq 3010)
{
Write-Host "Installation for $MsiPath is successful."
}
else
{
Write-Host "Non zero exit code returned by $MsiPath installation process: $exitCode"
Get-Content $LogPath | Write-Host
exit $exitCode
}
}
catch
{
Write-Host "Failed to install $MsiPath : $($_.Exception.Message)"
exit 1
}
}
$bizTalkBuildComponentUri = "https://aka.ms/BuildComponentSetup.EN"
# Download
Write-Host "BizTalk Project Build Component download..."
$setupZipFile = Start-DownloadWithRetry -Url $bizTalkBuildComponentUri -Name "BuildComponentSetup.EN.zip"
# Unzip
$setupPath = "C:\BizTalkBuildComponent"
$setupPath = Join-Path $env:TEMP "BizTalkBuildComponent"
if (-not (Test-Path -Path $setupPath)) {
$null = New-Item -Path $setupPath -ItemType Directory -Force
}
Write-Host "Unzip $setupZipFile to $setupPath..."
Extract-7Zip -Path $setupZipFile -DestinationPath $setupPath
Write-Host "Installing BizTalk Project Build Component..."
Install-Binary `
-LocalPath "$setupPath\Bootstrap.msi" `
-ExtraInstallArgs ("/l*v", "$setupPath\bootstrap.log") `
-ExpectedSignature $BuildComponentSignatureThumbprint
Install-Binary `
-LocalPath "$setupPath\BuildComponentSetup.msi" `
-ExtraInstallArgs ("/l*v", "$setupPath\buildComponentSetup.log") `
-ExpectedSignature $BuildComponentSignatureThumbprint
Remove-Item $setupZipFile
# Verify signature
$BuildComponentSignatureThumbprint = "8740DF4ACB749640AD318E4BE842F72EC651AD80"
Test-FileSignature -FilePath "$setupPath\Bootstrap.msi" -ExpectedThumbprint $BuildComponentSignatureThumbprint
Test-FileSignature -FilePath "$setupPath\BuildComponentSetup.msi" -ExpectedThumbprint $BuildComponentSignatureThumbprint
# Install
Install-Msi -MsiPath "$setupPath\Bootstrap.msi" -LogPath "$setupPath\bootstrap.log"
Install-Msi -MsiPath "$setupPath\BuildComponentSetup.msi" -LogPath "$setupPath\buildComponentSetup.log"
Remove-Item $setupPath -Recurse -Force
# Test
Invoke-PesterTests -TestFile "BizTalk" -TestName "BizTalk Build Component Setup"
@@ -6,7 +6,7 @@
$commonPackages = (Get-ToolsetContent).choco.common_packages
foreach ($package in $commonPackages) {
Choco-Install -PackageName $package.name -ArgumentList $package.args
Install-ChocoPackage $package.name -ArgumentList $package.args
}
Invoke-PesterTests -TestFile "ChocoPackages"
@@ -4,10 +4,9 @@
################################################################################
# Download and install latest Chrome browser
$ChromeSignatureThumbprint = "2673EA6CC23BEFFDA49AC715B121544098A1284C"
$ChromeInstallerFile = "googlechromestandaloneenterprise64.msi"
$ChromeInstallerUrl = "https://dl.google.com/tag/s/dl/chrome/install/${ChromeInstallerFile}"
Install-Binary -Url $ChromeInstallerUrl -Name $ChromeInstallerFile -ArgumentList @() -ExpectedSignature $ChromeSignatureThumbprint
Install-Binary `
-Url 'https://dl.google.com/tag/s/dl/chrome/install/googlechromestandaloneenterprise64.msi' `
-ExpectedSignature '2673EA6CC23BEFFDA49AC715B121544098A1284C'
# Prepare firewall rules
Write-Host "Adding the firewall rule for Google update blocking..."
@@ -3,10 +3,8 @@
## Desc: Install SQL Server® Data-Tier Application Framework (DacFx) for Windows
####################################################################################
$InstallerName = "DacFramework.msi"
$InstallerUrl = "https://aka.ms/dacfx-msi"
$SignatureThumbprint = "72105B6D5F370B62FD5C82F1512F7AD7DEE5F2C0"
Install-Binary -Url $InstallerUrl -Name $InstallerName -ExpectedSignature $SignatureThumbprint
Install-Binary -Type MSI `
-Url 'https://aka.ms/dacfx-msi' `
-ExpectedSignature '72105B6D5F370B62FD5C82F1512F7AD7DEE5F2C0'
Invoke-PesterTests -TestFile "Tools" -TestName "DACFx"
@@ -5,8 +5,8 @@
################################################################################
Write-Host "Install-Package Docker-Compose v1"
$versionToInstall = Get-LatestChocoPackageVersion -TargetVersion "1.29" -PackageName "docker-compose"
Choco-Install -PackageName docker-compose -ArgumentList "--version=$versionToInstall"
$versionToInstall = Resolve-ChocoPackageVersion -PackageName "docker-compose" -TargetVersion "1.29"
Install-ChocoPackage docker-compose -ArgumentList "--version=$versionToInstall"
Write-Host "Install-Package Docker-Compose v2"
$dockerComposev2Url = "https://github.com/docker/compose/releases/latest/download/docker-compose-windows-x86_64.exe"
@@ -5,19 +5,18 @@
################################################################################
# Install and configure Firefox browser
Write-Host "Install latest Firefox browser..."
Write-Host "Get the latest Firefox version..."
$VersionsManifest = Invoke-RestMethod "https://product-details.mozilla.org/1.0/firefox_versions.json"
$InstallerUrl = "https://download.mozilla.org/?product=firefox-$($VersionsManifest.LATEST_FIREFOX_VERSION)&os=win64&lang=en-US"
$packagePath = Start-DownloadWithRetry -Url $InstallerUrl -Name "FirefoxSetup.exe"
#region Supply chain security - Stack
$fileHash = (Get-FileHash -Path $packagePath -Algorithm SHA256).Hash
Write-Host "Install Firefox browser..."
$installerUrl = "https://download.mozilla.org/?product=firefox-$($VersionsManifest.LATEST_FIREFOX_VERSION)&os=win64&lang=en-US"
$hashUrl = "https://archive.mozilla.org/pub/firefox/releases/$($VersionsManifest.LATEST_FIREFOX_VERSION)/SHA256SUMS"
$externalHash = (Invoke-RestMethod -Uri $hashURL).ToString().Split("`n").Where({ $_ -ilike "*win64/en-US/Firefox Setup*exe*" }).Split(' ')[0]
Use-ChecksumComparison $fileHash $externalHash
#endregion
Install-Binary -FilePath $packagePath -ArgumentList "/silent", "/install"
Install-Binary -Type EXE `
-Url $installerUrl `
-InstallArgs @("/silent", "/install") `
-ExpectedSHA256Sum $externalHash
Write-Host "Disable autoupdate..."
$FirefoxDirectoryPath = Join-Path $env:ProgramFiles "Mozilla Firefox"
@@ -32,8 +31,7 @@ pref("general.config.filename", "mozilla.cfg");' -ItemType file -force
# Download and install Gecko WebDriver
Write-Host "Install Gecko WebDriver..."
$GeckoDriverPath = "$($env:SystemDrive)\SeleniumWebDrivers\GeckoDriver"
if (-not (Test-Path -Path $GeckoDriverPath))
{
if (-not (Test-Path -Path $GeckoDriverPath)) {
New-Item -Path $GeckoDriverPath -ItemType Directory -Force
}
+17 -20
View File
@@ -8,28 +8,25 @@ Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
# Install the latest version of Git for Windows
$repoURL = "https://api.github.com/repos/git-for-windows/git/releases/latest"
$gitReleases = Invoke-RestMethod $repoURL
[string]$downloadUrl = $gitReleases.assets.browser_download_url -match "Git-.+-64-bit.exe"
$downloadUrl = $gitReleases.assets.browser_download_url -match "Git-.+-64-bit.exe" | Select-Object -First 1
$installerFile = Split-Path $downloadUrl -Leaf
$packagePath = Start-DownloadWithRetry -Url $downloadUrl -Name $installerFile
#region Supply chain security - Git
$fileHash = (Get-FileHash -Path $packagePath -Algorithm SHA256).Hash
$externalHash = Get-HashFromGitHubReleaseBody -Url $RepoURL -FileName $installerFile
Use-ChecksumComparison $fileHash $externalHash
#endregion
Install-Binary -FilePath $packagePath `
-ArgumentList (
"/VERYSILENT", `
"/NORESTART", `
"/NOCANCEL", `
"/SP-", `
"/CLOSEAPPLICATIONS", `
"/RESTARTAPPLICATIONS", `
"/o:PathOption=CmdTools", `
"/o:BashTerminalOption=ConHost", `
"/o:EnableSymlinks=Enabled", `
"/COMPONENTS=gitlfs")
Install-Binary `
-Url $downloadUrl `
-InstallArgs @(`
"/VERYSILENT", `
"/NORESTART", `
"/NOCANCEL", `
"/SP-", `
"/CLOSEAPPLICATIONS", `
"/RESTARTAPPLICATIONS", `
"/o:PathOption=CmdTools", `
"/o:BashTerminalOption=ConHost", `
"/o:EnableSymlinks=Enabled", `
"/COMPONENTS=gitlfs") `
-ExpectedSHA256Sum $externalHash
Update-SessionEnvironment
@@ -42,7 +39,7 @@ git config --system --add safe.directory "*"
Add-MachinePathItem "C:\Program Files\Git\bin"
# Add well-known SSH host keys to ssh_known_hosts
ssh-keyscan -t rsa,ecdsa,ed25519 github.com >> "C:\Program Files\Git\etc\ssh\ssh_known_hosts"
ssh-keyscan -t rsa, ecdsa, ed25519 github.com >> "C:\Program Files\Git\etc\ssh\ssh_known_hosts"
ssh-keyscan -t rsa ssh.dev.azure.com >> "C:\Program Files\Git\etc\ssh\ssh_known_hosts"
Invoke-PesterTests -TestFile "Git"
@@ -7,19 +7,15 @@
Write-Host "Get the latest gh version..."
$repoUrl = "https://api.github.com/repos/cli/cli/releases/latest"
$installerFile = "gh_windows_amd64.msi"
$assets = (Invoke-RestMethod -Uri $repoUrl).assets
$downloadUrl = ($assets.browser_download_url -match "windows_amd64.msi") | Select-Object -First 1
$packagePath = Start-DownloadWithRetry -Url $downloadUrl -Name $installerFile
#region Supply chain security - GitHub CLI
$fileHash = (Get-FileHash -Path $packagePath -Algorithm SHA256).Hash
$hashUrl = ($assets.browser_download_url -match "checksums.txt") | Select-Object -First 1
$externalHash = (Invoke-RestMethod -Uri $hashURL).ToString().Split("`n").Where({ $_ -ilike "*windows_amd64.msi*" }).Split(' ')[0]
Use-ChecksumComparison $fileHash $externalHash
#endregion
Install-Binary -FilePath $packagePath
Install-Binary `
-Url $downloadUrl `
-ExpectedSHA256Sum $externalHash
Add-MachinePathItem "C:\Program Files (x86)\GitHub CLI"
@@ -4,10 +4,9 @@
################################################################################
# https://cloud.google.com/sdk/docs/downloads-interactive
$googleCloudCLIInstaller = "https://dl.google.com/dl/cloudsdk/channels/rapid/GoogleCloudSDKInstaller.exe"
$argumentList = @("/S", "/allusers", "/noreporting")
$googleCloudCLISignatureThumbprint = "2673EA6CC23BEFFDA49AC715B121544098A1284C"
Install-Binary -Url $googleCloudCLIInstaller -Name "GoogleCloudSDKInstaller.exe" -ArgumentList $argumentList -ExpectedSignature $googleCloudCLISignatureThumbprint
Install-Binary `
-Url 'https://dl.google.com/dl/cloudsdk/channels/rapid/GoogleCloudSDKInstaller.exe' `
-InstallArgs @("/S", "/allusers", "/noreporting") `
-ExpectedSignature '2673EA6CC23BEFFDA49AC715B121544098A1284C'
Invoke-PesterTests -TestFile "Tools" -TestName "GoogleCloudCLI"
@@ -114,13 +114,13 @@ foreach ($jdkVersionToInstall in $jdkVersionsToInstall) {
# Install Java tools
# Force chocolatey to ignore dependencies on Ant and Maven or else they will download the Oracle JDK
Choco-Install -PackageName ant -ArgumentList "-i"
Install-ChocoPackage ant -ArgumentList "--ignore-dependencies"
# Maven 3.9.x has multiple compatibilities problems
$toolsetMavenVersion = (Get-ToolsetContent).maven.version
$versionToInstall = Get-LatestChocoPackageVersion -TargetVersion $toolsetMavenVersion -PackageName "maven"
$versionToInstall = Resolve-ChocoPackageVersion -PackageName "maven" -TargetVersion $toolsetMavenVersion
Choco-Install -PackageName maven -ArgumentList "--version=$versionToInstall"
Choco-Install -PackageName gradle
Install-ChocoPackage maven -ArgumentList "--version=$versionToInstall"
Install-ChocoPackage gradle
# Add maven env variables to Machine
[string]$m2 = (Get-MachinePath).Split(";") -match "maven"
@@ -23,12 +23,12 @@ Use-ChecksumComparison $fileHash $externalHash
Add-MachinePathItem $destFilePath
Write-Host "Install Kubectl"
Choco-Install -PackageName kubernetes-cli
Install-ChocoPackage kubernetes-cli
Write-Host "Install Helm"
Choco-Install -PackageName kubernetes-helm
Install-ChocoPackage kubernetes-helm
Write-Host "Install Minikube"
Choco-Install -PackageName minikube
Install-ChocoPackage minikube
Invoke-PesterTests -TestFile "Tools" -TestName "KubernetesTools"
@@ -4,7 +4,7 @@
################################################################################
$llvmVersion = (Get-ToolsetContent).llvm.version
$latestChocoVersion = Get-LatestChocoPackageVersion -TargetVersion $llvmVersion -PackageName "llvm"
Choco-Install -PackageName llvm -ArgumentList '--version', $latestChocoVersion
$latestChocoVersion = Resolve-ChocoPackageVersion -PackageName "llvm" -TargetVersion $llvmVersion
Install-ChocoPackage llvm -ArgumentList '--version', $latestChocoVersion
Invoke-PesterTests -TestFile "LLVM"
@@ -3,10 +3,10 @@
## Desc: Install Mercurial
################################################################################
Choco-Install -PackageName hg -ArgumentList "--version", "5.0.0"
Install-ChocoPackage hg -ArgumentList "--version", "5.0.0"
$hgPath = "${env:ProgramFiles}\Mercurial\"
Add-MachinePathItem $hgPath
$env:Path = Get-MachinePath
Invoke-PesterTests -TestFile "Tools" -TestName "Mercurial"
Invoke-PesterTests -TestFile "Tools" -TestName "Mercurial"
@@ -5,28 +5,28 @@
################################################################################
$CondaDestination = "C:\Miniconda"
# Install the latest Miniconda
$InstallerName = "Miniconda3-latest-Windows-x86_64.exe"
$InstallerUrl = "https://repo.anaconda.com/miniconda/${InstallerName}"
$ArgumentList = ("/S", "/AddToPath=0", "/RegisterPython=0", "/D=$CondaDestination")
Install-Binary -Url $InstallerUrl -Name $InstallerName -ArgumentList $ArgumentList
[System.Environment]::SetEnvironmentVariable("CONDA", $CondaDestination, "Machine")
#region Supply chain security
$localFileHash = (Get-FileHash -Path (Join-Path ${env:TEMP} $installerName) -Algorithm SHA256).Hash
$distributorFileHash = $null
$checksums = (Invoke-RestMethod -Uri 'https://repo.anaconda.com/miniconda/' | ConvertFrom-HTML).SelectNodes('//html/body/table/tr')
ForEach($node in $checksums) {
foreach ($node in $checksums) {
if ($node.ChildNodes[1].InnerText -eq $InstallerName) {
$distributorFileHash = $node.ChildNodes[7].InnerText
}
}
Use-ChecksumComparison -LocalFileHash $localFileHash -DistributorFileHash $distributorFileHash
if ($null -eq $distributorFileHash) {
throw "Unable to find checksum for $InstallerName in https://repo.anaconda.com/miniconda/"
}
#endregion
Install-Binary `
-Url "https://repo.anaconda.com/miniconda/${InstallerName}" `
-InstallArgs @("/S", "/AddToPath=0", "/RegisterPython=0", "/D=$CondaDestination") `
-ExpectedSHA256Sum $distributorFileHash
[System.Environment]::SetEnvironmentVariable("CONDA", $CondaDestination, "Machine")
Invoke-PesterTests -TestFile "Miniconda"
@@ -20,12 +20,10 @@ foreach ($release in $TargetReleases) {
$LatestVersion = $MinorVersions[0]
$installDir = "c:\PROGRA~1\MongoDB"
$binaryName = "mongodb-windows-x86_64-$LatestVersion-signed.msi"
$downloadURL = "https://fastdl.mongodb.org/windows/$BinaryName"
$installArg = "INSTALLLOCATION=$installDir ADDLOCAL=all"
Install-Binary -Url $downloadURL -Name $binaryName -ArgumentList ("/q","/i","${env:Temp}\$binaryName", $installArg) -ExpectedSignature (Get-ToolsetContent).mongodb.signature
Install-Binary `
-Url "https://fastdl.mongodb.org/windows/mongodb-windows-x86_64-$LatestVersion-signed.msi" `
-ExtraInstallArgs @('TARGETDIR=C:\PROGRA~1\MongoDB ADDLOCAL=ALL') `
-ExpectedSignature (Get-ToolsetContent).mongodb.signature
# Add mongodb to the PATH
$mongodbService = "mongodb"
@@ -4,26 +4,26 @@
################################################################################
# Installing visual c++ redistibutable package.
$InstallerName = "vcredist_x64.exe"
$InstallerURI = "https://download.microsoft.com/download/0/5/6/056dcda9-d667-4e27-8001-8a0c6971d6b1/${InstallerName}"
$ArgumentList = ("/install", "/quiet", "/norestart")
$InstallerSignatureThumbrint = "3BDA323E552DB1FDE5F4FBEE75D6D5B2B187EEDC"
Install-Binary -Url $InstallerURI -Name $InstallerName -ArgumentList $ArgumentList -ExpectedSignature $InstallerSignatureThumbrint
Install-Binary `
-Url 'https://download.microsoft.com/download/0/5/6/056dcda9-d667-4e27-8001-8a0c6971d6b1/vcredist_x64.exe' `
-InstallArgs @("/install", "/quiet", "/norestart") `
-ExpectedSignature '3BDA323E552DB1FDE5F4FBEE75D6D5B2B187EEDC'
# Downloading mysql
[version]$MysqlVersion = (Get-ToolsetContent).mysql.version
$MysqlVersionMajorMinor = $MysqlVersion.ToString(2)
if ($MysqlVersion.Build -lt 0) {
$MysqlVersion = (Invoke-RestMethod -Uri "https://dev.mysql.com/downloads/mysql/${MysqlVersionMajorMinor}.html" -Headers @{ 'User-Agent'='curl/8.4.0' } |
Select-String -Pattern "${MysqlVersionMajorMinor}\.\d+").Matches.Value
$MysqlVersion = (Invoke-RestMethod -Uri "https://dev.mysql.com/downloads/mysql/${MysqlVersionMajorMinor}.html" -Headers @{ 'User-Agent' = 'curl/8.4.0' } |
Select-String -Pattern "${MysqlVersionMajorMinor}\.\d+").Matches.Value
}
$MysqlVersionFull = $MysqlVersion.ToString()
$MysqlVersionUrl = "https://cdn.mysql.com/Downloads/MySQL-${MysqlVersionMajorMinor}/mysql-${MysqlVersionFull}-winx64.msi"
Install-Binary -Url $MysqlVersionUrl -Name "mysql-${MysqlVersionFull}-winx64.msi" -ExpectedSignature (Get-ToolsetContent).mysql.signature
Install-Binary `
-Url $MysqlVersionUrl `
-ExpectedSignature (Get-ToolsetContent).mysql.signature
# Adding mysql in system environment path
$MysqlPath = $(Get-ChildItem -Path "C:\PROGRA~1\MySQL" -Directory)[0].FullName
@@ -4,11 +4,9 @@
################################################################################
# .NET 4.8 Dev pack
$InstallerName = "ndp48-devpack-enu.exe"
$InstallerUrl = "https://download.visualstudio.microsoft.com/download/pr/014120d7-d689-4305-befd-3cb711108212/0307177e14752e359fde5423ab583e43/${InstallerName}"
$InstallerSignatureThumbprint = "C82273A065EC470FB1EBDE846A91E6FFB29E9C12"
$ArgumentList = ("Setup", "/passive", "/norestart")
Install-Binary -Url $InstallerUrl -Name $InstallerName -ArgumentList $ArgumentList -ExpectedSignature $InstallerSignatureThumbprint
Install-Binary `
-Url 'https://download.visualstudio.microsoft.com/download/pr/014120d7-d689-4305-befd-3cb711108212/0307177e14752e359fde5423ab583e43/ndp48-devpack-enu.exe' `
-InstallArgs @("Setup", "/passive", "/norestart") `
-ExpectedSignature 'C82273A065EC470FB1EBDE846A91E6FFB29E9C12'
Invoke-PesterTests -TestFile "Tools" -TestName "NET48"
@@ -4,9 +4,7 @@
################################################################################
# .NET 4.8 Dev pack
$InstallerName = "ndp48-x86-x64-allos-enu.exe"
$InstallerUrl = "https://download.visualstudio.microsoft.com/download/pr/2d6bb6b2-226a-4baa-bdec-798822606ff1/8494001c276a4b96804cde7829c04d7f/${InstallerName}"
$InstallerSignatureThumbprint = "ABDCA79AF9DD48A0EA702AD45260B3C03093FB4B"
$ArgumentList = ("Setup", "/passive", "/norestart")
Install-Binary -Url $InstallerUrl -Name $InstallerName -ArgumentList $ArgumentList -ExpectedSignature $InstallerSignatureThumbprint
Install-Binary `
-Url 'https://download.visualstudio.microsoft.com/download/pr/2d6bb6b2-226a-4baa-bdec-798822606ff1/8494001c276a4b96804cde7829c04d7f/ndp48-x86-x64-allos-enu.exe' `
-InstallArgs @("Setup", "/passive", "/norestart") `
-ExpectedSignature 'ABDCA79AF9DD48A0EA702AD45260B3C03093FB4B'
@@ -6,7 +6,7 @@
$NsisVersion = (Get-ToolsetContent).nsis.version
Choco-Install -PackageName nsis -ArgumentList "--version", "$NsisVersion"
Install-ChocoPackage nsis -ArgumentList "--version", "$NsisVersion"
$NsisPath = "${env:ProgramFiles(x86)}\NSIS\"
Add-MachinePathItem $NsisPath
@@ -8,7 +8,7 @@ Stop-Service -Name w3svc | Out-Null
# Install latest nginx in chocolatey
$installDir = "C:\tools"
Choco-Install -PackageName nginx -ArgumentList "--force", "--params", "/installLocation:$installDir /port:80"
Install-ChocoPackage nginx -ArgumentList "--force", "--params", "/installLocation:$installDir /port:80"
# Stop and disable Nginx service
Stop-Service -Name nginx
@@ -11,9 +11,9 @@ New-Item -Path $PrefixPath -Force -ItemType Directory
New-Item -Path $CachePath -Force -ItemType Directory
$defaultVersion = (Get-ToolsetContent).node.default
$versionToInstall = Get-LatestChocoPackageVersion -TargetVersion $defaultVersion -PackageName "nodejs"
$versionToInstall = Resolve-ChocoPackageVersion -PackageName "nodejs" -TargetVersion $defaultVersion
Choco-Install -PackageName nodejs -ArgumentList "--version=$versionToInstall"
Install-ChocoPackage nodejs -ArgumentList "--version=$versionToInstall"
Add-MachinePathItem $PrefixPath
$env:Path = Get-MachinePath
@@ -7,7 +7,7 @@
$arch = 'INTEL'
$bits = '64'
$light = $false
$installer = "exe"
$installerType = "exe"
$version = (Get-ToolsetContent).openssl.version
$installDir = "$Env:ProgramFiles\OpenSSL"
@@ -15,35 +15,27 @@ $installDir = "$Env:ProgramFiles\OpenSSL"
$jsonUrl = 'https://raw.githubusercontent.com/slproweb/opensslhashes/master/win32_openssl_hashes.json'
$installersAvailable = (Invoke-RestMethod $jsonUrl).files
$installerNames = $installersAvailable | Get-Member -MemberType NoteProperty | Select-Object -ExpandProperty Name
$distributor_file_hash = $null
$installerUrl = $null
$installerName = $null
$installerHash = $null
$installersAvailable | Get-Member -MemberType NoteProperty | ForEach-Object {
$key = $_.Name
if(($installersAvailable.$key.light -eq $light) -and ($installersAvailable.$key.arch -eq $arch) -and ($installersAvailable.$key.bits -eq $bits) -and ($installersAvailable.$key.installer -eq $installer) -and ($installersAvailable.$key.basever -eq $version)) {
$installerUrl = $installersAvailable.$key.url
$installerName = $key
$distributor_file_hash = $installersAvailable.$key.sha512
}
foreach ($key in $installerNames) {
$installer = $installersAvailable.$key
if (($installer.light -eq $light) -and ($installer.arch -eq $arch) -and ($installer.bits -eq $bits) -and ($installer.installer -eq $installerType) -and ($installer.basever -eq $version)) {
$installerUrl = $installer.url
$installerHash = $installer.sha512
}
}
# Invoke installation
$installerArgs = '/silent', '/sp-', '/suppressmsgboxes', "/DIR=`"$installDir`""
Install-Binary -Url "$installerUrl" -Name "$installerName" -ArgumentList $installerArgs
#region Supply chain security
Write-Verbose "Performing checksum verification"
$local_file_hash = (Get-FileHash -Path (Join-Path ${env:TEMP} $installerName) -Algorithm SHA512).Hash
if ($local_file_hash -ne $distributor_file_hash) {
Write-Host "hash must be equal to: ${distributor_file_hash}"
Write-Host "actual hash is: ${local_file_hash}"
throw 'Checksum verification failed, please rerun install'
if ($null -eq $installerUrl) {
throw "Installer not found for version $version"
}
#endregion
Install-Binary `
-Url $installerUrl `
-InstallArgs @('/silent', '/sp-', '/suppressmsgboxes', "/DIR=`"$installDir`"") `
-ExpectedSHA512Sum $installerHash
# Update PATH
Add-MachinePathItem "$installDir\bin"
+3 -3
View File
@@ -6,11 +6,11 @@
# Install latest PHP in chocolatey
$installDir = "c:\tools\php"
$phpMajorMinor = (Get-ToolsetContent).php.version
$phpVersionToInstall = Get-LatestChocoPackageVersion -TargetVersion $phpMajorMinor -PackageName "php"
Choco-Install -PackageName php -ArgumentList "--params", "/InstallDir:$installDir", "--version=$phpVersionToInstall"
$phpVersionToInstall = Resolve-ChocoPackageVersion -PackageName "php" -TargetVersion $phpMajorMinor
Install-ChocoPackage php -ArgumentList "--params", "/InstallDir:$installDir", "--version=$phpVersionToInstall"
# Install latest Composer in chocolatey
Choco-Install -PackageName composer -ArgumentList "--ia", "/DEV=$installDir /PHP=$installDir"
Install-ChocoPackage composer -ArgumentList "--install-args", "/DEV=$installDir /PHP=$installDir"
# update path to extensions and enable curl and mbstring extensions, and enable php openssl extensions.
((Get-Content -path $installDir\php.ini -Raw) -replace ';extension=curl','extension=curl' -replace ';extension=mbstring','extension=mbstring' -replace ';extension_dir = "ext"','extension_dir = "ext"' -replace ';extension=openssl','extension=openssl') | Set-Content -Path $installDir\php.ini
@@ -44,11 +44,14 @@ do {
$increment--
}
} while (!$response)
# Return the previous value of ErrorAction and invoke Install-Binary function
$ErrorActionPreference = $ErrorActionOldValue
$InstallerName = $InstallerUrl.Split('/')[-1]
$ArgumentList = ("--install_runtimes 0", "--superpassword root", "--enable_acledit 1", "--unattendedmodeui none", "--mode unattended")
Install-Binary -Url $InstallerUrl -Name $InstallerName -ArgumentList $ArgumentList -ExpectedSignature (Get-ToolsetContent).postgresql.signature
$InstallerArgs = @("--install_runtimes 0", "--superpassword root", "--enable_acledit 1", "--unattendedmodeui none", "--mode unattended")
Install-Binary `
-Url $InstallerUrl `
-InstallArgs $InstallerArgs `
-ExpectedSignature (Get-ToolsetContent).postgresql.signature
# Get Path to pg_ctl.exe
$pgPath = (Get-CimInstance Win32_Service -Filter "Name LIKE 'postgresql-%'").PathName
@@ -6,20 +6,6 @@
$ErrorActionPreference = "Stop"
#region functions
Function Get-PowerShellCoreHash
{
Param (
[Parameter(Mandatory = $True)]
[string] $Release
)
$hashURL = "https://github.com/PowerShell/PowerShell/releases/download/v${Release}/hashes.sha256"
(Invoke-RestMethod -Uri $hashURL).ToString().Split("`n").Where({ $_ -ilike "*PowerShell-${Release}-win-x64.msi*" }).Split(' ')[0]
}
#endregion
$tempDir = Join-Path ([System.IO.Path]::GetTempPath()) ([System.IO.Path]::GetRandomFileName())
$null = New-Item -ItemType Directory -Path $tempDir -Force -ErrorAction SilentlyContinue
try {
@@ -28,33 +14,12 @@ try {
$metadata = Invoke-RestMethod https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/metadata.json
$release = $metadata.LTSReleaseTag[0] -replace '^v'
$packageName = "PowerShell-${release}-win-x64.msi"
$downloadUrl = "https://github.com/PowerShell/PowerShell/releases/download/v${release}/PowerShell-${release}-win-x64.msi"
$downloadURL = "https://github.com/PowerShell/PowerShell/releases/download/v${release}/${packageName}"
Write-Verbose "About to download package from '$downloadURL'" -Verbose
$hashUrl = "https://github.com/PowerShell/PowerShell/releases/download/v${release}/hashes.sha256"
$expectedSHA256Sum = (Invoke-RestMethod -Uri $hashURL).ToString().Split("`n").Where({ $_ -ilike "*PowerShell-${Release}-win-x64.msi*" }).Split(' ')[0]
$packagePath = Join-Path -Path $tempDir -ChildPath $packageName
Invoke-WebRequest -Uri $downloadURL -OutFile $packagePath
#region Supply chain security
Write-Verbose "Performing checksum verification"
$distributor_file_hash = Get-PowerShellCoreHash -Release $release
$local_file_hash = (Get-FileHash -Path $packagePath -Algorithm SHA256).Hash
if ($local_file_hash -ne $distributor_file_hash) {
Write-Host "hash must be equal to: ${distributor_file_hash}"
Write-Host "actual hash is: ${local_file_hash}"
throw 'Checksum verification failed, please rerun install'
}
#endregion
Write-Verbose "Performing quiet install"
$ArgumentList=@("/i", $packagePath, "/quiet")
$process = Start-Process msiexec -ArgumentList $ArgumentList -Wait -PassThru
if ($process.exitcode -ne 0) {
throw "Quiet install failed, please rerun install without -Quiet switch or ensure you have administrator rights"
}
Install-Binary -Url $downloadUrl -ExpectedSHA256Sum $expectedSHA256Sum
} finally {
# Restore original value
[Net.ServicePointManager]::SecurityProtocol = $originalValue
+3 -3
View File
@@ -3,9 +3,9 @@
## Desc: Install R for Windows
################################################################################
Choco-Install R.Project
Choco-Install rtools
Install-ChocoPackage R.Project
Install-ChocoPackage rtools
$rscriptPath = Resolve-Path "C:\Program Files\R\*\bin\x64"
Add-MachinePathItem $rscriptPath
Invoke-PesterTests -TestFile "Tools" -TestName "R"
Invoke-PesterTests -TestFile "Tools" -TestName "R"
@@ -3,7 +3,7 @@
## Desc: Install OLE DB Driver for SQL Server
################################################################################
$binaryDownloadPath = Start-DownloadWithRetry "https://go.microsoft.com/fwlink/?linkid=2242656" "msoledbsql.msi"
$binarySignatureThumbprint = "6E78B3DCE2998F6C2457C3E54DA90A01034916AE"
$ArgumentList = ("/i", "$binaryDownloadPath", "ADDLOCAL=ALL", "IACCEPTMSOLEDBSQLLICENSETERMS=YES", "/qn")
Install-Binary -FilePath $binaryDownloadPath -ArgumentList $ArgumentList -ExpectedSignature $binarySignatureThumbprint
Install-Binary -Type MSI `
-Url "https://go.microsoft.com/fwlink/?linkid=2242656" `
-ExtraInstallArgs @("ADDLOCAL=ALL", "IACCEPTMSOLEDBSQLLICENSETERMS=YES") `
-ExpectedSignature '6E78B3DCE2998F6C2457C3E54DA90A01034916AE'
@@ -3,18 +3,18 @@
## Desc: Install SQL PowerShell tool
################################################################################
$BaseUrl = "https://download.microsoft.com/download/B/1/7/B1783FE9-717B-4F78-A39A-A2E27E3D679D/ENU/x64"
$SignatureThumbrint = "9ACA9419E53D3C9E56396DD2335FF683A8B0B8F3"
$baseUrl = "https://download.microsoft.com/download/B/1/7/B1783FE9-717B-4F78-A39A-A2E27E3D679D/ENU/x64"
$signatureThumbrint = "9ACA9419E53D3C9E56396DD2335FF683A8B0B8F3"
# install required MSIs
$SQLSysClrTypesName = "SQLSysClrTypes.msi"
$SQLSysClrTypesUrl = "${BaseUrl}/${SQLSysClrTypesName}"
Install-Binary -Url $SQLSysClrTypesUrl -Name $SQLSysClrTypesName -ExpectedSignature $SignatureThumbrint
Install-Binary `
-Url "${baseUrl}/SQLSysClrTypes.msi" `
-ExpectedSignature $signatureThumbrint
$SharedManagementObjectsName = "SharedManagementObjects.msi"
$SharedManagementObjectsUrl = "${BaseUrl}/${SharedManagementObjectsName}"
Install-Binary -Url $SharedManagementObjectsUrl -Name $SharedManagementObjectsName -ExpectedSignature $SignatureThumbrint
Install-Binary `
-Url "${baseUrl}/SharedManagementObjects.msi" `
-ExpectedSignature $signatureThumbrint
$PowerShellToolsName = "PowerShellTools.msi"
$PowerShellToolsUrl = "${BaseUrl}/${PowerShellToolsName}"
Install-Binary -Url $PowerShellToolsUrl -Name $PowerShellToolsName -ExpectedSignature $SignatureThumbrint
Install-Binary `
-Url "${baseUrl}/PowerShellTools.msi" `
-ExpectedSignature $signatureThumbrint
+1 -1
View File
@@ -5,7 +5,7 @@
# Install the latest version of sbt.
# See https://chocolatey.org/packages/sbt
Choco-Install -PackageName sbt
Install-ChocoPackage sbt
$env:SBT_HOME="${env:ProgramFiles(x86)}\sbt"
@@ -8,18 +8,19 @@
New-Item -Path 'C:\Windows\Installer' -ItemType Directory -Force
# Get Service Fabric components versions
$serviceFabricRuntimeVersion = (Get-ToolsetContent).serviceFabric.runtime.version
$serviceFabricSDKVersion = (Get-ToolsetContent).serviceFabric.sdk.version
$runtimeVersion = (Get-ToolsetContent).serviceFabric.runtime.version
$sdkVersion = (Get-ToolsetContent).serviceFabric.sdk.version
$urlBase = "https://download.microsoft.com/download/b/8/a/b8a2fb98-0ec1-41e5-be98-9d8b5abf7856"
# Install Service Fabric Runtime for Windows
$InstallerName = "MicrosoftServiceFabric.${serviceFabricRuntimeVersion}.exe"
$InstallerUrl = "https://download.microsoft.com/download/b/8/a/b8a2fb98-0ec1-41e5-be98-9d8b5abf7856/${InstallerName}"
$ArgumentList = ("/accepteula ","/quiet","/force")
Install-Binary -Url $InstallerUrl -Name $InstallerName -ArgumentList $ArgumentList -ExpectedSignature (Get-ToolsetContent).serviceFabric.runtime.signature
Install-Binary `
-Url "${urlBase}/MicrosoftServiceFabric.${runtimeVersion}.exe" `
-InstallArgs @("/accepteula ", "/quiet", "/force") `
-ExpectedSignature (Get-ToolsetContent).serviceFabric.runtime.signature
# Install Service Fabric SDK
$InstallerName = "MicrosoftServiceFabricSDK.${serviceFabricSDKVersion}.msi"
$InstallerUrl = "https://download.microsoft.com/download/b/8/a/b8a2fb98-0ec1-41e5-be98-9d8b5abf7856/${InstallerName}"
Install-Binary -Url $InstallerUrl -Name $InstallerName -ExpectedSignature (Get-ToolsetContent).serviceFabric.sdk.signature
Install-Binary `
-Url "${urlBase}/MicrosoftServiceFabricSDK.${sdkVersion}.msi" `
-ExpectedSignature (Get-ToolsetContent).serviceFabric.sdk.signature
Invoke-PesterTests -TestFile "Tools" -TestName "ServiceFabricSDK"
@@ -3,14 +3,18 @@
## Desc: Install Visual C++ Redistributable
################################################################################
$vc2010x86Name = "vcredist_x86.exe"
$vc2010x86URI = "https://download.microsoft.com/download/1/6/5/165255E7-1014-4D0A-B094-B6A430A6BFFC/${vc2010x86Name}"
$vc2010x64Name = "vcredist_x64.exe"
$vc2010x64URI = "https://download.microsoft.com/download/1/6/5/165255E7-1014-4D0A-B094-B6A430A6BFFC/${Vc2010x64Name}"
$baseUrl = "https://download.microsoft.com/download/1/6/5/165255E7-1014-4D0A-B094-B6A430A6BFFC"
$argumentList = ("/install", "/quiet", "/norestart")
$vcSignatureThumbprint = "ABDCA79AF9DD48A0EA702AD45260B3C03093FB4B"
$signatureThumbrint = "ABDCA79AF9DD48A0EA702AD45260B3C03093FB4B"
Install-Binary -Url $vc2010x86URI -Name $vc2010x86Name -ArgumentList $argumentList -ExpectedSignature $vcSignatureThumbprint
Install-Binary -Url $vc2010x64URI -Name $vc2010x64Name -ArgumentList $argumentList -ExpectedSignature $vcSignatureThumbprint
Install-Binary `
-Url "${baseUrl}/vcredist_x86.exe" `
-InstallArgs $argumentList `
-ExpectedSignature $signatureThumbrint
Install-Binary `
-Url "${baseUrl}/vcredist_x64.exe" `
-InstallArgs $argumentList `
-ExpectedSignature $signatureThumbrint
Invoke-PesterTests -TestFile "Tools" -TestName "VCRedist"
@@ -16,8 +16,9 @@ $vsixPackagesList | ForEach-Object {
if ($vsixPackage.FileName.EndsWith(".vsix")) {
Install-VsixExtension -Url $vsixPackage.DownloadUri -Name $vsixPackage.FileName
} else {
$argumentList = ('/install', '/quiet', '/norestart')
Install-Binary -Url $vsixPackage.DownloadUri -Name $vsixPackage.FileName -ArgumentList $argumentList
Install-Binary `
-Url $vsixPackage.DownloadUri `
-InstallArgs @('/install', '/quiet', '/norestart')
}
}
@@ -30,29 +30,25 @@ $newContent = '{"Extensions":[{"Key":"1e906ff5-9da8-4091-a299-5c253c55fdc9","Val
Set-Content -Path "$vsInstallRoot\Common7\IDE\Extensions\MachineState.json" -Value $newContent
if (Test-IsWin19) {
# Install Windows 10 SDK version 10.0.14393.795
$sdkSignatureThumbprint = "C91545B333C52C4465DE8B90A3FAF4E1D9C58DFA"
$sdkUrl = "https://go.microsoft.com/fwlink/p/?LinkId=838916"
$sdkFileName = "sdksetup14393.exe"
$argumentList = ("/q", "/norestart", "/ceip off", "/features OptionId.WindowsSoftwareDevelopmentKit")
Install-Binary -Url $sdkUrl -Name $sdkFileName -ArgumentList $argumentList -ExpectedSignature $sdkSignatureThumbprint
Install-Binary -Type EXE `
-Url 'https://go.microsoft.com/fwlink/p/?LinkId=838916' `
-InstallArgs @("/q", "/norestart", "/ceip off", "/features OptionId.WindowsSoftwareDevelopmentKit") `
-ExpectedSignature 'C91545B333C52C4465DE8B90A3FAF4E1D9C58DFA'
# Install Windows 11 SDK version 10.0.22621.0
$sdkSignatureThumbprint = "E4C5C5FCDB68B930EE4E19BC25D431EF6D864C51"
$sdkUrl = "https://go.microsoft.com/fwlink/p/?linkid=2196241"
$sdkFileName = "sdksetup22621.exe"
$argumentList = ("/q", "/norestart", "/ceip off", "/features OptionId.UWPManaged OptionId.UWPCPP OptionId.UWPLocalized OptionId.DesktopCPPx86 OptionId.DesktopCPPx64 OptionId.DesktopCPParm64")
Install-Binary -Url $sdkUrl -Name $sdkFileName -ArgumentList $argumentList -ExpectedSignature $sdkSignatureThumbprint
Install-Binary -Type EXE `
-Url 'https://go.microsoft.com/fwlink/p/?linkid=2196241' `
-InstallArgs @("/q", "/norestart", "/ceip off", "/features OptionId.UWPManaged OptionId.UWPCPP OptionId.UWPLocalized OptionId.DesktopCPPx86 OptionId.DesktopCPPx64 OptionId.DesktopCPParm64") `
-ExpectedSignature 'E4C5C5FCDB68B930EE4E19BC25D431EF6D864C51'
}
if (Test-IsWin22) {
# Install Windows 10 SDK version 10.0.17763
$sdkSignatureThumbprint = "7535269B94C1FEA4A5EF6D808E371DA242F27936"
$sdkUrl = "https://go.microsoft.com/fwlink/p/?LinkID=2033908"
$sdkFileName = "sdksetup17763.exe"
$argumentList = ("/q", "/norestart", "/ceip off", "/features OptionId.UWPManaged OptionId.UWPCPP OptionId.UWPLocalized OptionId.DesktopCPPx86 OptionId.DesktopCPPx64 OptionId.DesktopCPParm64")
Install-Binary -Url $sdkUrl -Name $sdkFileName -ArgumentList $argumentList -ExpectedSignature $sdkSignatureThumbprint
Install-Binary -Type EXE `
-Url 'https://go.microsoft.com/fwlink/p/?LinkID=2033908' `
-InstallArgs @("/q", "/norestart", "/ceip off", "/features OptionId.UWPManaged OptionId.UWPCPP OptionId.UWPLocalized OptionId.DesktopCPPx86 OptionId.DesktopCPPx64 OptionId.DesktopCPParm64") `
-ExpectedSignature '7535269B94C1FEA4A5EF6D808E371DA242F27936'
}
Invoke-PesterTests -TestFile "VisualStudio"
+20 -20
View File
@@ -4,33 +4,33 @@
################################################################################
# Requires Windows SDK with the same version number as the WDK
if (Test-IsWin22) {
# SDK available through Visual Studio
$wdkUrl = "https://go.microsoft.com/fwlink/?linkid=2249371"
$FilePath = "C:\Program Files (x86)\Windows Kits\10\Vsix\VS2022\*\WDK.vsix"
$wdkSignatureThumbprint = "7C94971221A799907BB45665663BBFD587BAC9F8"
} elseif (Test-IsWin19) {
$winSdkUrl = "https://go.microsoft.com/fwlink/?linkid=2173743"
if (Test-IsWin19) {
# Install all features without showing the GUI using winsdksetup.exe
Install-Binary -Type EXE `
-Url 'https://go.microsoft.com/fwlink/?linkid=2173743' `
-InstallArgs @("/features", "+", "/quiet") `
-ExpectedSignature '44796EB5BD439B4BFB078E1DC2F8345AE313CBB1'
$wdkUrl = "https://go.microsoft.com/fwlink/?linkid=2166289"
$FilePath = "C:\Program Files (x86)\Windows Kits\10\Vsix\VS2019\WDK.vsix"
$wdkSignatureThumbprint = "914A09C2E02C696AF394048BCB8D95449BCD5B9E"
$winSdkSignatureThumbprint = "44796EB5BD439B4BFB078E1DC2F8345AE313CBB1"
$wdkExtensionPath = "C:\Program Files (x86)\Windows Kits\10\Vsix\VS2019\WDK.vsix"
} elseif (Test-IsWin22) {
# SDK is available through Visual Studio
$wdkUrl = "https://go.microsoft.com/fwlink/?linkid=2249371"
$wdkSignatureThumbprint = "7C94971221A799907BB45665663BBFD587BAC9F8"
$wdkExtensionPath = "C:\Program Files (x86)\Windows Kits\10\Vsix\VS2022\*\WDK.vsix"
} else {
throw "Invalid version of Visual Studio is found. Either 2019 or 2022 are required"
}
$argumentList = ("/features", "+", "/quiet")
if (Test-IsWin19) {
# `winsdksetup.exe /features + /quiet` installs all features without showing the GUI
Install-Binary -Url $winSdkUrl -Name "winsdksetup.exe" -ArgumentList $argumentList -ExpectedSignature $winSdkSignatureThumbprint
}
# `wdksetup.exe /features + /quiet` installs all features without showing the GUI
Install-Binary -Url $wdkUrl -Name "wdksetup.exe" -ArgumentList $argumentList -ExpectedSignature $wdkSignatureThumbprint
# Install all features without showing the GUI using wdksetup.exe
Install-Binary -Type EXE `
-Url $wdkUrl `
-InstallArgs @("/features", "+", "/quiet") `
-ExpectedSignature $wdkSignatureThumbprint
# Need to install the VSIX to get the build targets when running VSBuild
$FilePath = Resolve-Path -Path $FilePath
Install-VsixExtension -FilePath $FilePath -Name "WDK.vsix" -InstallOnly
$wdkExtensionPath = Resolve-Path -Path $wdkExtensionPath
Install-VsixExtension -FilePath $wdkExtensionPath -Name "WDK.vsix" -InstallOnly
Invoke-PesterTests -TestFile "WDK"
@@ -3,10 +3,8 @@
## Desc: Install WebPlatformInstaller
################################################################################
# Download and install WebPlatformInstaller
$webPlatformInstallerFile = "WebPlatformInstaller_x64_en-US.msi"
$webPlatformInstallerUrl = "http://go.microsoft.com/fwlink/?LinkId=287166"
$webPlatformInstallerSignatureThumbprint = "C3A3D43788E7ABCD287CB4F5B6583043774F99D2"
Install-Binary -Url $webPlatformInstallerUrl -Name $webPlatformInstallerFile -ExpectedSignature $webPlatformInstallerSignatureThumbprint
Install-Binary -Type MSI `
-Url 'http://go.microsoft.com/fwlink/?LinkId=287166' `
-ExpectedSignature 'C3A3D43788E7ABCD287CB4F5B6583043774F99D2'
Invoke-PesterTests -TestFile "Tools" -TestName "WebPlatformInstaller"
@@ -3,12 +3,13 @@
## Desc: Install Windows Application Driver (WinAppDriver)
####################################################################################
$LatestReleaseUrl = 'https://api.github.com/repos/microsoft/WinAppDriver/releases/latest'
$InstallerUrl = (Invoke-RestMethod -Uri $LatestReleaseUrl).assets.browser_download_url
$InstallerName = "WindowsApplicationDriver.msi"
$InstallerSignatureThumbprint = "2485A7AFA98E178CB8F30C9838346B514AEA4769"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Install-Binary -Url $InstallerUrl -Name $InstallerName -ExpectedSignature $InstallerSignatureThumbprint
$latestReleaseUrl = 'https://api.github.com/repos/microsoft/WinAppDriver/releases/latest'
$installerUrl = (Invoke-RestMethod -Uri $latestReleaseUrl).assets.browser_download_url
Install-Binary `
-Url $installerUrl `
-ExpectedSignature '2485A7AFA98E178CB8F30C9838346B514AEA4769'
Invoke-PesterTests -TestFile "WinAppDriver" -TestName "WinAppDriver"
+1 -1
View File
@@ -3,6 +3,6 @@
## Desc: Install WIX.
################################################################################
Choco-Install -PackageName wixtoolset -ArgumentList "--force"
Install-ChocoPackage wixtoolset -ArgumentList "--force"
Invoke-PesterTests -TestFile "Wix"
@@ -1,4 +1,4 @@
function Choco-Install {
function Install-ChocoPackage {
[CmdletBinding()]
param(
[Parameter(Mandatory)]
@@ -9,8 +9,7 @@ function Choco-Install {
process {
$count = 1
while($true)
{
while ($true) {
Write-Host "Running [#$count]: choco install $packageName -y $argumentList"
choco install $packageName -y @argumentList --no-progress
@@ -18,8 +17,7 @@ function Choco-Install {
if ($pkg) {
Write-Host "Package installed: $pkg"
break
}
else {
} else {
$count++
if ($count -ge $retryCount) {
Write-Host "Could not install $packageName after $count attempts"
@@ -31,20 +29,7 @@ function Choco-Install {
}
}
function Send-RequestToChocolateyPackages {
param(
[Parameter(Mandatory)]
[string] $FilterQuery,
[string] $Url = "https://community.chocolatey.org/api",
[int] $ApiVersion = 2
)
$response = Invoke-RestMethod "$Url/v$ApiVersion/Packages()?$filterQuery"
return $response
}
function Get-LatestChocoPackageVersion {
function Resolve-ChocoPackageVersion {
param(
[Parameter(Mandatory)]
[string] $PackageName,
@@ -56,10 +41,10 @@ function Get-LatestChocoPackageVersion {
[int]$versionNumbers[-1] += 1
$incrementedVersion = $versionNumbers -join "."
$filterQuery = "`$filter=(Id eq '$PackageName') and (IsPrerelease eq false) and (Version ge '$TargetVersion') and (Version lt '$incrementedVersion')"
$latestVersion = (Send-RequestToChocolateyPackages -FilterQuery $filterQuery).properties.Version |
Where-Object {$_ -Like "$TargetVersion.*" -or $_ -eq $TargetVersion} |
Sort-Object {[version]$_} |
$latestVersion = (Invoke-RestMethod "https://community.chocolatey.org/api/v2/Packages()?$filterQuery").properties.Version |
Where-Object { $_ -Like "$TargetVersion.*" -or $_ -eq $TargetVersion } |
Sort-Object { [version]$_ } |
Select-Object -Last 1
return $latestVersion
}
}
@@ -34,9 +34,9 @@ Export-ModuleMember -Function @(
'Get-WinVersion'
'Test-IsWin22'
'Test-IsWin19'
'Choco-Install'
'Install-ChocoPackage'
'Send-RequestToCocolateyPackages'
'Get-LatestChocoPackageVersion'
'Resolve-ChocoPackageVersion'
'Get-GitHubPackageDownloadUrl'
'Extract-7Zip'
'Invoke-SBWithRetry'
+108 -77
View File
@@ -1,94 +1,132 @@
function Install-Binary
{
function Install-Binary {
<#
.SYNOPSIS
A helper function to install executables.
A function to install binaries from either a URL or a local path.
.DESCRIPTION
Download and install .exe or .msi binaries from specified URL.
This function downloads and installs .exe or .msi binaries from a specified URL or a local path. It also supports checking the binary's signature and SHA256/SHA512 sum before installation.
.PARAMETER Url
The URL from which the binary will be downloaded. Required parameter.
The URL from which the binary will be downloaded. This parameter is required if LocalPath is not specified.
.PARAMETER Name
The Name with which binary will be downloaded. Required parameter.
.PARAMETER LocalPath
The local path of the binary to be installed. This parameter is required if Url is not specified.
.PARAMETER ArgumentList
The list of arguments that will be passed to the installer. Required for .exe binaries.
.PARAMETER Type
The type of the binary to be installed. Valid values are "MSI" and "EXE". If not specified, the type is inferred from the file extension.
.PARAMETER InstallArgs
The list of arguments that will be passed to the installer. Cannot be used together with ExtraInstallArgs.
.PARAMETER ExtraInstallArgs
Additional arguments that will be passed to the installer. Cannot be used together with InstallArgs.
.PARAMETER ExpectedSignature
The expected signature of the binary. If specified, the binary's signature is checked before installation.
.PARAMETER ExpectedSHA256Sum
The expected SHA256 sum of the binary. If specified, the binary's SHA256 sum is checked before installation.
.PARAMETER ExpectedSHA512Sum
The expected SHA512 sum of the binary. If specified, the binary's SHA512 sum is checked before installation.
.EXAMPLE
Install-Binary -Url "https://go.microsoft.com/fwlink/p/?linkid=2083338" -Name "winsdksetup.exe" -ArgumentList ("/features", "+", "/quiet") -ExpectedSignature "XXXXXXXXXXXXXXXXXXXXXXXXXX"
Install-Binary -Url "https://go.microsoft.com/fwlink/p/?linkid=2083338" -Type EXE -InstallArgs ("/features", "+", "/quiet") -ExpectedSignature "A5C7D5B7C838D5F89DDBEDB85B2C566B4CDA881F"
#>
Param
(
[Parameter(Mandatory, ParameterSetName="Url")]
[Parameter(Mandatory, ParameterSetName = "Url")]
[String] $Url,
[Parameter(Mandatory, ParameterSetName="Url")]
[String] $Name,
[Parameter(Mandatory, ParameterSetName="LocalPath")]
[String] $FilePath,
[String[]] $ArgumentList,
[String[]] $ExpectedSignature
[Parameter(Mandatory, ParameterSetName = "LocalPath")]
[String] $LocalPath,
[ValidateSet("MSI", "EXE")]
[String] $Type,
[String[]] $InstallArgs,
[String[]] $ExtraInstallArgs,
[String[]] $ExpectedSignature,
[String] $ExpectedSHA256Sum,
[String] $ExpectedSHA512Sum
)
if ($PSCmdlet.ParameterSetName -eq "LocalPath")
{
$name = Split-Path -Path $FilePath -Leaf
}
else
{
Write-Host "Downloading $Name..."
$filePath = Start-DownloadWithRetry -Url $Url -Name $Name
if ($PSCmdlet.ParameterSetName -eq "LocalPath") {
if (-not (Test-Path -Path $LocalPath)) {
throw "LocalPath parameter is specified, but the file does not exist."
}
if (-not $Type) {
$Type = ([System.IO.Path]::GetExtension($LocalPath)).Replace(".", "").ToUpper()
if ($Type -ne "MSI" -and $Type -ne "EXE") {
throw "LocalPath parameter is specified, but the file extension is not .msi or .exe. Please specify the Type parameter."
}
}
$filePath = $LocalPath
} else {
if (-not $Type) {
$Type = ([System.IO.Path]::GetExtension($Url)).Replace(".", "").ToUpper()
if ($Type -ne "MSI" -and $Type -ne "EXE") {
throw "Cannot determine the file type from the URL. Please specify the Type parameter."
}
}
$fileName = [System.IO.Path]::GetFileNameWithoutExtension([System.IO.Path]::GetRandomFileName()) + ".$Type".ToLower()
$filePath = Start-DownloadWithRetry -Url $Url -Name $fileName
}
if ($PSBoundParameters.ContainsKey('ExpectedSignature'))
{
if ($ExpectedSignature)
{
if ($PSBoundParameters.ContainsKey('ExpectedSignature')) {
if ($ExpectedSignature) {
Test-FileSignature -FilePath $filePath -ExpectedThumbprint $ExpectedSignature
}
else
{
} else {
throw "ExpectedSignature parameter is specified, but no signature is provided."
}
}
# MSI binaries should be installed via msiexec.exe
$fileExtension = ([System.IO.Path]::GetExtension($Name)).Replace(".", "")
if ($fileExtension -eq "msi")
{
if (-not $ArgumentList)
{
$ArgumentList = ('/i', $filePath, '/QN', '/norestart')
}
$filePath = "msiexec.exe"
if ($ExpectedSHA256Sum) {
$fileHash = (Get-FileHash -Path $filePath -Algorithm SHA256).Hash
Use-ChecksumComparison $fileHash $ExpectedSHA256Sum
}
try
{
$installStartTime = Get-Date
Write-Host "Starting Install $Name..."
$process = Start-Process -FilePath $filePath -ArgumentList $ArgumentList -Wait -PassThru
$exitCode = $process.ExitCode
$installCompleteTime = [math]::Round(($(Get-Date) - $installStartTime).TotalSeconds, 2)
if ($exitCode -eq 0 -or $exitCode -eq 3010)
{
Write-Host "Installation successful in $installCompleteTime seconds"
if ($ExpectedSHA512Sum) {
$fileHash = (Get-FileHash -Path $filePath -Algorithm SHA512).Hash
Use-ChecksumComparison $fileHash $ExpectedSHA512Sum
}
if ($ExtraInstallArgs -and $InstallArgs) {
throw "InstallArgs and ExtraInstallArgs parameters cannot be used together."
}
if ($Type -eq "MSI") {
# MSI binaries should be installed via msiexec.exe
if ($ExtraInstallArgs) {
$InstallArgs = @('/i', $filePath, '/qn', '/norestart') + $ExtraInstallArgs
} elseif (-not $InstallArgs) {
Write-Host "No arguments provided for MSI binary. Using default arguments: /i, /qn, /norestart"
$InstallArgs = @('/i', $filePath, '/qn', '/norestart')
}
else
{
Write-Host "Non zero exit code returned by the installation process: $exitCode"
Write-Host "Total time elapsed: $installCompleteTime seconds"
exit $exitCode
$filePath = "msiexec.exe"
} else {
# EXE binaries should be started directly
if ($ExtraInstallArgs) {
$InstallArgs = $ExtraInstallArgs
}
}
catch
{
$installStartTime = Get-Date
Write-Host "Starting Install $Name..."
try {
$process = Start-Process -FilePath $filePath -ArgumentList $InstallArgs -Wait -PassThru
$exitCode = $process.ExitCode
$installCompleteTime = [math]::Round(($(Get-Date) - $installStartTime).TotalSeconds, 2)
Write-Host "Failed to install the $fileExtension ${Name}: $($_.Exception.Message)"
Write-Host "Installation failed after $installCompleteTime seconds"
exit 1
if ($exitCode -eq 0) {
Write-Host "Installation successful in $installCompleteTime seconds"
} elseif ($exitCode -eq 3010) {
Write-Host "Installation successful in $installCompleteTime seconds. Reboot is required."
} else {
Write-Host "Installation process returned unexpected exit code: $exitCode"
Write-Host "Time elapsed: $installCompleteTime seconds"
exit $exitCode
}
} catch {
$installCompleteTime = [math]::Round(($(Get-Date) - $installStartTime).TotalSeconds, 2)
Write-Host "Installation failed in $installCompleteTime seconds"
}
}
@@ -171,8 +209,7 @@ function Set-SvcWithErrHandling {
}
}
function Start-DownloadWithRetry
{
function Start-DownloadWithRetry {
Param
(
[Parameter(Mandatory)]
@@ -190,26 +227,20 @@ function Start-DownloadWithRetry
$downloadStartTime = Get-Date
# Default retry logic for the package.
while ($Retries -gt 0)
{
try
{
Write-Host "Downloading package from: $Url to path $filePath."
while ($Retries -gt 0) {
try {
$downloadAttemptStartTime = Get-Date
Write-Host "Downloading package from: $Url to path $filePath ."
(New-Object System.Net.WebClient).DownloadFile($Url, $filePath)
break
}
catch
{
} catch {
$failTime = [math]::Round(($(Get-Date) - $downloadStartTime).TotalSeconds, 2)
$attemptTime = [math]::Round(($(Get-Date) - $downloadAttemptStartTime).TotalSeconds, 2)
Write-Host "There is an error encounterd after $attemptTime seconds during package downloading:`n $_"
Write-Host "There is an error encounterd after $attemptTime seconds during package downloading:`n$($_.Exception.ToString())"
$Retries--
if ($Retries -eq 0)
{
Write-Host "File can't be downloaded. Please try later or check that file exists by url: $Url"
Write-Host "Total time elapsed $failTime"
if ($Retries -eq 0) {
Write-Host "Package download failed after $failTime seconds"
exit 1
}
@@ -66,14 +66,19 @@ Function Install-VisualStudio {
$responseDataPath = "$env:TEMP\vs_install_response.json"
$responseData | ConvertTo-Json | Out-File -FilePath $responseDataPath
$installStartTime = Get-Date
Write-Host "Starting Install ..."
$bootstrapperArgumentList = ('/c', $bootstrapperFilePath, '--in', $responseDataPath, $ExtraArgs, '--quiet', '--norestart', '--wait', '--nocache' )
Write-Host "Bootstrapper arguments: $bootstrapperArgumentList"
$process = Start-Process -FilePath cmd.exe -ArgumentList $bootstrapperArgumentList -Wait -PassThru
$exitCode = $process.ExitCode
if ($exitCode -eq 0 -or $exitCode -eq 3010) {
Write-Host "Installation successful"
$installCompleteTime = [math]::Round(($(Get-Date) - $installStartTime).TotalSeconds, 2)
if ($exitCode -eq 0) {
Write-Host "Installation successful in $installCompleteTime seconds"
return $exitCode
} elseif ($exitCode -eq 3010) {
Write-Host "Installation successful in $installCompleteTime seconds. Reboot is required."
return $exitCode
} else {
Write-Host "Non zero exit code returned by the installation process : $exitCode"