Skip to content

Commit

Permalink
[Windows] Add VC components for VS 17.7 (#8151)
Browse files Browse the repository at this point in the history
* [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
  • Loading branch information
vpolikarpov-akvelon authored Sep 2, 2023
1 parent 0a6c637 commit 1e590b7
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 56 deletions.
92 changes: 67 additions & 25 deletions images/win/scripts/ImageHelpers/VisualStudioHelpers.ps1
Original file line number Diff line number Diff line change
@@ -1,62 +1,104 @@
Function Install-VisualStudio
{
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 Version
The version of Visual Studio that will be installed. Required parameter.
.PARAMETER WorkLoads
The string that contain workloads that will be passed to the installer.
.PARAMETER Edition
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
(
[Parameter(Mandatory)]
[String] $BootstrapperUrl,
[String] $WorkLoads
[Parameter(Mandatory)] [String] $Version,
[Parameter(Mandatory)] [String] $Edition,
[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 ..."
$BootstrapperName = [IO.Path]::GetFileName($BootstrapperUrl)
$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"
$shortNameEnableProcess = Start-Process -FilePath fsutil.exe -ArgumentList ('8dot3name', 'set', '0') -Wait -PassThru

$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."
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 ..."
$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

$exitCode = $process.ExitCode
if ($exitCode -eq 0 -or $exitCode -eq 3010)
{
if ($exitCode -eq 0 -or $exitCode -eq 3010) {
Write-Host "Installation successful"
return $exitCode
}
else
{
$setupErrorLogPath = "$env:TEMP\dd_setup_*_errors.log"
if (Test-Path -Path $setupErrorLogPath)
{
$logErrors = Get-Content -Path $setupErrorLogPath -Raw
Write-Host "$logErrors"
} else {
Write-Host "Non zero exit code returned by the installation process : $exitCode"

# Try to download tool to collect logs
$collectExeUrl = "https://aka.ms/vscollect.exe"
$collectExeName = [IO.Path]::GetFileName($collectExeUrl)
$collectExePath = Start-DownloadWithRetry -Url $collectExeUrl -Name $collectExeName

# 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
}
}
Expand Down
19 changes: 6 additions & 13 deletions images/win/scripts/Installers/Install-VS.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,14 @@
################################################################################

$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-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
# Only supports a single instance
Expand Down
36 changes: 18 additions & 18 deletions images/win/toolsets/toolset-2022.json
Original file line number Diff line number Diff line change
Expand Up @@ -265,24 +265,24 @@
"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",
"Microsoft.VisualStudio.Component.VC.14.36.17.6.ARM.Spectre",
"Microsoft.VisualStudio.Component.VC.14.36.17.6.ARM",
"Microsoft.VisualStudio.Component.VC.14.36.17.6.ARM64.Spectre",
"Microsoft.VisualStudio.Component.VC.14.36.17.6.ARM64",
"Microsoft.VisualStudio.Component.VC.14.36.17.6.ATL.ARM.Spectre",
"Microsoft.VisualStudio.Component.VC.14.36.17.6.ATL.ARM",
"Microsoft.VisualStudio.Component.VC.14.36.17.6.ATL.ARM64.Spectre",
"Microsoft.VisualStudio.Component.VC.14.36.17.6.ATL.ARM64",
"Microsoft.VisualStudio.Component.VC.14.36.17.6.ATL.Spectre",
"Microsoft.VisualStudio.Component.VC.14.36.17.6.ATL",
"Microsoft.VisualStudio.Component.VC.14.36.17.6.MFC.ARM.Spectre",
"Microsoft.VisualStudio.Component.VC.14.36.17.6.MFC.ARM",
"Microsoft.VisualStudio.Component.VC.14.36.17.6.MFC.ARM64.Spectre",
"Microsoft.VisualStudio.Component.VC.14.36.17.6.MFC.ARM64",
"Microsoft.VisualStudio.Component.VC.14.36.17.6.MFC.Spectre",
"Microsoft.VisualStudio.Component.VC.14.36.17.6.MFC",
"Microsoft.VisualStudio.Component.VC.14.36.17.6.x86.x64.Spectre",
"Microsoft.VisualStudio.Component.VC.14.36.17.6.x86.x64",
"Microsoft.VisualStudio.Component.VC.14.37.17.7.ARM.Spectre",
"Microsoft.VisualStudio.Component.VC.14.37.17.7.ARM",
"Microsoft.VisualStudio.Component.VC.14.37.17.7.ARM64.Spectre",
"Microsoft.VisualStudio.Component.VC.14.37.17.7.ARM64",
"Microsoft.VisualStudio.Component.VC.14.37.17.7.ATL.ARM.Spectre",
"Microsoft.VisualStudio.Component.VC.14.37.17.7.ATL.ARM",
"Microsoft.VisualStudio.Component.VC.14.37.17.7.ATL.ARM64.Spectre",
"Microsoft.VisualStudio.Component.VC.14.37.17.7.ATL.ARM64",
"Microsoft.VisualStudio.Component.VC.14.37.17.7.ATL.Spectre",
"Microsoft.VisualStudio.Component.VC.14.37.17.7.ATL",
"Microsoft.VisualStudio.Component.VC.14.37.17.7.MFC.ARM.Spectre",
"Microsoft.VisualStudio.Component.VC.14.37.17.7.MFC.ARM",
"Microsoft.VisualStudio.Component.VC.14.37.17.7.MFC.ARM64.Spectre",
"Microsoft.VisualStudio.Component.VC.14.37.17.7.MFC.ARM64",
"Microsoft.VisualStudio.Component.VC.14.37.17.7.MFC.Spectre",
"Microsoft.VisualStudio.Component.VC.14.37.17.7.MFC",
"Microsoft.VisualStudio.Component.VC.14.37.17.7.x86.x64.Spectre",
"Microsoft.VisualStudio.Component.VC.14.37.17.7.x86.x64",
"Microsoft.VisualStudio.Component.VC.ATLMFC",
"Microsoft.VisualStudio.Component.VC.ATLMFC.Spectre",
"Microsoft.VisualStudio.Component.Windows10SDK.19041",
Expand Down

0 comments on commit 1e590b7

Please sign in to comment.