Skip to content

Commit

Permalink
Add Visual Studio 2019 Tools to Windows Image (#1143)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
slide authored Apr 24, 2024
1 parent 99995ca commit c4e85b2
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 0 deletions.
7 changes: 7 additions & 0 deletions build-jenkins-agent-windows.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
]
}

Expand Down
6 changes: 6 additions & 0 deletions goss/goss-windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: []
Expand Down
1 change: 1 addition & 0 deletions provisioning/tools-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
23 changes: 23 additions & 0 deletions provisioning/visualstudio.vsconfig
Original file line number Diff line number Diff line change
@@ -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": []
}
14 changes: 14 additions & 0 deletions provisioning/windows-provision.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit c4e85b2

Please sign in to comment.