11#  https://developercommunity.visualstudio.com/t/install-specific-version-of-vs-component/1142479
2- #  Where to find the links: https://docs.microsoft.com/en-us/visualstudio/releases/2019/history#release-dates-and-build-numbers
3- 
2+ #  Where to find the links: 
3+ #    - https://docs.microsoft.com/en-us/visualstudio/releases/2019/history#release-dates-and-build-numbers
4+ #    - https://learn.microsoft.com/en-us/visualstudio/releases/2022/release-history#fixed-version-bootstrappers
45#  BuildTools from S3
5- $VS_DOWNLOAD_LINK  =  " https://s3.amazonaws.com/ossci-windows/vs${env: VS_VERSION} _BuildTools.exe" 
6+ $VS_VERSION_major  =  [int ] ${env: VS_VERSION}.split  (" ."  )[0 ]
7+ $VS_DOWNLOAD_LINK  =  " https://aka.ms/vs/$VS_VERSION_major /release/vs_BuildTools.exe" 
68$COLLECT_DOWNLOAD_LINK  =  " https://aka.ms/vscollect.exe" 
79$VS_INSTALL_ARGS  =  @ (" --nocache" , " --quiet" , " --wait" ,  " --add Microsoft.VisualStudio.Workload.VCTools" , 
810                                                     " --add Microsoft.Component.MSBuild" , 
@@ -19,19 +21,18 @@ if (${env:INSTALL_WINDOWS_SDK} -eq "1") {
1921}
2022
2123if  (Test-Path  " ${env: ProgramFiles(x86)} \Microsoft Visual Studio\Installer\vswhere.exe"  ) {
22-     $VS_VERSION_major  =  [int ] ${env: VS_VERSION}.split  (" ."  )[0 ]
23-     $existingPath  =  &  " ${env: ProgramFiles(x86)} \Microsoft Visual Studio\Installer\vswhere.exe"   - products " Microsoft.VisualStudio.Product.BuildTools"   - version " [${env: VS_VERSION} , ${env: VS_VERSION_major + 1} )"   - property installationPath
24+     $existingPath  =  &  " ${env: ProgramFiles(x86)} \Microsoft Visual Studio\Installer\vswhere.exe"   - products " Microsoft.VisualStudio.Product.BuildTools"   - version " [${env: VS_VERSION} , ${VS_VERSION_major + 1} )"   - property installationPath
2425    if  (($existingPath  -ne  $null ) -and  (! ${env: CIRCLECI} )) {
2526        echo " Found correctly versioned existing BuildTools installation in $existingPath " 
2627        exit  0 
2728    }
2829    $pathToRemove  =  &  " ${env: ProgramFiles(x86)} \Microsoft Visual Studio\Installer\vswhere.exe"   - products " Microsoft.VisualStudio.Product.BuildTools"   - property installationPath
2930}
3031
31- echo " Downloading VS  installer from S3 ." 
32+ echo " Downloading Visual Studio  installer from $VS_DOWNLOAD_LINK ." 
3233curl.exe  -- retry 3  - kL $VS_DOWNLOAD_LINK  -- output vs_installer.exe 
3334if  ($LASTEXITCODE  -ne  0 ) {
34-     echo " Download of the VS 2019  Version ${env: VS_VERSION}  installer failed" 
35+     echo " Download of the VS ${ env: VS_YEAR}   Version ${env: VS_VERSION}  installer failed" 
3536    exit  1 
3637}
3738
@@ -52,7 +53,7 @@ $process = Start-Process "${PWD}\vs_installer.exe" -ArgumentList $VS_INSTALL_ARG
5253Remove-Item  - Path vs_installer.exe  - Force
5354$exitCode  =  $process.ExitCode  
5455if  (($exitCode  -ne  0 ) -and  ($exitCode  -ne  3010 )) {
55-     echo " VS 2019  installer exited with code $exitCode , which should be one of [0, 3010]." 
56+     echo " VS ${ env: VS_YEAR}   installer exited with code $exitCode , which should be one of [0, 3010]." 
5657    curl.exe  -- retry 3  - kL $COLLECT_DOWNLOAD_LINK  -- output Collect.exe 
5758    if  ($LASTEXITCODE  -ne  0 ) {
5859        echo " Download of the VS Collect tool failed." 
0 commit comments