mirror of
https://github.com/actions/runner-images-sangeeth.git
synced 2025-12-20 06:29:50 +00:00
add function to download and install vsix
This commit is contained in:
@@ -161,6 +161,74 @@ Hashtable for service arguments
|
||||
}
|
||||
}
|
||||
|
||||
function Install-VsixExtension
|
||||
{
|
||||
Param
|
||||
(
|
||||
[String]$Url,
|
||||
[String]$Name
|
||||
)
|
||||
|
||||
$FilePath = "${env:Temp}\$Name"
|
||||
$ReleaseInPath = 'Enterprise'
|
||||
$exitCode = -1
|
||||
$retries = 20
|
||||
|
||||
while($true)
|
||||
{
|
||||
try
|
||||
{
|
||||
Write-Host "Downloading $Name..."
|
||||
(New-Object System.Net.WebClient).DownloadFile($Url, $FilePath)
|
||||
break
|
||||
}
|
||||
catch
|
||||
{
|
||||
Write-Host "There is an error during $Name downloading"
|
||||
$_
|
||||
if ($retries -gt 0)
|
||||
{
|
||||
$retries--
|
||||
Write-Host "Waiting 30 seconds before retrying. Retries left: $retries"
|
||||
Start-Sleep -Seconds 30
|
||||
}
|
||||
else {
|
||||
Write-Host "File can't be downloaded"
|
||||
$_
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$ArgumentList = ('/quiet', $FilePath)
|
||||
|
||||
Write-Host "Starting Install $Name..."
|
||||
try
|
||||
{
|
||||
$process = Start-Process -FilePath "C:\Program Files (x86)\Microsoft Visual Studio\2019\$ReleaseInPath\Common7\IDE\VSIXInstaller.exe" -ArgumentList $ArgumentList -Wait -PassThru
|
||||
}
|
||||
catch
|
||||
{
|
||||
Write-Host "There is an error during $Name installation"
|
||||
$_
|
||||
exit 1
|
||||
}
|
||||
|
||||
$exitCode = $process.ExitCode
|
||||
|
||||
if ($exitCode -eq 0 -or $exitCode -eq 1001) # 1001 means the extension is already installed
|
||||
{
|
||||
Write-Host "$Name installed successfully"
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Host "Unsuccessful exit code returned by the installation process: $exitCode."
|
||||
exit 1
|
||||
}
|
||||
|
||||
#Cleanup installation files
|
||||
Remove-Item -Force -Confirm:$false $FilePath
|
||||
}
|
||||
function Get-VS19ExtensionVersion
|
||||
{
|
||||
param (
|
||||
|
||||
Reference in New Issue
Block a user