fix(ci): unify restore + build via 'msbuild /restore' (avoid NETSDK1064)

Standalone 'nuget.exe restore' (32-bit) and the subsequent build (which
loads the 64-bit .NET 9 SDK PackageDependencyResolution.targets) disagree
on the resolved package paths, surfacing as NETSDK1064 'Package ... was
not found' on SDK-style projects (OutlookAddin.UI / .Core / .Tests).
Using 'msbuild /restore' keeps both phases in one MSBuild process with a
consistent assets file and package cache lookup.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-11 16:04:00 +00:00
parent e6c2b099d0
commit 55d3e6d0f3
+8 -16
View File
@@ -33,14 +33,12 @@ jobs:
Write-Host "Using MSBuild from $msbuildDir"
Add-Content -Path $env:GITHUB_PATH -Value $msbuildDir
- name: Setup NuGet
uses: nuget/setup-nuget@v2
- name: Restore NuGet
run: nuget restore OutlookAddin.sln
- name: Build
run: msbuild OutlookAddin.sln /t:Build /p:Configuration=Release /p:Platform="Any CPU" /m
- name: Build (restore + compile)
# `msbuild /restore` runs restore and build in the same MSBuild process,
# which keeps the NuGet package cache + project.assets.json + assembly
# resolution consistent (avoids NETSDK1064 from a mismatch between a
# standalone `nuget restore` and the later build).
run: msbuild OutlookAddin.sln /restore /t:Build /p:Configuration=Release /p:Platform="Any CPU" /m
- name: Test
run: dotnet test src/OutlookAddin.Tests/OutlookAddin.Tests.csproj --configuration Release --no-build --logger "trx;LogFileName=test-results.trx"
@@ -68,9 +66,6 @@ jobs:
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
- name: Resolve mage.exe + signtool.exe paths
id: tools
shell: powershell
@@ -131,11 +126,8 @@ jobs:
Remove-Item -Force $tmpPfx
Write-Host "Cert imported."
- name: Restore NuGet
run: nuget restore OutlookAddin.sln
- name: Build Release
run: msbuild OutlookAddin.sln /t:Build /p:Configuration=Release /p:Platform="Any CPU" /m
- name: Build Release (restore + compile)
run: msbuild OutlookAddin.sln /restore /t:Build /p:Configuration=Release /p:Platform="Any CPU" /m
# Code signing -- cert in LocalMachine\My (or CurrentUser\My); signtool
# picks it by thumbprint, the service runs as LocalSystem so the runtime