From 42924e71c76a1ccf4e95da2b6b6fa51322bb20ec Mon Sep 17 00:00:00 2001 From: Ray Cheung Date: Wed, 1 Apr 2026 18:14:37 +0800 Subject: [PATCH] Fix the `build.ps1` that does not work well with `-RestoreOnly` switch (#46012) ## Summary of the Pull Request Fix the `build.ps1` that does not work well with `-RestoreOnly` switch. Also there is `.slnf` now and the build script should support it. ## 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 --- tools/build/build-common.ps1 | 6 +++--- tools/build/build.ps1 | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/build/build-common.ps1 b/tools/build/build-common.ps1 index cadeba1542..1dbd356199 100644 --- a/tools/build/build-common.ps1 +++ b/tools/build/build-common.ps1 @@ -7,7 +7,7 @@ This file provides reusable helper functions used by the build scripts: - Get-BuildPaths: returns ScriptDir, OriginalCwd, RepoRoot (repo root detection) - RunMSBuild: wrapper around msbuild.exe (accepts optional Platform/Configuration) - RestoreThenBuild: performs restore and optionally builds the solution/project -- BuildProjectsInDirectory: discovers and builds local .sln/.csproj/.vcxproj files +- BuildProjectsInDirectory: discovers and builds local .slnx/.csproj/.vcxproj files - Ensure-VsDevEnvironment: initializes the Visual Studio developer environment when possible. It prefers the DevShell PowerShell module (Microsoft.VisualStudio.DevShell.dll / Enter-VsDevShell), falls back to running VsDevCmd.bat and importing its environment into the current PowerShell session, @@ -113,7 +113,7 @@ function BuildProjectsInDirectory { $files = @() try { - $files = Get-ChildItem -Path (Join-Path $DirectoryPath '*') -Include *.sln,*.slnx,*.csproj,*.vcxproj -File -ErrorAction SilentlyContinue + $files = Get-ChildItem -Path (Join-Path $DirectoryPath '*') -Include *.sln,*.slnx,*.slnf,*.csproj,*.vcxproj -File -ErrorAction SilentlyContinue } catch { $files = @() } @@ -130,7 +130,7 @@ function BuildProjectsInDirectory { foreach ($f in $files) { Write-Host ("[LOCAL BUILD] Building {0}" -f $f.FullName) - if ($f.Extension -eq '.sln') { + if ($f.Extension -eq '.sln' -or $f.Extension -eq '.slnx') { RestoreThenBuild $f.FullName $ExtraArgs $Platform $Configuration $RestoreOnly } else { $buildArgs = '/m' diff --git a/tools/build/build.ps1 b/tools/build/build.ps1 index 750d60a7d4..a574eae398 100644 --- a/tools/build/build.ps1 +++ b/tools/build/build.ps1 @@ -86,7 +86,7 @@ if (-not $Platform -or $Platform -eq '') { } } -$cwd = if ($Path) { +$cwd = if ($Path -ne '') { (Resolve-Path $Path).ProviderPath } else { (Get-Location).ProviderPath