From e6c2b099d0b907d7f4d06d72a7fe79246705b2bb Mon Sep 17 00:00:00 2001 From: Chaim Date: Mon, 11 May 2026 15:59:50 +0000 Subject: [PATCH] fix(ci): use VS Pro MSBuild (requires Office workload) instead of Build Tools VS Build Tools 2022 does not ship Microsoft.VisualStudio.Tools.Office.targets (only the full VS IDE editions do), so the VSTO project fails to import them (MSB4226). The runner machine already has VS Pro 2022 with the Office workload installed; switch from microsoft/setup-msbuild@v2 (which picks Build Tools via -latest) to a manual vswhere step that explicitly requires the Office workload. Also removes the temporary filesystem-debug step (root cause was the Win32 File System Redirector pulling system32 paths to SysWOW64 for 32-bit nuget/MSBuild; fixed at the runner level via USERPROFILE redirect, not in the workflow). Co-Authored-By: Claude Opus 4.7 (1M context) --- .gitea/workflows/build.yml | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 1fb147a..47e223e 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -19,25 +19,19 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Debug — show what checkout produced + - name: Add Office-capable MSBuild to PATH shell: powershell run: | - Write-Host "CWD: $(Get-Location)" - Write-Host "GITHUB_WORKSPACE: $env:GITHUB_WORKSPACE" - Write-Host "" - Write-Host "=== Top-level entries ===" - Get-ChildItem -Force | Format-Table Name, Length, Mode - Write-Host "" - Write-Host "=== All .csproj and .sln files ===" - Get-ChildItem -Recurse -File -Include *.csproj,*.sln -ErrorAction SilentlyContinue | - ForEach-Object { Write-Host "$($_.FullName) ($($_.Length) bytes)" } - Write-Host "" - Write-Host "=== src/ tree ===" - if (Test-Path src) { Get-ChildItem -Recurse src -Depth 1 -ErrorAction SilentlyContinue | ForEach-Object { Write-Host $_.FullName } } - else { Write-Host "src/ does not exist!" } - - - name: Add MSBuild to PATH - uses: microsoft/setup-msbuild@v2 + # microsoft/setup-msbuild@v2 picks `vswhere -latest`, which prefers + # Build Tools 2022. Build Tools has no VSTO targets (MSB4226), so + # locate a VS installation that explicitly has the Office workload + # (the one that ships Microsoft.VisualStudio.Tools.Office.targets). + $vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" + $installPath = & $vswhere -products * -requires Microsoft.VisualStudio.Workload.Office -property installationPath | Select-Object -First 1 + if (-not $installPath) { throw "No VS installation with the Office workload found on this runner." } + $msbuildDir = Join-Path $installPath 'MSBuild\Current\Bin' + Write-Host "Using MSBuild from $msbuildDir" + Add-Content -Path $env:GITHUB_PATH -Value $msbuildDir - name: Setup NuGet uses: nuget/setup-nuget@v2 @@ -66,8 +60,13 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Add MSBuild to PATH - uses: microsoft/setup-msbuild@v2 + - name: Add Office-capable MSBuild to PATH + shell: powershell + run: | + $vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" + $installPath = & $vswhere -products * -requires Microsoft.VisualStudio.Workload.Office -property installationPath | Select-Object -First 1 + if (-not $installPath) { throw "No VS installation with the Office workload found on this runner." } + Add-Content -Path $env:GITHUB_PATH -Value (Join-Path $installPath 'MSBuild\Current\Bin') - name: Setup NuGet uses: nuget/setup-nuget@v2