Improve Windows helpers functions stability (#723)

* Rework windows InstallHelpers; Add retry logic to install function
This commit is contained in:
Maksim Petrov
2020-04-21 11:58:27 +03:00
committed by GitHub
parent 54a14f61b3
commit 8e8fbb4f76
15 changed files with 197 additions and 227 deletions

View File

@@ -13,8 +13,7 @@ Export-ModuleMember -Function @(
'Add-MachinePathItem' 'Add-MachinePathItem'
'Get-SystemVariable' 'Get-SystemVariable'
'Set-SystemVariable' 'Set-SystemVariable'
'Install-MSI' 'Install-Binary'
'Install-EXE'
'Get-ToolcachePackages' 'Get-ToolcachePackages'
'Get-ToolsByName' 'Get-ToolsByName'
'Add-ContentToMarkdown' 'Add-ContentToMarkdown'

View File

@@ -1,163 +1,151 @@
function Install-MSI function Install-Binary
{ {
Param <#
( .SYNOPSIS
[String]$MsiUrl, A helper function to install executables.
[String]$MsiName,
[int]$retries = 5 .DESCRIPTION
Download and install .exe or .msi binaries from specified URL.
.PARAMETER Url
The URL from which the binary will be downloaded. Required parameter.
.PARAMETER Name
The Name with which binary will be downloaded. Required parameter.
.PARAMETER ArgumentList
The list of arguments that will be passed to the installer. Required for .exe binaries.
.EXAMPLE
Install-Binary -Url "https://go.microsoft.com/fwlink/p/?linkid=2083338" -Name "winsdksetup.exe" -ArgumentList ("/features", "+", "/quiet")
#>
Param (
[Parameter(Mandatory)]
[String] $Url,
[Parameter(Mandatory)]
[String] $Name,
[String[]] $ArgumentList
) )
$exitCode = -1 Write-Host "Downloading $Name..."
$filePath = Start-DownloadWithRetry -Url $Url -Name $Name
# MSI binaries should be installed via msiexec.exe
$fileExtension = ([System.IO.Path]::GetExtension($Name)).Replace(".", "")
if ($fileExtension -eq "msi")
{
$ArgumentList = ('/i', $filePath, '/QN', '/norestart')
$filePath = "msiexec.exe"
}
try try
{ {
Write-Host "Downloading $MsiName..." Write-Host "Starting Install $Name..."
$FilePath = "${env:Temp}\$MsiName" $process = Start-Process -FilePath $filePath -ArgumentList $ArgumentList -Wait -PassThru
Invoke-WebRequest -Uri $MsiUrl -OutFile $FilePath
$Arguments = ('/i', $FilePath, '/QN', '/norestart' )
Write-Host "Starting Install $MsiName..."
$process = Start-Process -FilePath msiexec.exe -ArgumentList $Arguments -Wait -PassThru
$exitCode = $process.ExitCode $exitCode = $process.ExitCode
if ($exitCode -eq 0 -or $exitCode -eq 3010) if ($exitCode -eq 0 -or $exitCode -eq 3010)
{ {
Write-Host -Object 'Installation successful' Write-Host "Installation successful"
return $exitCode
} }
else else
{ {
Write-Host -Object "Non zero exit code returned by the installation process : $exitCode." Write-Host "Non zero exit code returned by the installation process: $exitCode"
exit $exitCode exit $exitCode
} }
} }
catch catch
{ {
Write-Host -Object "Failed to install the MSI $MsiName" Write-Host "Failed to install the $fileExtension ${Name}: $($_.Exception.Message)"
Write-Host -Object $_.Exception.Message exit 1
exit -1
}
}
function Install-EXE
{
Param
(
[String]$Url,
[String]$Name,
[String[]]$ArgumentList
)
$exitCode = -1
try
{
Write-Host "Downloading $Name..."
$FilePath = "${env:Temp}\$Name"
Invoke-WebRequest -Uri $Url -OutFile $FilePath
Write-Host "Starting Install $Name..."
$process = Start-Process -FilePath $FilePath -ArgumentList $ArgumentList -Wait -PassThru
$exitCode = $process.ExitCode
if ($exitCode -eq 0 -or $exitCode -eq 3010)
{
Write-Host -Object 'Installation successful'
return $exitCode
}
else
{
Write-Host -Object "Non zero exit code returned by the installation process : $exitCode."
return $exitCode
}
}
catch
{
Write-Host -Object "Failed to install the Executable $Name"
Write-Host -Object $_.Exception.Message
return -1
} }
} }
function Stop-SvcWithErrHandling function Stop-SvcWithErrHandling
<#
.DESCRIPTION
Function for stopping the Windows Service with error handling
.AUTHOR
Andrey Mishechkin v-andmis@microsoft.com
.PARAMETER -ServiceName
The name of stopping service
.PARAMETER -StopOnError
Switch for stopping the script and exit from PowerShell if one service is absent
#>
{ {
<#
.DESCRIPTION
Function for stopping the Windows Service with error handling
.PARAMETER ServiceName
The name of stopping service
.PARAMETER StopOnError
Switch for stopping the script and exit from PowerShell if one service is absent
#>
param ( param (
[Parameter(Mandatory, ValueFromPipeLine = $true)] [string] $ServiceName, [Parameter(Mandatory, ValueFromPipeLine = $true)]
[Parameter()] [switch] $StopOnError [string] $ServiceName,
[switch] $StopOnError
) )
Process { Process
$Service = Get-Service $ServiceName -ErrorAction SilentlyContinue {
if (-not $Service) { $service = Get-Service $ServiceName -ErrorAction SilentlyContinue
Write-Warning "[!] Service [$ServiceName] is not found"; if (-not $service)
if ($StopOnError) { {
exit 1; Write-Warning "[!] Service [$ServiceName] is not found"
if ($StopOnError)
{
exit 1
} }
} }
else { else
Write-Host "Try to stop service [$ServiceName]"; {
try { Write-Host "Try to stop service [$ServiceName]"
Stop-Service -Name $ServiceName -Force; try
$Service.WaitForStatus("Stopped", "00:01:00"); {
Write-Host "Service [$ServiceName] has been stopped successfuly"; Stop-Service -Name $ServiceName -Force
$service.WaitForStatus("Stopped", "00:01:00")
Write-Host "Service [$ServiceName] has been stopped successfuly"
} }
catch { catch
{
Write-Error "[!] Failed to stop service [$ServiceName] with error:" Write-Error "[!] Failed to stop service [$ServiceName] with error:"
$_ | Out-String | Write-Error; $_ | Out-String | Write-Error
} }
} }
} }
} }
function Set-SvcWithErrHandling function Set-SvcWithErrHandling
<#
.DESCRIPTION
Function for setting the Windows Service parameter with error handling
.AUTHOR
Andrey Mishechkin v-andmis@microsoft.com
.PARAMETER -ServiceName
The name of stopping service
.PARAMETER -Arguments
Hashtable for service arguments
#>
{ {
<#
.DESCRIPTION
Function for setting the Windows Service parameter with error handling
.PARAMETER ServiceName
The name of stopping service
.PARAMETER Arguments
Hashtable for service arguments
#>
param ( param (
[Parameter(Mandatory, ValueFromPipeLine = $true)] [string] $ServiceName, [Parameter(Mandatory, ValueFromPipeLine = $true)]
[Parameter(Mandatory)] [hashtable] $Arguments [string] $ServiceName,
[Parameter(Mandatory)]
[hashtable] $Arguments
) )
Process { Process
$Service = Get-Service $ServiceName -ErrorAction SilentlyContinue {
if (-not $Service) { $service = Get-Service $ServiceName -ErrorAction SilentlyContinue
Write-Warning "[!] Service [$ServiceName] is not found"; if (-not $service)
{
Write-Warning "[!] Service [$ServiceName] is not found"
}
try
{
Set-Service $serviceName @Arguments
} }
try { catch
Set-Service $ServiceName @Arguments; {
}
catch {
Write-Error "[!] Failed to set service [$ServiceName] arguments with error:" Write-Error "[!] Failed to set service [$ServiceName] arguments with error:"
$_ | Out-String | Write-Error; $_ | Out-String | Write-Error
} }
} }
} }
@@ -173,36 +161,36 @@ function Start-DownloadWithRetry
[int] $Retries = 20 [int] $Retries = 20
) )
$FilePath = Join-Path -Path $DownloadPath -ChildPath $Name $filePath = Join-Path -Path $DownloadPath -ChildPath $Name
#Default retry logic for the package. #Default retry logic for the package.
while ($retries -gt 0) while ($Retries -gt 0)
{ {
try try
{ {
Write-Host "Downloading package from: $Url to path $FilePath ." Write-Host "Downloading package from: $Url to path $filePath ."
(New-Object System.Net.WebClient).DownloadFile($Url, $FilePath) (New-Object System.Net.WebClient).DownloadFile($Url, $filePath)
break break
} }
catch catch
{ {
Write-Host "There is an error during package downloading:`n $_" Write-Host "There is an error during package downloading:`n $_"
$retries-- $Retries--
if ($retries -eq 0) if ($Retries -eq 0)
{ {
Write-Host "File can't be downloaded. Please try later or check that file exists by url: $Url" Write-Host "File can't be downloaded. Please try later or check that file exists by url: $Url"
exit 1 exit 1
} }
Write-Host "Waiting 30 seconds before retrying. Retries left: $retries" Write-Host "Waiting 30 seconds before retrying. Retries left: $Retries"
Start-Sleep -Seconds 30 Start-Sleep -Seconds 30
} }
} }
return $FilePath return $filePath
} }
function Install-VsixExtension function Install-VsixExtension
{ {
Param Param
@@ -217,12 +205,12 @@ function Install-VsixExtension
[switch] $InstallOnly [switch] $InstallOnly
) )
if (!$InstallOnly) if (-not $InstallOnly)
{ {
$FilePath = Start-DownloadWithRetry -Url $Url -Name $Name $FilePath = Start-DownloadWithRetry -Url $Url -Name $Name
} }
$ArgumentList = ('/quiet', "`"$FilePath`"") $argumentList = ('/quiet', "`"$FilePath`"")
Write-Host "Starting Install $Name..." Write-Host "Starting Install $Name..."
try try
@@ -230,7 +218,7 @@ function Install-VsixExtension
#There are 2 types of packages at the moment - exe and vsix #There are 2 types of packages at the moment - exe and vsix
if ($Name -match "vsix") if ($Name -match "vsix")
{ {
$process = Start-Process -FilePath "C:\Program Files (x86)\Microsoft Visual Studio\$VSversion\Enterprise\Common7\IDE\VSIXInstaller.exe" -ArgumentList $ArgumentList -Wait -PassThru $process = Start-Process -FilePath "C:\Program Files (x86)\Microsoft Visual Studio\$VSversion\Enterprise\Common7\IDE\VSIXInstaller.exe" -ArgumentList $argumentList -Wait -PassThru
} }
else else
{ {
@@ -257,20 +245,20 @@ function Install-VsixExtension
} }
#Cleanup downloaded installation files #Cleanup downloaded installation files
if (!$InstallOnly) if (-not $InstallOnly)
{ {
Remove-Item -Force -Confirm:$false $FilePath Remove-Item -Force -Confirm:$false $FilePath
} }
} }
function Get-VSExtensionVersion function Get-VSExtensionVersion
{ {
param ( param (
[string] [Parameter(Mandatory=$true)] $packageName [Parameter(Mandatory=$true)]
[string] $packageName
) )
$instanceFolders = Get-ChildItem -Path "C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances" $instanceFolders = Get-ChildItem -Path "C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances"
if ($instanceFolders -is [array]) if ($instanceFolders -is [array])
{ {
Write-Host "More than one instance installed" Write-Host "More than one instance installed"
@@ -281,7 +269,7 @@ function Get-VSExtensionVersion
$state = $stateContent | ConvertFrom-Json $state = $stateContent | ConvertFrom-Json
$packageVersion = ($state.packages | Where-Object { $_.id -eq $packageName }).version $packageVersion = ($state.packages | Where-Object { $_.id -eq $packageName }).version
if (!$packageVersion) if (-not $packageVersion)
{ {
Write-Host "installed package $packageName for Visual Studio 2019 was not found" Write-Host "installed package $packageName for Visual Studio 2019 was not found"
exit 1 exit 1
@@ -290,7 +278,6 @@ function Get-VSExtensionVersion
return $packageVersion return $packageVersion
} }
function Get-ToolcachePackages { function Get-ToolcachePackages {
$toolcachePath = Join-Path $env:ROOT_FOLDER "toolcache.json" $toolcachePath = Join-Path $env:ROOT_FOLDER "toolcache.json"
Get-Content -Raw $toolcachePath | ConvertFrom-Json Get-Content -Raw $toolcachePath | ConvertFrom-Json

View File

@@ -5,4 +5,7 @@
Import-Module -Name ImageHelpers -Force Import-Module -Name ImageHelpers -Force
Install-MSI -MsiUrl "https://aka.ms/cosmosdb-emulator" -MsiName "AzureCosmosDBEmulator.msi" $InstallerName = "AzureCosmosDBEmulator.msi"
$InstallerUrl = "https://aka.ms/cosmosdb-emulator"
Install-Binary -Url $InstallerUrl -Name $InstallerName

View File

@@ -6,8 +6,8 @@
Import-Module -Name ImageHelpers -Force; Import-Module -Name ImageHelpers -Force;
$ChromeInstallerFile = "chrome_installer.exe"; $ChromeInstallerFile = "chrome_installer.exe";
$ChromeInstallerUri = "https://dl.google.com/chrome/install/375.126/${ChromeInstallerFile}"; $ChromeInstallerUrl = "https://dl.google.com/chrome/install/375.126/${ChromeInstallerFile}";
Install-Exe -Url $ChromeInstallerUri -Name $ChromeInstallerFile -ArgumentList ("/silent", "/install") Install-Binary -Url $ChromeInstallerUrl -Name $ChromeInstallerFile -ArgumentList ("/silent", "/install")
Write-Host "Adding the firewall rule for Google update blocking"; Write-Host "Adding the firewall rule for Google update blocking";
New-NetFirewallRule -DisplayName "BlockGoogleUpdate" -Direction Outbound -Action Block -Program "C:\Program Files (x86)\Google\Update\GoogleUpdate.exe"; New-NetFirewallRule -DisplayName "BlockGoogleUpdate" -Direction Outbound -Action Block -Program "C:\Program Files (x86)\Google\Update\GoogleUpdate.exe";

View File

@@ -5,6 +5,7 @@
Import-Module -Name ImageHelpers -Force Import-Module -Name ImageHelpers -Force
$exitcode = Install-MSI -MsiUrl "https://download.microsoft.com/download/f/1/9/f19eaee6-0728-4a0b-9755-9808acc8af0b/EN/x64/DacFramework.msi" -MsiName "DacFramework.msi" $InstallerName = "DacFramework.msi"
$InstallerUrl = "https://download.microsoft.com/download/f/1/9/f19eaee6-0728-4a0b-9755-9808acc8af0b/EN/x64/${InstallerName}"
exit $exitcode Install-Binary -Url $InstallerUrl -Name $InstallerName

View File

@@ -14,7 +14,7 @@ Write-Host "Firefox latest version: $latestVersion"
# url for latest version of firefox # url for latest version of firefox
$urlLatestVersion = "https://download.mozilla.org/?product=firefox-${latestVersion}&os=win64&lang=en-US" $urlLatestVersion = "https://download.mozilla.org/?product=firefox-${latestVersion}&os=win64&lang=en-US"
Install-EXE -Url $urlLatestVersion -Name "Firefox Setup $latestVersion.exe" -ArgumentList ("/silent", "/install") Install-Binary -Url $urlLatestVersion -Name "Firefox Setup $latestVersion.exe" -ArgumentList ("/silent", "/install")
# Disable autoupdate # Disable autoupdate
$firefoxDirectoryPath = Join-Path $env:ProgramFiles "Mozilla Firefox" $firefoxDirectoryPath = Join-Path $env:ProgramFiles "Mozilla Firefox"

View File

@@ -19,18 +19,18 @@ $gitVersion = getSimpleValue -url "https://gitforwindows.org/latest-version.txt"
$installerFile = "Git-$gitVersion-64-bit.exe"; $installerFile = "Git-$gitVersion-64-bit.exe";
$downloadUrl = "https://github.com/git-for-windows/git/releases/download/$gitTag/$installerFile"; $downloadUrl = "https://github.com/git-for-windows/git/releases/download/$gitTag/$installerFile";
Install-Exe -Url $downloadUrl ` Install-Binary -Url $downloadUrl `
-Name $installerFile ` -Name $installerFile `
-ArgumentList ( -ArgumentList (
"/VERYSILENT", ` "/VERYSILENT", `
"/NORESTART", ` "/NORESTART", `
"/NOCANCEL", ` "/NOCANCEL", `
"/SP-", ` "/SP-", `
"/CLOSEAPPLICATIONS", ` "/CLOSEAPPLICATIONS", `
"/RESTARTAPPLICATIONS", ` "/RESTARTAPPLICATIONS", `
"/o:PathOption=CmdTools", ` "/o:PathOption=CmdTools", `
"/o:BashTerminalOption=ConHost", ` "/o:BashTerminalOption=ConHost", `
"/COMPONENTS=gitlfs") "/COMPONENTS=gitlfs")
Choco-Install -PackageName hub Choco-Install -PackageName hub

View File

@@ -5,12 +5,14 @@
Import-Module -Name ImageHelpers -Force Import-Module -Name ImageHelpers -Force
$CondaDestination = "C:\Miniconda"
# Lock to Miniconda 4.6 until we do the work to run `conda init` for the vsts user # Lock to Miniconda 4.6 until we do the work to run `conda init` for the vsts user
# Then we can go back to installing the latest Miniconda # Then we can go back to installing the latest Miniconda
# $url = "https://repo.continuum.io/miniconda/Miniconda3-latest-Windows-x86_64.exe" # $url = "https://repo.continuum.io/miniconda/Miniconda3-latest-Windows-x86_64.exe"
$url = "https://repo.continuum.io/miniconda/Miniconda3-4.6.14-Windows-x86_64.exe" $InstallerName = "Miniconda3-4.6.14-Windows-x86_64.exe"
$name = $Url.Split('/')[-1] $InstallerUrl = "https://repo.continuum.io/miniconda/${InstallerName}"
$destination = "C:\Miniconda" $ArgumentList = ("/S", "/AddToPath=0", "/RegisterPython=0", "/D=$CondaDestination")
Install-EXE -Url $url -Name $name -ArgumentList "/S /AddToPath=0 /RegisterPython=0 /D=$destination" Install-Binary -Url $InstallerUrl -Name $InstallerName -ArgumentList $ArgumentList
Set-SystemVariable -SystemVariable "CONDA" -Value $destination Set-SystemVariable -SystemVariable "CONDA" -Value $CondaDestination

View File

@@ -9,31 +9,23 @@ $uri = 'https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.21-winx64.zip'
$mysqlPath = 'C:\mysql-5.7.21-winx64\bin' $mysqlPath = 'C:\mysql-5.7.21-winx64\bin'
# Installing visual c++ redistibutable package. # Installing visual c++ redistibutable package.
$InstallerURI = 'https://download.microsoft.com/download/0/5/6/056dcda9-d667-4e27-8001-8a0c6971d6b1/vcredist_x64.exe' $InstallerName = "vcredist_x64.exe"
$InstallerName = 'vcredist_x64.exe' $InstallerURI = "https://download.microsoft.com/download/0/5/6/056dcda9-d667-4e27-8001-8a0c6971d6b1/${InstallerName}"
$ArgumentList = ('/install', '/quiet', '/norestart' ) $ArgumentList = ("/install", "/quiet", "/norestart")
$exitCode = Install-EXE -Url $InstallerURI -Name $InstallerName -ArgumentList $ArgumentList Install-Binary -Url $InstallerURI -Name $InstallerName -ArgumentList $ArgumentList
if ($exitCode -eq 0 -or $exitCode -eq 3010)
{
# MySQL disabled TLS 1.0 support on or about Jul-14-2018. Need to make sure TLS 1.2 is enabled.
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor "Tls12"
# Get the latest mysql command line tools . # MySQL disabled TLS 1.0 support on or about Jul-14-2018. Need to make sure TLS 1.2 is enabled.
Invoke-WebRequest -UseBasicParsing -Uri $uri -OutFile mysql.zip [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor "Tls12"
# Expand the zip # Get the latest mysql command line tools .
Expand-Archive -Path mysql.zip -DestinationPath "C:\" -Force Invoke-WebRequest -UseBasicParsing -Uri $uri -OutFile mysql.zip
# Deleting zip folder # Expand the zip
Remove-Item -Recurse -Force mysql.zip Expand-Archive -Path mysql.zip -DestinationPath "C:\" -Force
# Adding mysql in system environment path # Deleting zip folder
Add-MachinePathItem $mysqlPath Remove-Item -Recurse -Force mysql.zip
return 0; # Adding mysql in system environment path
} Add-MachinePathItem $mysqlPath
else
{
return $exitCode;
}

View File

@@ -6,8 +6,8 @@
Import-Module -Name ImageHelpers -Force Import-Module -Name ImageHelpers -Force
# .NET 4.7.2 Dev pack # .NET 4.7.2 Dev pack
$InstallerURI = "https://download.microsoft.com/download/3/B/F/3BFB9C35-405D-45DF-BDAF-0EB57D047888/NDP472-DevPack-ENU.exe"
$InstallerName = "NDP472-DevPack-ENU.exe" $InstallerName = "NDP472-DevPack-ENU.exe"
$InstallerUrl = "https://download.microsoft.com/download/3/B/F/3BFB9C35-405D-45DF-BDAF-0EB57D047888/${InstallerName}"
$ArgumentList = ('Setup', '/passive', '/norestart' ) $ArgumentList = ('Setup', '/passive', '/norestart' )
Install-EXE -Url $InstallerURI -Name $InstallerName -ArgumentList $ArgumentList Install-Binary -Url $InstallerUrl -Name $InstallerName -ArgumentList $ArgumentList

View File

@@ -6,8 +6,8 @@
Import-Module -Name ImageHelpers -Force Import-Module -Name ImageHelpers -Force
# .NET 4.8 Dev pack # .NET 4.8 Dev pack
$InstallerURI = "https://download.visualstudio.microsoft.com/download/pr/014120d7-d689-4305-befd-3cb711108212/0307177e14752e359fde5423ab583e43/ndp48-devpack-enu.exe" $InstallerName = "ndp48-devpack-enu.exe"
$InstallerName = "NDP48-DevPack-ENU.exe" $InstallerUrl = "https://download.visualstudio.microsoft.com/download/pr/014120d7-d689-4305-befd-3cb711108212/0307177e14752e359fde5423ab583e43/${InstallerName}"
$ArgumentList = ('Setup', '/passive', '/norestart' ) $ArgumentList = ("Setup", "/passive", "/norestart")
Install-EXE -Url $InstallerURI -Name $InstallerName -ArgumentList $ArgumentList Install-Binary -Url $InstallerUrl -Name $InstallerName -ArgumentList $ArgumentList

View File

@@ -7,7 +7,7 @@
Import-Module -Name ImageHelpers -Force Import-Module -Name ImageHelpers -Force
if(Test-IsWin19) if (Test-IsWin19)
{ {
$winSdkUrl = "https://go.microsoft.com/fwlink/p/?linkid=2083338" $winSdkUrl = "https://go.microsoft.com/fwlink/p/?linkid=2083338"
$wdkUrl = "https://go.microsoft.com/fwlink/?linkid=2085767" $wdkUrl = "https://go.microsoft.com/fwlink/?linkid=2085767"
@@ -22,24 +22,13 @@ else
$VSver = "2017" $VSver = "2017"
} }
$argumentList = ("/features", "+", "/quiet")
# `winsdksetup.exe /features + /quiet` installs all features without showing the GUI # `winsdksetup.exe /features + /quiet` installs all features without showing the GUI
$sdkExitCode = Install-EXE -Url $winSdkUrl -Name "winsdksetup.exe" -ArgumentList ("/features", "+", "/quiet") Install-Binary -Url $winSdkUrl -Name "winsdksetup.exe" -ArgumentList $argumentList
if ($sdkExitCode -ne 0)
{
Write-Host "Failed to install the Windows SDK."
exit $sdkExitCode
}
# `wdksetup.exe /features + /quiet` installs all features without showing the GUI # `wdksetup.exe /features + /quiet` installs all features without showing the GUI
$wdkExitCode = Install-EXE -Url $wdkUrl -Name "wdksetup.exe" -ArgumentList ("/features", "+", "/quiet") Install-Binary -Url $wdkUrl -Name "wdksetup.exe" -ArgumentList $argumentList
if ($wdkExitCode -ne 0)
{
Write-Host "Failed to install the Windows Driver Kit."
exit $wdkExitCode
}
# Need to install the VSIX to get the build targets when running VSBuild # Need to install the VSIX to get the build targets when running VSBuild
Install-VsixExtension -FilePath $FilePath -Name "WDK.vsix" -VSversion $VSver -InstallOnly Install-VsixExtension -FilePath $FilePath -Name "WDK.vsix" -VSversion $VSver -InstallOnly

View File

@@ -4,5 +4,9 @@
#################################################################################### ####################################################################################
Import-Module -Name ImageHelpers -Force Import-Module -Name ImageHelpers -Force
$InstallerName = "WindowsApplicationDriver.msi"
$InstallerUrl = "https://github.com/Microsoft/WinAppDriver/releases/download/v1.1/${InstallerName}"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Install-MSI -MsiUrl "https://github.com/Microsoft/WinAppDriver/releases/download/v1.1/WindowsApplicationDriver.msi" -MsiName "WindowsApplicationDriver.msi" Install-Binary -Url $InstallerUrl -Name $InstallerName

View File

@@ -7,18 +7,13 @@ Import-Module -Name ImageHelpers -Force
#SSDT for Visual Studio 2017 #SSDT for Visual Studio 2017
#The link down below points to the latest version of SSDT for Visual Studio 2017 #The link down below points to the latest version of SSDT for Visual Studio 2017
$InstallerURI = 'https://go.microsoft.com/fwlink/?linkid=2124518' $InstallerName = "SSDT-Setup-ENU.exe"
$InstallerName = 'SSDT-Setup-ENU.exe' $InstallerUrl = "https://go.microsoft.com/fwlink/?linkid=2124518"
$logFilePath = "$env:TEMP\ssdtlog.txt" $logFilePath = "$env:TEMP\ssdtlog.txt"
$ArgumentList = ('/install', 'INSTALLALL', '/passive', '/norestart', "/log `"$logFilePath`"") $ArgumentList = ("/install", "INSTALLALL", "/passive", "/norestart", "/log `"$logFilePath`"")
$exitCode = Install-EXE -Url $InstallerURI -Name $InstallerName -ArgumentList $ArgumentList Install-Binary -Url $InstallerUrl -Name $InstallerName -ArgumentList $ArgumentList
if($exitCode -ne 0 -and $exitCode -ne 3010) Write-Host "******** SSDT SETUP LOG START ********"
{ Write-Host $(Get-Content $logFilePath | Out-String)
Write-Host "******** SSDT SETUP LOG START ********" Write-Host "******** SSDT SETUP LOG END ********"
Write-Host $(Get-Content $logFilePath | Out-String)
Write-Host "******** SSDT SETUP LOG END ********"
}
exit $exitCode

View File

@@ -5,10 +5,8 @@
Import-Module -Name ImageHelpers -Force Import-Module -Name ImageHelpers -Force
$InstallerURI = 'http://download.microsoft.com/download/B/0/C/B0C80BA3-8AD6-4958-810B-6882485230B5/standalonesdk/sdksetup.exe' $InstallerName = "sdksetup.exe"
$InstallerName = 'sdksetup.exe' $InstallerUrl = "http://download.microsoft.com/download/B/0/C/B0C80BA3-8AD6-4958-810B-6882485230B5/standalonesdk/${InstallerName}"
$ArgumentList = ('/quiet', '/norestart') $ArgumentList = ("/quiet", "/norestart")
$exitCode = Install-EXE -Url $InstallerURI -Name $InstallerName -ArgumentList $ArgumentList Install-Binary -Url $InstallerUrl -Name $InstallerName -ArgumentList $ArgumentList
exit $exitCode