|
| 1 | +# https://developercommunity.visualstudio.com/t/install-specific-version-of-vs-component/1142479 |
| 2 | +# https://docs.microsoft.com/en-us/visualstudio/releases/2019/history#release-dates-and-build-numbers |
| 3 | + |
| 4 | +# 16.8.6 BuildTools |
| 5 | +$VS_DOWNLOAD_LINK = "https://ossci-windows.s3.us-east-1.amazonaws.com/vs16.8.6_BuildTools.exe" |
| 6 | +$COLLECT_DOWNLOAD_LINK = "https://aka.ms/vscollect.exe" |
| 7 | +$VS_INSTALL_ARGS = @("--nocache","--quiet","--wait", "--add Microsoft.VisualStudio.Workload.VCTools", |
| 8 | + "--add Microsoft.Component.MSBuild", |
| 9 | + "--add Microsoft.VisualStudio.Component.Roslyn.Compiler", |
| 10 | + "--add Microsoft.VisualStudio.Component.TextTemplating", |
| 11 | + "--add Microsoft.VisualStudio.Component.VC.CoreIde", |
| 12 | + "--add Microsoft.VisualStudio.Component.VC.Redist.14.Latest", |
| 13 | + "--add Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Core", |
| 14 | + "--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64", |
| 15 | + "--add Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Win81") |
| 16 | + |
| 17 | +curl.exe --retry 3 -kL $VS_DOWNLOAD_LINK --output vs_installer.exe |
| 18 | +if ($LASTEXITCODE -ne 0) { |
| 19 | + echo "Download of the VS 2019 Version 16.8.5 installer failed" |
| 20 | + exit 1 |
| 21 | +} |
| 22 | + |
| 23 | +if (Test-Path "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe") { |
| 24 | + $existingPath = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -products "Microsoft.VisualStudio.Product.BuildTools" -version "[16, 17)" -property installationPath |
| 25 | + if ($existingPath -ne $null) { |
| 26 | + if (!${env:CIRCLECI}) { |
| 27 | + echo "Found correctly versioned existing BuildTools installation in $existingPath" |
| 28 | + exit 0 |
| 29 | + } |
| 30 | + echo "Found existing BuildTools installation in $existingPath, keeping it" |
| 31 | + } |
| 32 | +} |
| 33 | + |
| 34 | +$process = Start-Process "${PWD}\vs_installer.exe" -ArgumentList $VS_INSTALL_ARGS -NoNewWindow -Wait -PassThru |
| 35 | +Remove-Item -Path vs_installer.exe -Force |
| 36 | +$exitCode = $process.ExitCode |
| 37 | +if (($exitCode -ne 0) -and ($exitCode -ne 3010)) { |
| 38 | + echo "VS 2019 installer exited with code $exitCode, which should be one of [0, 3010]." |
| 39 | + curl.exe --retry 3 -kL $COLLECT_DOWNLOAD_LINK --output Collect.exe |
| 40 | + if ($LASTEXITCODE -ne 0) { |
| 41 | + echo "Download of the VS Collect tool failed." |
| 42 | + exit 1 |
| 43 | + } |
| 44 | + Start-Process "${PWD}\Collect.exe" -NoNewWindow -Wait -PassThru |
| 45 | + New-Item -Path "C:\w\build-results" -ItemType "directory" -Force |
| 46 | + Copy-Item -Path "C:\Users\${env:USERNAME}\AppData\Local\Temp\vslogs.zip" -Destination "C:\w\build-results\" |
| 47 | + exit 1 |
| 48 | +} |
0 commit comments