1

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?

1 Answer 1

2

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'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.