From 9853bc96076e811cef5eab4469095fc9be58201e Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Thu, 11 Jun 2026 17:02:51 -0500 Subject: [PATCH] Update formatting scripts for Preview-only VS and pwsh 7 (#20312) This is a pair of changes to make the code formatting scripts work, circa 2026. * If you only have VS Insiders installed, then vswhere can't actually find a clang-format to build with. You need `-prerelease` to let it also find preview builds of VS. * Years ago we updated OpenConsole.psm1 to only support pwsh 7. I, of course, use `cmd` as my dev env for terminal, so I use `runformat.cmd`, which always shelled to `powershell` (5). This updates that tool to use pwsh 7. Clearly this impacted only me ever. related to #20162 --- tools/OpenConsole.psm1 | 2 +- tools/runformat.cmd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/OpenConsole.psm1 b/tools/OpenConsole.psm1 index b9c80ce457..1d51f4c5d0 100644 --- a/tools/OpenConsole.psm1 +++ b/tools/OpenConsole.psm1 @@ -416,7 +416,7 @@ function Invoke-CodeFormat() { [switch]$IgnoreXaml ) - $clangFormatPath = & 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe' -latest -find "**\x64\bin\clang-format.exe" + $clangFormatPath = & 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe' -latest -prerelease -find "**\x64\bin\clang-format.exe" If ([String]::IsNullOrEmpty($clangFormatPath)) { Write-Error "No Visual Studio-supplied version of clang-format could be found." } diff --git a/tools/runformat.cmd b/tools/runformat.cmd index d9c1d56c73..336ce12237 100644 --- a/tools/runformat.cmd +++ b/tools/runformat.cmd @@ -2,4 +2,4 @@ rem run clang-format on c++ files -powershell -noprofile "import-module %OPENCON_TOOLS%\openconsole.psm1; Invoke-CodeFormat" +pwsh -noprofile -c "import-module %OPENCON_TOOLS%\openconsole.psm1; Invoke-CodeFormat"