Files
PowerToys/tools/build/BUILD-GUIDELINES.md
Jeremy Sinclair f82afdf384 [Dev][Build] VS 2026 Support (#44304)
<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request
This PR updates the PowerToys solution to support **Visual Studio 2026
(PlatformToolset v145)**. It centralizes the build configuration,
updates the C++ language standards, and fixes an issue with a MouseJump
unit test that appears while using the VS 2026 supported build agent.

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [ ] Closes: #xxx
- [x] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [x] **Tests:** Added/updated and all pass
- [ ] **Localization:** All end-user-facing strings can be localized
- [x] **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

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

**Build System & Configuration:**
- Updated `Cpp.Build.props` to use `v145` (VS 2026) as the default
`PlatformToolset`, with fall back to `v143` for VS 2022.
- Configured C++ Language Standard:
  - `stdcpplatest` for production projects.
- Removed explicit `<PlatformToolset>` definitions from individual
project files (approx. 37 modules) to inherit correctly from the central
`Cpp.Build.props`.

**Code Refactoring & Fixes:**
- Updated `DrawingHelperTests.cs` in MouseJump Unit Test to ease the
pixel difference tolerance. This became an issue after switching to the
new VS2026 build agent.
<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed

- Validated successful compilation of the entire solution. Similar
updates have been made to the .NET 10 branch, but these are much cleaner
and will be merged into that branch once fully confirmed working.

---------

Co-authored-by: Kai Tao (from Dev Box) <kaitao@microsoft.com>
Co-authored-by: Gordon Lam (SH) <yeelam@microsoft.com>
2026-01-28 15:46:34 -08:00

2.5 KiB
Raw Permalink Blame History

Build scripts quick guideline

Use these scripts to build PowerToys locally. They auto-detect your platform (x64/arm64), initialize the Visual Studio developer environment, and write helpful logs on failure.

Quick start (from cmd.exe)

  • Fast essentials (runner + settings) and NuGet restore first:
    • tools\build\build-essentials.cmd
  • Build projects in the current folder:
    • tools\build\build.cmd

Tip: Add D:\PowerToys\tools\build to your PATH to use the wrappers anywhere.

When to use which

  1. build-essentials.ps1

    • Restores NuGet for PowerToys.slnx and builds essentials (runner, settings).
    • Auto-detects Platform; initializes VS Dev environment automatically.
    • Example (PowerShell):
      • ./tools/build/build-essentials.ps1
      • ./tools/build/build-essentials.ps1 -Platform arm64 -Configuration Release
  2. build.ps1 (from any folder)

    • Builds any .sln/.csproj/.vcxproj in the current directory.
    • Auto-detects Platform; initializes VS Dev environment automatically.
    • Accepts extra MSBuild args (forwarded to msbuild):
      • ./tools/build/build.ps1 '/p:CIBuild=true' '/p:SomeProp=Value'
    • Restore only:
      • ./tools/build/build.ps1 -RestoreOnly
  3. build-installer.ps1 (use with caution)

    • Full local packaging pipeline (restore, build, sign MSIX, WiX v5 MSI/bootstrapper).
    • Auto-inits VS Dev environment. Cleans some output (keeps *.exe) under installer/.
    • Key options: -PerUser true|false, -InstallerSuffix wix5|vnext.
    • Example:
      • ./tools/build/build-installer.ps1 -Platform x64 -Configuration Release -PerUser true -InstallerSuffix wix5

Logs and troubleshooting

  • On failure, see logs next to the solution/project being built:
    • build.<configuration>.<platform>.all.log — full text log
    • build.<configuration>.<platform>.errors.log — errors only
    • build.<configuration>.<platform>.warnings.log — warnings only
    • build.<configuration>.<platform>.trace.binlog — open with MSBuild Structured Log Viewer
  • VS environment init:
    • Scripts try DevShell first (Microsoft.VisualStudio.DevShell.dll / Enter-VsDevShell), then fall back to VsDevCmd.bat.
    • If VS isn't found, run from "Developer PowerShell for VS 2022" or "Developer PowerShell for VS", or ensure vswhere.exe exists under Program Files (x86)\Microsoft Visual Studio\Installer.

Notes

  • Override platform explicitly with -Platform x64|arm64 if needed.
  • CMD wrappers: build.cmd, build-essentials.cmd forward all arguments to the PowerShell scripts.