From dc5d1a1d7f789034a0ed0c7f04dd7cf282840238 Mon Sep 17 00:00:00 2001 From: Mark Schofield <34426337+MarkSchofield@users.noreply.github.com> Date: Mon, 6 Oct 2025 20:47:08 -0700 Subject: [PATCH] Accommodate '[' and ']' in preset names when finding the code model --- PSCMake/Common/CMake.ps1 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/PSCMake/Common/CMake.ps1 b/PSCMake/Common/CMake.ps1 index 3f3c5f9..f45faa4 100644 --- a/PSCMake/Common/CMake.ps1 +++ b/PSCMake/Common/CMake.ps1 @@ -448,7 +448,12 @@ function Get-CMakeBuildCodeModel { param( [string] $BinaryDirectory ) - Get-ChildItem -Path (Get-CMakeBuildCodeModelDirectory $BinaryDirectory) -File -Filter 'codemodel-v2-*' -ErrorAction SilentlyContinue | + + # Since BinaryDirectory may contain characters that are valid for the file-system, but are used by PowerShell's + # wildcard syntax (i.e. '[' and ']'), escape the characters before passing to Get-ChildItem. + $EscapedBinaryDirectory = $BinaryDirectory.Replace('[', '`[').Replace(']', '`]') + + Get-ChildItem -Path (Get-CMakeBuildCodeModelDirectory $EscapedBinaryDirectory) -File -Filter 'codemodel-v2-*' -ErrorAction SilentlyContinue | Select-Object -First 1 | Get-Content | ConvertFrom-Json