From 11b406feeea6e8dfd82da1da00ed4081af271d3c Mon Sep 17 00:00:00 2001
From: Kai Tao <69313318+vanzue@users.noreply.github.com>
Date: Mon, 2 Feb 2026 09:15:53 +0800
Subject: [PATCH] Build: Fix release pipeline and local build failure (#45211)
## Summary of the Pull Request
Release pipeline is keeping failed, and local build failed at ut.
This pull request introduces changes to improve how test projects are
handled during release builds, ensuring that test code is not compiled
or analyzed when not needed - in doing release build, to - succeed the
execution and reduce built time.
And, to upgrade from VS17 to VS18 in cmdpal sdk build, this is to keep
consistency with all other build step
## PR Checklist
- [ ] Closes: #xxx
- [ ] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [ ] **Tests:** Added/updated and all pass
- [ ] **Localization:** All end-user-facing strings can be localized
- [ ] **Dev docs:** Added/updated
- [ ] **New binaries:** Added on the required places
- [ ] [JSON for
signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx
## Detailed Description of the Pull Request / Additional comments
## Validation Steps Performed
Local build & release pipeline build should all pass:
Local build:
Release pipeline is working too:
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
---
.github/actions/spell-check/expect.txt | 3 +-
.pipelines/v2/release.yml | 1 +
.pipelines/v2/templates/job-build-project.yml | 1 +
.pipelines/v2/templates/pipeline-ci-build.yml | 5 ++-
.../verifyNoticeMdAgainstNugetPackages.ps1 | 42 +++++++++++++++----
Cpp.Build.props | 6 +++
Directory.Build.props | 37 +++++++++++++++-
Directory.Build.targets | 39 ++++++++++++++++-
.../Microsoft.CmdPal.Core.ViewModels.csproj | 4 ++
...t.CommandPalette.Extensions.Toolkit.csproj | 8 +++-
10 files changed, 133 insertions(+), 13 deletions(-)
diff --git a/.github/actions/spell-check/expect.txt b/.github/actions/spell-check/expect.txt
index aac8998ed4..e4002c1774 100644
--- a/.github/actions/spell-check/expect.txt
+++ b/.github/actions/spell-check/expect.txt
@@ -1025,6 +1025,7 @@ Metacharacter
metadatamatters
Metadatas
metafile
+Metacharacter
mfc
Mgmt
Microwaved
@@ -1071,7 +1072,7 @@ mouseutils
MOVESIZEEND
MOVESIZESTART
MRM
-MRT
+Mrt
mru
MSAL
msc
diff --git a/.pipelines/v2/release.yml b/.pipelines/v2/release.yml
index a9799dc031..d3adc45f04 100644
--- a/.pipelines/v2/release.yml
+++ b/.pipelines/v2/release.yml
@@ -91,6 +91,7 @@ extends:
official: true
codeSign: true
runTests: false
+ buildTests: false
signingIdentity:
serviceName: $(SigningServiceName)
appId: $(SigningAppId)
diff --git a/.pipelines/v2/templates/job-build-project.yml b/.pipelines/v2/templates/job-build-project.yml
index fb321f6f2f..e41bfbc0ad 100644
--- a/.pipelines/v2/templates/job-build-project.yml
+++ b/.pipelines/v2/templates/job-build-project.yml
@@ -258,6 +258,7 @@ jobs:
-restore -graph
/p:RestorePackagesConfig=true
/p:CIBuild=true
+ /p:BuildTests=${{ parameters.buildTests }}
/bl:$(LogOutputDirectory)\build-0-main.binlog
${{ parameters.additionalBuildOptions }}
$(MSBuildCacheParameters)
diff --git a/.pipelines/v2/templates/pipeline-ci-build.yml b/.pipelines/v2/templates/pipeline-ci-build.yml
index 0ef570d0c8..a56c575399 100644
--- a/.pipelines/v2/templates/pipeline-ci-build.yml
+++ b/.pipelines/v2/templates/pipeline-ci-build.yml
@@ -59,6 +59,7 @@ stages:
enableMsBuildCaching: ${{ parameters.enableMsBuildCaching }}
msBuildCacheIsReadOnly: ${{ parameters.msBuildCacheIsReadOnly }}
runTests: ${{ parameters.runTests }}
+ buildTests: true
useVSPreview: ${{ parameters.useVSPreview }}
useLatestWinAppSDK: ${{ parameters.useLatestWinAppSDK }}
${{ if eq(parameters.useLatestWinAppSDK, true) }}:
@@ -78,7 +79,9 @@ stages:
${{ else }}:
name: SHINE-OSS-L
${{ if eq(parameters.useVSPreview, true) }}:
- demands: ImageOverride -equals SHINE-VS17-Preview
+ demands: ImageOverride -equals SHINE-VS18-Preview
+ ${{ else }}:
+ demands: ImageOverride -equals SHINE-VS18-Latest
buildConfigurations: [Release]
official: false
codeSign: false
diff --git a/.pipelines/verifyNoticeMdAgainstNugetPackages.ps1 b/.pipelines/verifyNoticeMdAgainstNugetPackages.ps1
index af9ab8ff6f..a5cf73e6e9 100644
--- a/.pipelines/verifyNoticeMdAgainstNugetPackages.ps1
+++ b/.pipelines/verifyNoticeMdAgainstNugetPackages.ps1
@@ -90,9 +90,15 @@ if ($noticeMatch.Success) {
$currentNoticePackageList = ""
}
+# Test-only packages that are allowed to be in NOTICE.md but not in the build
+# (e.g., when BuildTests=false, these packages won't appear in the NuGet list)
+$allowedExtraPackages = @(
+ "- Moq"
+)
+
if (!$noticeFile.Trim().EndsWith($returnList.Trim()))
{
- Write-Host -ForegroundColor Red "Notice.md does not match NuGet list."
+ Write-Host -ForegroundColor Yellow "Notice.md does not exactly match NuGet list. Analyzing differences..."
# Show detailed differences
$generatedPackages = $returnList -split "`r`n|`n" | Where-Object { $_.Trim() -ne "" } | Sort-Object
@@ -105,7 +111,7 @@ if (!$noticeFile.Trim().EndsWith($returnList.Trim()))
# Find packages in proj file list but not in NOTICE.md
$missingFromNotice = $generatedPackages | Where-Object { $noticePackages -notcontains $_ }
if ($missingFromNotice.Count -gt 0) {
- Write-Host -ForegroundColor Red "MissingFromNotice:"
+ Write-Host -ForegroundColor Red "MissingFromNotice (ERROR - these must be added to NOTICE.md):"
foreach ($pkg in $missingFromNotice) {
Write-Host -ForegroundColor Red " $pkg"
}
@@ -114,10 +120,23 @@ if (!$noticeFile.Trim().EndsWith($returnList.Trim()))
# Find packages in NOTICE.md but not in proj file list
$extraInNotice = $noticePackages | Where-Object { $generatedPackages -notcontains $_ }
- if ($extraInNotice.Count -gt 0) {
- Write-Host -ForegroundColor Yellow "ExtraInNotice:"
- foreach ($pkg in $extraInNotice) {
- Write-Host -ForegroundColor Yellow " $pkg"
+
+ # Filter out allowed extra packages (test-only dependencies)
+ $unexpectedExtra = $extraInNotice | Where-Object { $allowedExtraPackages -notcontains $_ }
+ $allowedExtra = $extraInNotice | Where-Object { $allowedExtraPackages -contains $_ }
+
+ if ($allowedExtra.Count -gt 0) {
+ Write-Host -ForegroundColor Green "ExtraInNotice (OK - allowed test-only packages):"
+ foreach ($pkg in $allowedExtra) {
+ Write-Host -ForegroundColor Green " $pkg"
+ }
+ Write-Host ""
+ }
+
+ if ($unexpectedExtra.Count -gt 0) {
+ Write-Host -ForegroundColor Red "ExtraInNotice (ERROR - unexpected packages in NOTICE.md):"
+ foreach ($pkg in $unexpectedExtra) {
+ Write-Host -ForegroundColor Red " $pkg"
}
Write-Host ""
}
@@ -127,10 +146,17 @@ if (!$noticeFile.Trim().EndsWith($returnList.Trim()))
Write-Host " Proj file list has $($generatedPackages.Count) packages"
Write-Host " NOTICE.md has $($noticePackages.Count) packages"
Write-Host " MissingFromNotice: $($missingFromNotice.Count) packages"
- Write-Host " ExtraInNotice: $($extraInNotice.Count) packages"
+ Write-Host " ExtraInNotice (allowed): $($allowedExtra.Count) packages"
+ Write-Host " ExtraInNotice (unexpected): $($unexpectedExtra.Count) packages"
Write-Host ""
- exit 1
+ # Fail if there are missing packages OR unexpected extra packages
+ if ($missingFromNotice.Count -gt 0 -or $unexpectedExtra.Count -gt 0) {
+ Write-Host -ForegroundColor Red "FAILED: NOTICE.md mismatch detected."
+ exit 1
+ } else {
+ Write-Host -ForegroundColor Green "PASSED: NOTICE.md matches (with allowed test-only packages)."
+ }
}
exit 0
diff --git a/Cpp.Build.props b/Cpp.Build.props
index 4b8a206306..5acfbdee1a 100644
--- a/Cpp.Build.props
+++ b/Cpp.Build.props
@@ -2,6 +2,12 @@
+
+
+ false
+ false
+
+
diff --git a/Directory.Build.props b/Directory.Build.props
index e7b415cbca..99379ecefc 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -19,6 +19,39 @@
$(Platform)
+
+
+ <_ProjectName>$(MSBuildProjectName)
+
+ <_IsSkippedTestProject Condition="$(_ProjectName.EndsWith('Test'))">true
+ <_IsSkippedTestProject Condition="$(_ProjectName.EndsWith('Tests'))">true
+
+ <_IsSkippedTestProject Condition="$(_ProjectName.StartsWith('UnitTests-'))">true
+ <_IsSkippedTestProject Condition="$(_ProjectName.StartsWith('UITest-'))">true
+
+ <_IsSkippedTestProject Condition="$(MSBuildProjectDirectory.Contains('\Tests\'))">true
+
+
+
+ false
+ false
+ false
+ false
+ disable
+
+ false
+ false
+ false
+ false
+
+
$(Version).0
https://github.com/microsoft/PowerToys
@@ -30,7 +63,9 @@
<_PropertySheetDisplayName>PowerToys.Root.Props
$(MsbuildThisFileDirectory)\Cpp.Build.props
-
+
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/Directory.Build.targets b/Directory.Build.targets
index ab9bad297e..9efab5a9a5 100644
--- a/Directory.Build.targets
+++ b/Directory.Build.targets
@@ -28,4 +28,41 @@
$(NoWarn);CS8305;SA1500;CA1852
-
\ No newline at end of file
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/modules/cmdpal/Core/Microsoft.CmdPal.Core.ViewModels/Microsoft.CmdPal.Core.ViewModels.csproj b/src/modules/cmdpal/Core/Microsoft.CmdPal.Core.ViewModels/Microsoft.CmdPal.Core.ViewModels.csproj
index 4ace6c5783..6e1b224ecd 100644
--- a/src/modules/cmdpal/Core/Microsoft.CmdPal.Core.ViewModels/Microsoft.CmdPal.Core.ViewModels.csproj
+++ b/src/modules/cmdpal/Core/Microsoft.CmdPal.Core.ViewModels/Microsoft.CmdPal.Core.ViewModels.csproj
@@ -1,5 +1,9 @@
+
+
+ false
+
diff --git a/src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/Microsoft.CommandPalette.Extensions.Toolkit.csproj b/src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/Microsoft.CommandPalette.Extensions.Toolkit.csproj
index bce6dc1016..0e72a8a51a 100644
--- a/src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/Microsoft.CommandPalette.Extensions.Toolkit.csproj
+++ b/src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/Microsoft.CommandPalette.Extensions.Toolkit.csproj
@@ -84,7 +84,13 @@
IL2081;$(WarningsNotAsErrors)
-
+
+
+
+
+
+
+