4

Chocolatey上安装windirstatilmerge时出现以下错误。我怀疑 PowerShell 3.0 中的 & 符号行为发生了变化。

Running powershell -NoProfile -ExecutionPolicy unrestricted -Command "& import-module -name  'C:\NuGet\chocolateyInstall\helpers\chocolateyInstaller.psm1'; & 'C:\NuGet\lib\ilmerge.2.10.526.4\tools\chocolateyInstall.ps1'". This may take awhile and permissions may need to be elevated, depending on the package.
ilmerge did not finish successfully. Boo to the chocolatey gods!
-----------------------
[ERROR] The expression after '&' in a pipeline element produced an invalid object. It must result in a command name, script block or Command
Info object.
-----------------------
4

2 回答 2

4

问题不是我必须替换$oc = Get-Command 'Write-Host' | ?{$_.ModuleName -eq 'Microsoft.PowerShell.Utility'}的&符号行为$oc = Get-Command 'Write-Host' -Module 'Microsoft.PowerShell.Utility'以及对 Write-Error 包装器进行类似替换。

于 2011-11-17T18:50:48.047 回答
2

使用 -version 1.0 或 2.0 参数启动 PowerShell 怎么样?然后运行上面的命令,看看有没有什么不同。

在命令行

PowerShell -版本 2.0

于 2011-11-15T16:50:41.313 回答