Skip to content

Commit e1d4856

Browse files
committed
Update VS 2019 and add VS 2022 to Windows AMI
1 parent eac2407 commit e1d4856

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

aws/ami/windows/scripts/Installers/Install-VS.ps1

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
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

2123
if (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."
3233
curl.exe --retry 3 -kL $VS_DOWNLOAD_LINK --output vs_installer.exe
3334
if ($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
5253
Remove-Item -Path vs_installer.exe -Force
5354
$exitCode = $process.ExitCode
5455
if (($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."

aws/ami/windows/windows.pkr.hcl

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,31 @@ build {
5555
]
5656
}
5757

58+
# Install the Visual Studio 2019
59+
provisioner "powershell" {
60+
environment_vars = ["INSTALL_WINDOWS_SDK=1", "VS_YEAR=2019", "VS_VERSION=16.11.21"]
61+
execution_policy = "unrestricted"
62+
scripts = [
63+
"${path.root}/scripts/Installers/Install-VS.ps1",
64+
]
65+
}
66+
67+
# Install the Visual Studio 2022
68+
provisioner "powershell" {
69+
environment_vars = ["INSTALL_WINDOWS_SDK=1", "VS_YEAR=2022", "VS_VERSION=17.4.1"]
70+
execution_policy = "unrestricted"
71+
scripts = [
72+
"${path.root}/scripts/Installers/Install-VS.ps1",
73+
]
74+
}
75+
5876
# Install the rest of the dependencies
5977
provisioner "powershell" {
60-
environment_vars = ["INSTALL_WINDOWS_SDK=1", "VS_VERSION=16.8.6"]
6178
execution_policy = "unrestricted"
6279
scripts = [
6380
"${path.root}/scripts/Helpers/Reset-UserData.ps1",
6481
"${path.root}/scripts/Installers/Install-Choco.ps1",
6582
"${path.root}/scripts/Installers/Install-Tools.ps1",
66-
"${path.root}/scripts/Installers/Install-VS.ps1",
6783
]
6884
}
6985

0 commit comments

Comments
 (0)