From 7b19b4c21922b9ced9b6542b60c5b1d4821d4887 Mon Sep 17 00:00:00 2001 From: Clint Rutkas Date: Mon, 29 Jun 2026 14:29:14 -0700 Subject: [PATCH] Add build-time guard for Windows long path support (#49028) PowerToys has deeply nested source paths that exceed the legacy 260-character MAX_PATH limit. Contributors who haven't enabled Windows long path support hit cryptic 'path too long' / 'could not find file' errors during their first build. Add an EnsureLongPathsEnabled MSBuild target in Directory.Build.targets that reads HKLM\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled and fails fast with an actionable error (PTLONGPATH) pointing at tools\build\setup-dev-environment.ps1. Covers both Visual Studio and the command-line build scripts, skips design-time builds, and can be bypassed with /p:SkipLongPathsCheck=true. **What happens if Long file path isn't enabled.** image Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- Directory.Build.targets | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Directory.Build.targets b/Directory.Build.targets index 4ba887527a..6ad39ac215 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -4,6 +4,29 @@ + + + + <_LongPathsEnabled>$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem', 'LongPathsEnabled', null, RegistryView.Registry64)) + + + + $(WindowsSdkDir)bin\x64\mt.exe