From 57ae2b1b77c5b2c25e044cc6f05b5e25bc52351e Mon Sep 17 00:00:00 2001
From: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Date: Thu, 07 May 2026 07:01:24 +0000
Subject: [PATCH] Fix Windows VC toolchain discovery in CI

---
 .github/workflows/build.yml |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 59c380d..ad45464 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -60,10 +60,19 @@
       if: runner.os == 'Windows'
       shell: cmd
       run: |
-        call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x86
-        cd opendj-server-legacy\src\build-tools\windows
+        for /f "usebackq delims=" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do set "VSINSTALLDIR=%%i"
+        if not defined VSINSTALLDIR (
+          echo Unable to locate a Visual Studio installation with C++ build tools.
+          exit /b 1
+        )
+        call "%VSINSTALLDIR%\VC\Auxiliary\Build\vcvarsall.bat" x86
+        if errorlevel 1 exit /b %errorlevel%
+        pushd opendj-server-legacy\src\build-tools\windows
         nmake all
+        if errorlevel 1 exit /b %errorlevel%
         xcopy /Y *.exe ..\..\..\lib\
+        if errorlevel 1 exit /b %errorlevel%
+        popd
         git status
     - name: Set Integration Test Environment
       id: failsafe

--
Gitblit v1.10.0