Search code examples
powershellnunitdotcover

How to pass multiple arguments to dotCover merge


I am writing powershell command to merge two snapshots as following -

&$coveragTool merge /Source= $TestResult1;$TestResult2 /Output= TestMergeOutput.dcvr

it is giving error as -

Parameter 'Source' has invalid value.
Invalid volume separator char ':' (0x3A) in path at index 67.

where as the document says two files should be separated by a semicolon(;)

like this -

merge: Merge several coverage snapshots
usage: dotCover merge|m <parameters>

Valid parameters:
  --Source=ARG             : (Required) List of snapshots separated with semicolon (;)
  --Output=ARG             : (Required) File name for the merged snapshot
  --TempDir=ARG            : (Optional) Directory for the auxiliary files. Set to system temp by default

Global parameters:
  --LogFile=ARG            : (Optional) Enables logging and allows specifying a log file name
  --UseEnvVarsInPaths=ARG  : (Optional) [True|False] Allows using environment variables (for example, %TEMP%) in paths. True
 by default

how do i make it correct?


Solution

  • You cannot pass an unquoted ; as part of an argument, because PowerShell interprets it as a statement separator.

    Either enclose the argument in "...", or `-escape the ; character selectively; also, the space after = may or may not be a problem.

    To make the call (at least syntactically) succeed, use the following:

    & $coveragTool merge /Source="$TestResult1;$TestResult2" /Output=TestMergeOutput.dcvr
    

    Alternatively (note the `, ignore the broken syntax highlighting):

    & $coveragTool merge /Source=$TestResult1`;$TestResult2 /Output=TestMergeOutput.dcvr
    

    PowerShell has more so-called metacharacters than cmd.exe, for instance, notably ( ) , { } ; @ $ # in addition to & | < > - see this answer for additional information.