From c4e85b2e090ec15e6173dde648459b2f1fc12797 Mon Sep 17 00:00:00 2001 From: Alex Earl Date: Tue, 23 Apr 2024 22:57:03 -0700 Subject: [PATCH] Add Visual Studio 2019 Tools to Windows Image (#1143) * Add Visual Studio 2019 Tools to Windows Image Adds Visual Studio 2019 Build Tools to the Windows image. This will allow building native applications/DLLs for Windows in the Jenkins infrastructure. * Make sure install process completes Makes sure that the install process has completed before moving on. * Add check for 2019 when installing VS Build Tools Adds a check for the environment variable (AGENT_OS_VERSION) to only install VS Build Tools if it is 2019. * Skip goss check on 2022 Skips the goss check fir VS Built Tools if building for 2022. --- build-jenkins-agent-windows.pkr.hcl | 7 +++++++ goss/goss-windows.yaml | 6 ++++++ provisioning/tools-versions.yml | 1 + provisioning/visualstudio.vsconfig | 23 +++++++++++++++++++++++ provisioning/windows-provision.ps1 | 14 ++++++++++++++ 5 files changed, 51 insertions(+) create mode 100644 provisioning/visualstudio.vsconfig diff --git a/build-jenkins-agent-windows.pkr.hcl b/build-jenkins-agent-windows.pkr.hcl index cbc804004..64bc3df79 100644 --- a/build-jenkins-agent-windows.pkr.hcl +++ b/build-jenkins-agent-windows.pkr.hcl @@ -54,6 +54,12 @@ build { destination = "C:/" } + provisioner "file" { + pause_before = "1m" + source = "./provisioning/visualstudio.vsconfig" + destination = "C:/" + } + provisioner "powershell" { pause_before = "1m" environment_vars = local.provisioning_env_vars @@ -92,6 +98,7 @@ build { "goss --use-alpha=1 --gossfile C:/goss-common.yaml --loglevel DEBUG validate --retry-timeout 300s", "Remove-Item -Force C:/goss-windows.yaml", "Remove-Item -Force C:/goss-common.yaml", + "Remove-Item -Force C:/visualstudio.vsconfig", ] } diff --git a/goss/goss-windows.yaml b/goss/goss-windows.yaml index e58af0c69..a9191ca78 100644 --- a/goss/goss-windows.yaml +++ b/goss/goss-windows.yaml @@ -54,6 +54,12 @@ command: exit-status: 0 stdout: - 2.4.1 + visualstudio: + exec: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe" -nologo -version + exit-status: 0 + stdout: + - /16\.\d+\.\d+\.\d+/ + skip: {{ not(eq .Env.AGENT_OS_VERSION "2019") }} file: C:\Program Files\Chromium\Application\: contains: [] diff --git a/provisioning/tools-versions.yml b/provisioning/tools-versions.yml index 858493ca4..d9d49862a 100644 --- a/provisioning/tools-versions.yml +++ b/provisioning/tools-versions.yml @@ -49,3 +49,4 @@ windows_pwsh_version: 7.4.2 xq_version: 1.2.3 yq_version: 4.42.1 playwright_version: 1.43.1 +vs_buildtools_version: 16 diff --git a/provisioning/visualstudio.vsconfig b/provisioning/visualstudio.vsconfig new file mode 100644 index 000000000..1933b7de8 --- /dev/null +++ b/provisioning/visualstudio.vsconfig @@ -0,0 +1,23 @@ +{ + "version": "1.0", + "components": [ + "Microsoft.VisualStudio.Component.Roslyn.Compiler", + "Microsoft.VisualStudio.Component.CoreBuildTools", + "Microsoft.Component.MSBuild", + "Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Core", + "Microsoft.VisualStudio.Workload.NativeDesktop", + "Microsoft.VisualStudio.Component.TextTemplating", + "Microsoft.VisualStudio.Component.Windows10SDK.19041", + "Microsoft.VisualStudio.Component.Windows10SDK.16299", + "Microsoft.VisualStudio.Component.VC.CoreIde", + "Microsoft.VisualStudio.Component.VC.CoreBuildTools", + "Microsoft.VisualStudio.Component.VC.Redist.14.Latest", + "Microsoft.VisualStudio.Component.VC.Tools.x86.x64", + "Microsoft.VisualStudio.Component.VC.v141.x86.x64", + "Microsoft.VisualStudio.Component.VC.Tools.ARM64", + "Microsoft.VisualStudio.Component.VC.v141.ARM64", + "Microsoft.VisualStudio.Component.VC.Tools.ARM", + "Microsoft.VisualStudio.Component.VC.v141.ARM", + ], + "extensions": [] +} \ No newline at end of file diff --git a/provisioning/windows-provision.ps1 b/provisioning/windows-provision.ps1 index c69e68ebc..37962e8a3 100644 --- a/provisioning/windows-provision.ps1 +++ b/provisioning/windows-provision.ps1 @@ -269,6 +269,20 @@ $downloads = [ordered]@{ }; } +if("2019" -eq $env:AGENT_OS_VERSION) { + # We only do this for 2019 until installing on 2022 can be debugged + $downloads['vs-build-tools'] = @{ + 'url' = 'https://aka.ms/vs/{0}/release/vs_buildtools.exe' -f $env:VS_BUILDTOOLS_VERSION; + 'local' = "$baseDir\vs_buildtools.exe"; + 'postExpand' = { + $p = Start-Process -Wait -PassThru -NoNewWindow -FilePath "$baseDir\vs_buildtools.exe" ` + -ArgumentList "--installPath `"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community`" --quiet --wait --norestart --nocache --config C:\visualstudio.vsconfig" + $p.WaitForExit() + }; + 'cleanupLocal' = 'true'; + }; +} + ## Add tools folder to PATH so we can sanity check them as soon as they are installed AddToPathEnv $baseDir