术语 'Win32' 未被识别为 cmdlet 的名称 - 将管道符号作为参数的一部分传递

The term 'Win32' is not recognized as the name of a cmdlet - pass a pipe symbol as part of an argument

我正在尝试为自动化构建制作脚本。 堆叠在 "release|Win32" 命令上

命令:

PS C:\Users\Builder> powershell.exe "& 'C:\Program Files\Microsoft Visual Studio 11.0\Common7\IDE\devenv.com'" C:\Build\
VS2012Build.2.7X\ClientServer\SHClientServer\SHCApplicationsVS2012.sln /Clean Release|Win32 No Local

错误:

The term 'Win32' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spell
ing of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:193
+ powershell.exe "& 'C:\Program Files\Microsoft Visual Studio 11.0\Common7\IDE\devenv.com'" C:\Build\VS2012Build.2.7X
\ClientServer\SHClientServer\SHCApplicationsVS2012.sln /Clean Release|Win32 <<<<  No Local
    + CategoryInfo          : ObjectNotFound: (Win32:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

由于 | 是 PowerShell 中的元字符(具有句法意义的字符),如果您想将其用作参数的一部分,则必须 引用 它 -单独使用 ` 或更典型地通过(单引号或双引号)引用整个参数:

powershell.exe "& 'C:\Program Files\Microsoft Visual Studio 11.0\Common7\IDE\devenv.com' C:\Build\VS2012Build.2.7X\ClientServer\SHClientServer\SHCApplicationsVS2012.sln /Clean 'Release|Win32' No Local"
  • 请注意 Release|Win32 现在如何用单引号引起来 ('Release|Win32')。
  • 此外,为了稳健,我在 "..." 中包含了 整个 PowerShell 命令。