mirror of
https://github.com/actions/runner-images-sangeeth.git
synced 2025-12-15 06:19:21 +00:00
Improve Windows Visual Studio provisioners (#758)
* Add retries to DotnetSDK provisioner * Improve VS provisioners * Fixes in syntax * Fixes in syntax * Rename Install-VS function * Remove bootstrapperName parameter from Install-VisualStudio * Small fix
This commit is contained in:
@@ -20,7 +20,8 @@ function Install-Binary
|
||||
Install-Binary -Url "https://go.microsoft.com/fwlink/p/?linkid=2083338" -Name "winsdksetup.exe" -ArgumentList ("/features", "+", "/quiet")
|
||||
#>
|
||||
|
||||
Param (
|
||||
Param
|
||||
(
|
||||
[Parameter(Mandatory)]
|
||||
[String] $Url,
|
||||
[Parameter(Mandatory)]
|
||||
@@ -62,6 +63,68 @@ function Install-Binary
|
||||
}
|
||||
}
|
||||
|
||||
Function Install-VisualStudio
|
||||
{
|
||||
<#
|
||||
.SYNOPSIS
|
||||
A helper function to install Visual Studio.
|
||||
|
||||
.DESCRIPTION
|
||||
Prepare system environment, and install Visual Studio bootstrapper with selected workloads.
|
||||
|
||||
.PARAMETER BootstrapperUrl
|
||||
The URL from which the bootstrapper will be downloaded. Required parameter.
|
||||
|
||||
.PARAMETER WorkLoads
|
||||
The string that contain workloads that will be passed to the installer.
|
||||
#>
|
||||
|
||||
Param
|
||||
(
|
||||
[Parameter(Mandatory)]
|
||||
[String] $BootstrapperUrl,
|
||||
[String] $WorkLoads
|
||||
)
|
||||
|
||||
Write-Host "Downloading Bootstrapper ..."
|
||||
$BootstrapperName = [IO.Path]::GetFileName($BootstrapperUrl)
|
||||
$bootstrapperFilePath = Start-DownloadWithRetry -Url $BootstrapperUrl -Name $BootstrapperName
|
||||
|
||||
try
|
||||
{
|
||||
Write-Host "Enable short name support on Windows needed for Xamarin Android AOT, defaults appear to have been changed in Azure VMs"
|
||||
$shortNameEnableProcess = Start-Process -FilePath fsutil.exe -ArgumentList ('8dot3name', 'set', '0') -Wait -PassThru
|
||||
|
||||
$shortNameEnableExitCode = $shortNameEnableProcess.ExitCode
|
||||
if ($shortNameEnableExitCode -ne 0)
|
||||
{
|
||||
Write-Host "Enabling short name support on Windows failed. This needs to be enabled prior to VS 2017 install for Xamarin Andriod AOT to work."
|
||||
exit $shortNameEnableExitCode
|
||||
}
|
||||
|
||||
Write-Host "Starting Install ..."
|
||||
$bootstrapperArgumentList = ('/c', $bootstrapperFilePath, $WorkLoads, '--quiet', '--norestart', '--wait', '--nocache' )
|
||||
$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"
|
||||
return $exitCode
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Host "Non zero exit code returned by the installation process : $exitCode"
|
||||
exit $exitCode
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
Write-Host "Failed to install Visual Studio; $($_.Exception.Message)"
|
||||
exit -1
|
||||
}
|
||||
}
|
||||
|
||||
function Stop-SvcWithErrHandling
|
||||
{
|
||||
<#
|
||||
@@ -74,7 +137,8 @@ function Stop-SvcWithErrHandling
|
||||
.PARAMETER StopOnError
|
||||
Switch for stopping the script and exit from PowerShell if one service is absent
|
||||
#>
|
||||
param (
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory, ValueFromPipeLine = $true)]
|
||||
[string] $ServiceName,
|
||||
[switch] $StopOnError
|
||||
@@ -123,7 +187,8 @@ function Set-SvcWithErrHandling
|
||||
Hashtable for service arguments
|
||||
#>
|
||||
|
||||
param (
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory, ValueFromPipeLine = $true)]
|
||||
[string] $ServiceName,
|
||||
[Parameter(Mandatory)]
|
||||
@@ -152,7 +217,8 @@ function Set-SvcWithErrHandling
|
||||
|
||||
function Start-DownloadWithRetry
|
||||
{
|
||||
param (
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory)]
|
||||
[string] $Url,
|
||||
[Parameter(Mandatory)]
|
||||
@@ -253,7 +319,8 @@ function Install-VsixExtension
|
||||
|
||||
function Get-VSExtensionVersion
|
||||
{
|
||||
param (
|
||||
Param
|
||||
(
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string] $packageName
|
||||
)
|
||||
@@ -289,7 +356,8 @@ function Get-ToolsetContent {
|
||||
}
|
||||
|
||||
function Get-ToolsByName {
|
||||
param (
|
||||
Param
|
||||
(
|
||||
[Parameter(Mandatory = $True)]
|
||||
[string]$SoftwareName
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user