mirror of
https://github.com/actions/runner-images-sangeeth.git
synced 2025-12-30 21:38:26 +08: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:
@@ -4,61 +4,7 @@
|
||||
################################################################################
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
Function InstallVS
|
||||
{
|
||||
Param
|
||||
(
|
||||
[String]$WorkLoads,
|
||||
[String]$Sku,
|
||||
[String] $VSBootstrapperURL
|
||||
)
|
||||
|
||||
$exitCode = -1
|
||||
|
||||
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 -Object '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 "Downloading Bootstrapper ..."
|
||||
Invoke-WebRequest -Uri $VSBootstrapperURL -OutFile "${env:Temp}\vs_$Sku.exe"
|
||||
|
||||
$FilePath = "${env:Temp}\vs_$Sku.exe"
|
||||
$Arguments = ('/c', $FilePath, $WorkLoads, '--quiet', '--norestart', '--wait', '--nocache' )
|
||||
|
||||
Write-Host "Starting Install ..."
|
||||
$process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -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."
|
||||
|
||||
# this wont work because of log size limitation in extension manager
|
||||
# Get-Content $customLogFilePath | Write-Host
|
||||
|
||||
exit $exitCode
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
Write-Host -Object "Failed to install Visual Studio. Check the logs for details in $customLogFilePath"
|
||||
Write-Host -Object $_.Exception.Message
|
||||
exit -1
|
||||
}
|
||||
}
|
||||
Import-Module -Name ImageHelpers -Force
|
||||
|
||||
$WorkLoads = '--allWorkloads --includeRecommended ' + `
|
||||
'--add Component.Dotfuscator ' + `
|
||||
@@ -150,22 +96,18 @@ $WorkLoads = '--allWorkloads --includeRecommended ' + `
|
||||
'--add Microsoft.VisualStudio.Workload.Universal ' + `
|
||||
'--add Microsoft.VisualStudio.Workload.VisualStudioExtension'
|
||||
|
||||
|
||||
$ReleaseInPath = 'Enterprise'
|
||||
$Sku = 'Enterprise'
|
||||
$VSBootstrapperURL = 'https://aka.ms/vs/16/release/vs_Enterprise.exe'
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$ReleaseInPath = "Enterprise"
|
||||
$BootstrapperUrl = "https://aka.ms/vs/16/release/vs_${ReleaseInPath}.exe"
|
||||
|
||||
# Install VS
|
||||
$exitCode = InstallVS -WorkLoads $WorkLoads -Sku $Sku -VSBootstrapperURL $VSBootstrapperURL
|
||||
Install-VisualStudio -BootstrapperUrl $BootstrapperUrl -WorkLoads $WorkLoads
|
||||
|
||||
# Find the version of VS installed for this instance
|
||||
# Only supports a single instance
|
||||
$vsProgramData = Get-Item -Path "C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances"
|
||||
$instanceFolders = Get-ChildItem -Path $vsProgramData.FullName
|
||||
|
||||
if($instanceFolders -is [array])
|
||||
if ($instanceFolders -is [array])
|
||||
{
|
||||
Write-Host "More than one instance installed"
|
||||
exit 1
|
||||
@@ -174,14 +116,15 @@ if($instanceFolders -is [array])
|
||||
$catalogContent = Get-Content -Path ($instanceFolders.FullName + '\catalog.json')
|
||||
$catalog = $catalogContent | ConvertFrom-Json
|
||||
$version = $catalog.info.id
|
||||
Write-Host "Visual Studio version" $version "installed"
|
||||
$VSInstallRoot = "C:\Program Files (x86)\Microsoft Visual Studio\2019\$ReleaseInPath"
|
||||
Write-Host "Visual Studio version ${version} installed"
|
||||
|
||||
# Initialize Visual Studio Experimental Instance
|
||||
&"C:\Program Files (x86)\Microsoft Visual Studio\2019\$ReleaseInPath\Common7\IDE\devenv.exe" /RootSuffix Exp /ResetSettings General.vssettings /Command File.Exit
|
||||
& "$VSInstallRoot\Common7\IDE\devenv.exe" /RootSuffix Exp /ResetSettings General.vssettings /Command File.Exit
|
||||
|
||||
# Updating content of MachineState.json file to disable autoupdate of VSIX extensions
|
||||
$newContent = '{"Extensions":[{"Key":"1e906ff5-9da8-4091-a299-5c253c55fdc9","Value":{"ShouldAutoUpdate":false}},{"Key":"Microsoft.VisualStudio.Web.AzureFunctions","Value":{"ShouldAutoUpdate":false}}],"ShouldAutoUpdate":false,"ShouldCheckForUpdates":false}'
|
||||
Set-Content -Path "C:\Program Files (x86)\Microsoft Visual Studio\2019\$ReleaseInPath\Common7\IDE\Extensions\MachineState.json" -Value $newContent
|
||||
Set-Content -Path "$VSInstallRoot\Common7\IDE\Extensions\MachineState.json" -Value $newContent
|
||||
|
||||
|
||||
# Adding description of the software to Markdown
|
||||
@@ -190,7 +133,7 @@ $SoftwareName = "Visual Studio 2019 Enterprise"
|
||||
|
||||
$Description = @"
|
||||
_Version:_ $version<br/>
|
||||
_Location:_ C:\Program Files (x86)\Microsoft Visual Studio\2019\$ReleaseInPath
|
||||
_Location:_ $VSInstallRoot
|
||||
|
||||
The following workloads and components are installed with Visual Studio 2019:
|
||||
"@
|
||||
@@ -198,7 +141,4 @@ The following workloads and components are installed with Visual Studio 2019:
|
||||
Add-SoftwareDetailsToMarkdown -SoftwareName $SoftwareName -DescriptionMarkdown $Description
|
||||
|
||||
# Adding explicitly added Workloads details to markdown by parsing $Workloads
|
||||
Add-ContentToMarkdown -Content $($WorkLoads.Split('--') | % { if( ($_.Split(" "))[0] -like "add") { "* " +($_.Split(" "))[1] } } )
|
||||
|
||||
|
||||
exit $exitCode
|
||||
Add-ContentToMarkdown -Content $($WorkLoads.Split('--') | % { if( ($_.Split(" "))[0] -like "add") { "* " +($_.Split(" "))[1] } } )
|
||||
Reference in New Issue
Block a user