我试图从C:\ Program Files(x86)\ Microsoft Visual Studio 10.0 \ Common7 \ IDE
运行MSTest.exe。此外,我正在将当前目录中的所有程序集作为单独的/ testcontainer参数进行设置。 我无法在没有PowerShell投诉的情况下解决此问题。
$CurrentDirectory = [IO.Directory]::GetCurrentDirectory()
$MSTestCall = '"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe"'
foreach($file in Get-ChildItem $CurrentDirectory)
{
if($file.name -match "\S+test\S?.dll$" )
{
$MSTestArguments += "/TestContainer:" + $file + " "
}
}
$MSTestArguments += " /resultsFile:out.trx"
$MSTestArguments += " /testsettings:C:\someDirectory\local64.testsettings"
Invoke-Expression "$MSTestCall $MSTestArguments"
这段代码给出的错误是:
Invoke-Expression:在“/”运算符右侧必须提供值表达式。
当我尝试在名称中没有空格的目录中调用mstest.exe时,我不会遇到此错误(不需要额外的")。
当我尝试使用&
时,
&$MSTestCall $MSTestArguments
е®ѓе°†$MSTestArgumentsдҢњдёғеҚ•дёҒеЏ‚ж•°дә йЂ’пәЊдҢ†MSTestз«‹еҚіе°†е…¶дёұеәѓгЂ‚жњ‰д»Ђд№€е»ғи®®еђ—пәџ
$MSTestCall = '"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe"'
。一旦你把"foo bar.exe"
放入变量$foo
中,那么它就包含了该字符串及其中的空格。调用& $foo
就像预期的那样工作,即执行由变量$foo
中的字符串命名的命令。 - Keith Hill.dll
,我怀疑您想要的是\ .dll
。整个字符串都要用单引号括起来 -'\S+test\S?\.dll$'
。 - Keith Hill