From 98c2e94385ab9d5cca7bcf3aa9f0c814a7ccd659 Mon Sep 17 00:00:00 2001 From: baldurk Date: Thu, 10 Jul 2025 17:52:17 +0100 Subject: [PATCH] Switch to python script for CI VS install that might magically work * Also for diagnostic purposes, print whether the installer succeeded --- .github/workflows/ci.yml | 28 ++++++++++++-- .github/workflows/install-vs-components.py | 44 ++++++++++++++++++++++ 2 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/install-vs-components.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7321da0d5..479903e85 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -137,10 +137,32 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 5 - - name: Install missing VC tools + + - name: Install VSSetup + run: Install-Module VSSetup -Scope CurrentUser + shell: powershell + + - name: Show installed toolsets run: | - "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe" modify --installPath "C:\Program Files\Microsoft Visual Studio\2022\Enterprise" --add Microsoft.VisualStudio.Component.VC.140 --quiet --norestart --nocache - shell: cmd + echo "--- All:" + Get-VSSetupInstance -All + echo "--- VC140:" + Get-VSSetupInstance -All | Select-VSSetupInstance -Latest -Require Microsoft.VisualStudio.Component.VC.140 + shell: powershell + + - if: matrix.toolset == 'v140' + name: Install missing Visual Studio components + run: python .github/workflows/install-vs-components.py + + - if: matrix.toolset == 'v140' + name: Show installed toolsets + run: | + echo "--- All:" + Get-VSSetupInstance -All + echo "--- VC140:" + Get-VSSetupInstance -All | Select-VSSetupInstance -Latest -Require Microsoft.VisualStudio.Component.VC.140 + shell: powershell + - name: Download optional 3rdparty extras run: | curl https://renderdoc.org/qrenderdoc_3rdparty.zip -O diff --git a/.github/workflows/install-vs-components.py b/.github/workflows/install-vs-components.py new file mode 100644 index 000000000..1663dcc66 --- /dev/null +++ b/.github/workflows/install-vs-components.py @@ -0,0 +1,44 @@ +# Taken from https://github.com/mhammond/pywin32/blob/main/.github/workflows/install-vs-components.py + +# See https://github.com/actions/runner-images/issues/9701 +# Adapted from https://github.com/actions/runner-images/issues/9873#issuecomment-2139288682 + +import os +import platform +from itertools import chain +from subprocess import check_call, check_output + +os.chdir("C:/Program Files (x86)/Microsoft Visual Studio/Installer") +vs_install_path = check_output( + ( + "vswhere.exe", + "-latest", + "-products", + "*", + "-requires", + "Microsoft.Component.MSBuild", + "-property", + "installationPath", + ), + text=True, + shell=True, +).strip() +components_to_add = ( + ["Microsoft.VisualStudio.Component.VC.140"] +) +args = ( + "vs_installer.exe", + "modify", + "--installPath", + vs_install_path, + *chain.from_iterable([("--add", component) for component in components_to_add]), + "--quiet", + "--norestart", +) +print(*args) + +# Should be run twice for some reason +print("First run...") +check_call(args) +print("Second run...") +check_call(args)