Search code examples
opencoverpsake

Exec command failing on some PCs in psake script to OpenCover


I have been testing running a coverage check of my unit tests using OpenCover and have created a powershell script to create the coverage report using psake.

    Exec { opencover.console.exe -target:"nunit3-console.exe" -targetargs:"Slu.Taxen.Data.Kol.Test.dll" -register:user -output:"..\Coverage\DataTestResults.xml" -filter:"+[*]* -[Slu.Taxen.Data.Kol.Test*]*" }

This has worked without problem on a couple of computers (both running windows 10) but when I tried it today on a windows 8.1 machine I get the error message:

Incorrect Arguments: The argument '-[Slu.Taxen.Data.Kol.Test*]*' is not recognised

and then:

Error: 14/03/2016 16:49:08:
At F:\Code\Greenbase2\KolAPI\psake.psm1:147 char:17 +                 throw ("Exec: " + $errorMessage) +
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [<<==>>] Exception: Exec: Error executing command  opencover.console.exe -target:"nu
nit3-console.exe" -targetargs:"Slu.Taxen.Data.Kol.Test.dll" -register:user 
-output:"..\Coverage\DataTestResults.xml" -f
ilter:"+[*]* -[Slu.Taxen.Data.Kol.Test*]*" .

But if I run the command directly in console on my windows 8.1 machine it works fine. Which suggests to me that it's not opencover which is causing the fuss but Psake or powershell.

Any clues?


Solution

  • We found that with powershell that putting the quotes around the whole argument works better when passing any argument that contains spaces when in powershell - see usage wiki e.g. Instead of

    -filter:"<filters with spaces>"
    

    Do

    "-filter:<filters with spaces>"