From 731e5fc3a08c673bf0a795ae6584a75cfc6bd86b Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Fri, 19 Jun 2026 14:17:20 -0700 Subject: [PATCH] Locate Visual Studio via vswhere instead of hardcoding VS2022 path The windows-latest runner image moved from windows-2025 (VS2022) to windows-2025-vs2026 (VS2026), so the hardcoded C:\Program Files\Microsoft Visual Studio\2022\Enterprise paths in build_openssl.bat no longer exist. vcvarsall.bat never ran, the MSVC toolchain wasn't on PATH, and the win32/win64 builds failed with exit code 2. Use vswhere to discover the install path so the build works regardless of the VS version/edition the runner image ships. This also future-proofs the arm64 job (windows-11-arm) for when that image eventually moves to VS2026. Drop the now-inaccurate "MSVC 2022" from the job name. Co-Authored-By: Claude Opus 4.8 (1M context) --- .github/workflows/build-windows-openssl.yml | 2 +- windows/openssl/build_openssl.bat | 24 +++++++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-windows-openssl.yml b/.github/workflows/build-windows-openssl.yml index b44f8db5..f85476f6 100644 --- a/.github/workflows/build-windows-openssl.yml +++ b/.github/workflows/build-windows-openssl.yml @@ -29,7 +29,7 @@ jobs: - {ARCH: "win32", RUNNER: "windows-latest"} - {ARCH: "win64", RUNNER: "windows-latest"} - {ARCH: "arm64", RUNNER: "windows-11-arm"} - name: "Build OpenSSL for ${{ matrix.ARCH.ARCH }} on MSVC 2022" + name: "Build OpenSSL for ${{ matrix.ARCH.ARCH }} on MSVC" steps: - uses: actions/checkout@v6.0.3 with: diff --git a/windows/openssl/build_openssl.bat b/windows/openssl/build_openssl.bat index 28947c9e..5a87d7d2 100644 --- a/windows/openssl/build_openssl.bat +++ b/windows/openssl/build_openssl.bat @@ -5,19 +5,31 @@ cd openssl-* SET PATH=%PATH%;C:\Program Files\NASM SET CL=/FS + +REM Locate the Visual Studio install rather than hardcoding a version/edition, +REM so this keeps working as GitHub bumps the runner image (e.g. VS2022 -> VS2026). +REM The GitHub runner images put vswhere on PATH. If that ever stops being true, +REM it's installed by the VS Installer at a fixed location: +REM "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" +for /f "usebackq tokens=*" %%i in (`vswhere -latest -products * -property installationPath`) do set VSINSTALL=%%i +if not defined VSINSTALL ( + echo Could not locate a Visual Studio installation via vswhere + exit /b 1 +) + if "%BUILDARCH%" == "win32" ( - CALL "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\BuildTools\Common7\Tools\VsDevCmd.bat" -arch=x86 - CALL "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x86 + CALL "%VSINSTALL%\Common7\Tools\VsDevCmd.bat" -arch=x86 + CALL "%VSINSTALL%\VC\Auxiliary\Build\vcvarsall.bat" x86 perl Configure %OPENSSL_BUILD_FLAGS_WINDOWS% VC-WIN32 ) else if "%BUILDARCH%" == "win64" ( - CALL "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\BuildTools\Common7\Tools\VsDevCmd.bat" -arch=x64 - CALL "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + CALL "%VSINSTALL%\Common7\Tools\VsDevCmd.bat" -arch=x64 + CALL "%VSINSTALL%\VC\Auxiliary\Build\vcvarsall.bat" x64 perl Configure %OPENSSL_BUILD_FLAGS_WINDOWS% VC-WIN64A ) else if "%BUILDARCH%" == "arm64" ( - CALL "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\BuildTools\Common7\Tools\VsDevCmd.bat" -arch=arm64 - CALL "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" arm64 + CALL "%VSINSTALL%\Common7\Tools\VsDevCmd.bat" -arch=arm64 + CALL "%VSINSTALL%\VC\Auxiliary\Build\vcvarsall.bat" arm64 perl Configure %OPENSSL_BUILD_FLAGS_WINDOWS% VC-WIN64-ARM )