I have a CMake project that generates a Visual Studio solution that builds with MSBuild.
The command I am using to build the project is:
cmake --build Debug -- -v:diag
using the --
option causes the -v:diag
option to be passed to MSBuild.
When run from a command prompt, everything is fine.
However, when run from within a powershell prompt, it breaks:
PS C:\proj> cmake --build Debug --verbose -- -v:diag
Microsoft (R) Build Engine version 16.11.2+f32259642 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
MSBUILD : error MSB1016: Specify the verbosity level.
Switch: -v:
For switch syntax, type "MSBuild -help"
Seems powershell is doing something to parse the arguments around the colon :
.
How can I cause powershell to pass the argument string as-is to cmake?
Unfortunately, you've hit a bug in PowerShell's parameter binder, present up to at least PowerShell 7.2.4:
-v:diag
is unexpectedly passed as two arguments, -v:
and diag
, if preceded by --
in calls to external programs - see GitHub issue #17399.
As a workaround, quote the argument:
cmake --build Debug --verbose -- '-v:diag'