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