[Windows] Add VC components for VS 17.7 (#8151)

* [Windows] Add VC components for VS 17.7

* Try to debug VS installation

* Add more components for VS

* Use response file

* Remove 14.36.17.6 build tools components

* Fix issue where config is bad for VS2019 installer
This commit is contained in:
Vasilii Polikarpov
2023-09-02 12:25:52 +02:00
committed by GitHub
parent 0a6c637b3f
commit 1e590b77aa
3 changed files with 91 additions and 56 deletions

View File

@@ -1,5 +1,4 @@
Function Install-VisualStudio Function Install-VisualStudio {
{
<# <#
.SYNOPSIS .SYNOPSIS
A helper function to install Visual Studio. A helper function to install Visual Studio.
@@ -7,56 +6,99 @@ Function Install-VisualStudio
.DESCRIPTION .DESCRIPTION
Prepare system environment, and install Visual Studio bootstrapper with selected workloads. Prepare system environment, and install Visual Studio bootstrapper with selected workloads.
.PARAMETER BootstrapperUrl .PARAMETER Version
The URL from which the bootstrapper will be downloaded. Required parameter. The version of Visual Studio that will be installed. Required parameter.
.PARAMETER WorkLoads .PARAMETER Edition
The string that contain workloads that will be passed to the installer. The edition of Visual Studio that will be installed. Required parameter.
.PARAMETER Channel
The channel of Visual Studio that will be installed. Required parameter.
.PARAMETER RequiredComponents
The list of required components. Required parameter.
.PARAMETER ExtraArgs
The extra arguments to pass to the bootstrapper. Optional parameter.
#> #>
Param Param
( (
[Parameter(Mandatory)] [Parameter(Mandatory)] [String] $Version,
[String] $BootstrapperUrl, [Parameter(Mandatory)] [String] $Edition,
[String] $WorkLoads [Parameter(Mandatory)] [String] $Channel,
[Parameter(Mandatory)] [String[]] $RequiredComponents,
[String] $ExtraArgs = ""
) )
$bootstrapperUrl = "https://aka.ms/vs/${Version}/${Channel}/vs_${Edition}.exe"
$channelUri = "https://aka.ms/vs/${Version}/${Channel}/channel"
$channelId = "VisualStudio.${Version}.Release"
$productId = "Microsoft.VisualStudio.Product.${Edition}"
Write-Host "Downloading Bootstrapper ..." Write-Host "Downloading Bootstrapper ..."
$BootstrapperName = [IO.Path]::GetFileName($BootstrapperUrl) $BootstrapperName = [IO.Path]::GetFileName($BootstrapperUrl)
$bootstrapperFilePath = Start-DownloadWithRetry -Url $BootstrapperUrl -Name $BootstrapperName $bootstrapperFilePath = Start-DownloadWithRetry -Url $BootstrapperUrl -Name $BootstrapperName
try try {
{
Write-Host "Enable short name support on Windows needed for Xamarin Android AOT, defaults appear to have been changed in Azure VMs" 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 $shortNameEnableProcess = Start-Process -FilePath fsutil.exe -ArgumentList ('8dot3name', 'set', '0') -Wait -PassThru
$shortNameEnableExitCode = $shortNameEnableProcess.ExitCode $shortNameEnableExitCode = $shortNameEnableProcess.ExitCode
if ($shortNameEnableExitCode -ne 0) 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." 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 exit $shortNameEnableExitCode
} }
$responseData = @{
"channelUri" = $channelUri
"channelId" = $channelId
"productId" = $productId
"arch" = "x64"
"add" = $RequiredComponents | ForEach-Object { "$_;includeRecommended" }
}
# Create json file with response data
$responseDataPath = "$env:TEMP\vs_install_response.json"
$responseData | ConvertTo-Json | Out-File -FilePath $responseDataPath
Write-Host "Starting Install ..." Write-Host "Starting Install ..."
$bootstrapperArgumentList = ('/c', $bootstrapperFilePath, $WorkLoads, '--quiet', '--norestart', '--wait', '--nocache' ) $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 $process = Start-Process -FilePath cmd.exe -ArgumentList $bootstrapperArgumentList -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 "Installation successful" Write-Host "Installation successful"
return $exitCode return $exitCode
} } else {
else Write-Host "Non zero exit code returned by the installation process : $exitCode"
{
$setupErrorLogPath = "$env:TEMP\dd_setup_*_errors.log" # Try to download tool to collect logs
if (Test-Path -Path $setupErrorLogPath) $collectExeUrl = "https://aka.ms/vscollect.exe"
{ $collectExeName = [IO.Path]::GetFileName($collectExeUrl)
$logErrors = Get-Content -Path $setupErrorLogPath -Raw $collectExePath = Start-DownloadWithRetry -Url $collectExeUrl -Name $collectExeName
Write-Host "$logErrors"
# Collect installation logs using the collect.exe tool and check if it is successful
& "$collectExePath"
if ($LastExitCode -ne 0) {
Write-Host "Failed to collect logs using collect.exe tool. Exit code : $LastExitCode"
exit $exitCode
} }
Write-Host "Non zero exit code returned by the installation process : $exitCode" # Expand the zip file
Expand-Archive -Path "$env:TEMP\vslogs.zip" -DestinationPath "$env:TEMP\vslogs"
# Print logs
$vsLogsPath = "$env:TEMP\vslogs"
$vsLogs = Get-ChildItem -Path $vsLogsPath -Recurse | Where-Object { -not $_.PSIsContainer } | Select-Object -ExpandProperty FullName
foreach ($log in $vsLogs) {
Write-Host "============================"
Write-Host "== Log file : $log "
Write-Host "============================"
Get-Content -Path $log -ErrorAction Continue
}
exit $exitCode exit $exitCode
} }
} }

View File

@@ -4,21 +4,14 @@
################################################################################ ################################################################################
$toolset = Get-ToolsetContent $toolset = Get-ToolsetContent
$requiredComponents = $toolset.visualStudio.workloads | ForEach-Object { "--add $_" }
$workLoads = @(
"--allWorkloads --includeRecommended"
$requiredComponents
"--remove Component.CPython3.x64"
)
$workLoadsArgument = [String]::Join(" ", $workLoads)
$releaseInPath = $toolset.visualStudio.edition
$subVersion = $toolset.visualStudio.subversion
$channel = $toolset.visualStudio.channel
$bootstrapperUrl = "https://aka.ms/vs/${subVersion}/${channel}/vs_${releaseInPath}.exe"
# Install VS # Install VS
Install-VisualStudio -BootstrapperUrl $bootstrapperUrl -WorkLoads $workLoadsArgument Install-VisualStudio `
-Version $toolset.visualStudio.subversion `
-Edition $toolset.visualStudio.edition `
-Channel $toolset.visualStudio.channel `
-RequiredComponents $toolset.visualStudio.workloads `
-ExtraArgs "--allWorkloads --includeRecommended --remove Component.CPython3.x64"
# Find the version of VS installed for this instance # Find the version of VS installed for this instance
# Only supports a single instance # Only supports a single instance

View File

@@ -265,24 +265,24 @@
"Microsoft.VisualStudio.Component.VC.14.35.17.5.MFC", "Microsoft.VisualStudio.Component.VC.14.35.17.5.MFC",
"Microsoft.VisualStudio.Component.VC.14.35.17.5.x86.x64.Spectre", "Microsoft.VisualStudio.Component.VC.14.35.17.5.x86.x64.Spectre",
"Microsoft.VisualStudio.Component.VC.14.35.17.5.x86.x64", "Microsoft.VisualStudio.Component.VC.14.35.17.5.x86.x64",
"Microsoft.VisualStudio.Component.VC.14.36.17.6.ARM.Spectre", "Microsoft.VisualStudio.Component.VC.14.37.17.7.ARM.Spectre",
"Microsoft.VisualStudio.Component.VC.14.36.17.6.ARM", "Microsoft.VisualStudio.Component.VC.14.37.17.7.ARM",
"Microsoft.VisualStudio.Component.VC.14.36.17.6.ARM64.Spectre", "Microsoft.VisualStudio.Component.VC.14.37.17.7.ARM64.Spectre",
"Microsoft.VisualStudio.Component.VC.14.36.17.6.ARM64", "Microsoft.VisualStudio.Component.VC.14.37.17.7.ARM64",
"Microsoft.VisualStudio.Component.VC.14.36.17.6.ATL.ARM.Spectre", "Microsoft.VisualStudio.Component.VC.14.37.17.7.ATL.ARM.Spectre",
"Microsoft.VisualStudio.Component.VC.14.36.17.6.ATL.ARM", "Microsoft.VisualStudio.Component.VC.14.37.17.7.ATL.ARM",
"Microsoft.VisualStudio.Component.VC.14.36.17.6.ATL.ARM64.Spectre", "Microsoft.VisualStudio.Component.VC.14.37.17.7.ATL.ARM64.Spectre",
"Microsoft.VisualStudio.Component.VC.14.36.17.6.ATL.ARM64", "Microsoft.VisualStudio.Component.VC.14.37.17.7.ATL.ARM64",
"Microsoft.VisualStudio.Component.VC.14.36.17.6.ATL.Spectre", "Microsoft.VisualStudio.Component.VC.14.37.17.7.ATL.Spectre",
"Microsoft.VisualStudio.Component.VC.14.36.17.6.ATL", "Microsoft.VisualStudio.Component.VC.14.37.17.7.ATL",
"Microsoft.VisualStudio.Component.VC.14.36.17.6.MFC.ARM.Spectre", "Microsoft.VisualStudio.Component.VC.14.37.17.7.MFC.ARM.Spectre",
"Microsoft.VisualStudio.Component.VC.14.36.17.6.MFC.ARM", "Microsoft.VisualStudio.Component.VC.14.37.17.7.MFC.ARM",
"Microsoft.VisualStudio.Component.VC.14.36.17.6.MFC.ARM64.Spectre", "Microsoft.VisualStudio.Component.VC.14.37.17.7.MFC.ARM64.Spectre",
"Microsoft.VisualStudio.Component.VC.14.36.17.6.MFC.ARM64", "Microsoft.VisualStudio.Component.VC.14.37.17.7.MFC.ARM64",
"Microsoft.VisualStudio.Component.VC.14.36.17.6.MFC.Spectre", "Microsoft.VisualStudio.Component.VC.14.37.17.7.MFC.Spectre",
"Microsoft.VisualStudio.Component.VC.14.36.17.6.MFC", "Microsoft.VisualStudio.Component.VC.14.37.17.7.MFC",
"Microsoft.VisualStudio.Component.VC.14.36.17.6.x86.x64.Spectre", "Microsoft.VisualStudio.Component.VC.14.37.17.7.x86.x64.Spectre",
"Microsoft.VisualStudio.Component.VC.14.36.17.6.x86.x64", "Microsoft.VisualStudio.Component.VC.14.37.17.7.x86.x64",
"Microsoft.VisualStudio.Component.VC.ATLMFC", "Microsoft.VisualStudio.Component.VC.ATLMFC",
"Microsoft.VisualStudio.Component.VC.ATLMFC.Spectre", "Microsoft.VisualStudio.Component.VC.ATLMFC.Spectre",
"Microsoft.VisualStudio.Component.Windows10SDK.19041", "Microsoft.VisualStudio.Component.Windows10SDK.19041",