Author Posts

March 9, 2016 at 4:58 am

I'm calling this from a BAT file:

powershell -nologo -file ./Run-Metrics.ps1 1 1 "RWSConsoleOnly" "batch" 
"RWSConsoleOnly" 3 
"c:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\FXCop\FXCopCmd.exe" 
"c:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\Rule Sets\" 
"c:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\FxCop\Metrics.exe" 

And I get this error:

Run-Metrics.ps1 : A 
positional parameter cannot be found that accepts argument 'Studio'.
    + CategoryInfo          : InvalidArgument: (:) [Run-Metrics.ps1], ParentCo 
    + FullyQualifiedErrorId : PositionalParameterNotFound,Run-Metrics.ps1

This was working a couple of days ago. I've made changes internally to the script but not to the BAT file or the script parameters. The parameters are:

    # AHP Iteration

    # buildAnalysisCount

    # buildAnalysisNames

    # buildAnalysisTypes

    # buildAnalysisAsmbs

    # FXCop Level

    # FXCopCmdPath

    # FXCop Ruleset Path

    # Visual Studio Version

    # Metrics Command Path

    # Working Path

Any ideas why I'm getting this error? I've tried more quotes around the strings with spaces in the path and that didn't work. Is there a "best practice" for passing complex strings to a single PS parameters from a BAT file?

March 9, 2016 at 5:06 am

It's a syntax error in your batch file. In the command prompt, you can escape a quotation mark with a backslash, and you've got a trailing backslash at the end of one of your paths:

Rule Sets\"

It should be fine to simply remove that backslash and end the string with Rule Sets". If you really do need that trailing backslash, you can double it up: "Rule Sets\\".

It's just one of those weird quirks of the old command shell.

March 9, 2016 at 5:15 am

That was It! Thanks!