在Windows 7下调用powershell脚本的msbuild会出现签名错误

时间:2010-01-14 18:58:30

标签: powershell msbuild windows-7

我们有一个powershell构建脚本,可以调用在Windows 7 64位下给我带来麻烦的其他脚本。它在XP下工作正常。我已经将set-executionpolicy运行到RemoteSigned(并且还尝试使用Bypass和Unrestricted)。我可以从错误消息中拉出命令行并自己运行它,一切运行正常。

构建错误在这里看起来很糟糕;但是为了完整,我还是把它们包括在内。


Project "C:\dev7\Source\DashPortal\DashboardGenerator\DashboardGenerator.csproj" (2) is building "C:\dev7\Source\DashPo
rtal\DashboardController\DashboardController.csproj" (15) on node 0 (default targets).
  File C:\Users\pmckinney.NA\Documents\WindowsPowerShell\profile.ps1 cannot be lo
  aded because the execution of scripts is disabled on this system. Please see "g
  et-help about_signing" for more details.
  At line:1 char:2
  + . <<<<  'C:\Users\pmckinney.NA\Documents\WindowsPowerShell\profile.ps1'
      + CategoryInfo          : NotSpecified: (:) [], PSSecurityException
      + FullyQualifiedErrorId : RuntimeException

  File C:\dev7\Source\DashPortal\DashboardController\..\..\..\Build\createReportI
  nstallScript.ps1 cannot be loaded because the execution of scripts is disabled
  on this system. Please see "get-help about_signing" for more details.
  At line:1 char:87
  + C:\dev7\Source\DashPortal\DashboardController\..\..\..\Build\createReportInst
  allScript <<<<  -t C:\dev7\Source\DashPortal\DashboardController\..\..\..\Sourc
  e\DashPortal\DashboardReports\ReportSetupScriptTemplate.sql -l C:\dev7\Source\D
  ashPortal\DashboardController\..\..\..\Source\DashPortal\DashboardReports\Repor
  tSetupReportList.xml -c C:\dev7\Source\DashPortal\DashboardController\..\..\..\
  Source\DashPortal\Config
      + CategoryInfo          : NotSpecified: (:) [], PSSecurityException
      + FullyQualifiedErrorId : RuntimeException

C:\dev7\Source\DashPortal\DashboardController\DashboardController.csproj(265,5): error MSB3073: The command "powershell
 C:\dev7\Source\DashPortal\DashboardController\..\..\..\Build\createReportInstallScript -t C:\dev7\Source\DashPortal\Da
shboardController\..\..\..\Source\DashPortal\DashboardReports\ReportSetupScriptTemplate.sql -l C:\dev7\Source\DashPorta
l\DashboardController\..\..\..\Source\DashPortal\DashboardReports\ReportSetupReportList.xml -c C:\dev7\Source\DashPorta
l\DashboardController\..\..\..\Source\DashPortal\Config" exited with code 1.

2 个答案:

答案 0 :(得分:23)

猜测:您确实在 x64 PowerShell中运行Set-ExecutionPolicy,构建运行 x86 PowerShell?

也许在两个shell中尝试Get-ExcutionPolicy。

答案 1 :(得分:0)

编辑:oops,我看到你已经启用了脚本。这可能与MSBuild运行的上下文有关。您是否将MSBuild作为某种本地服务帐户运行?

Edit2:很明显错误信息具有欺骗性。还有其他事情正在发生并且正在抛出执行策略错误,但不是出于预期的原因。也许作为一种隔离的方法,尝试创建另一个MSBuild任务,该任务运行相同的行,但使用较短的硬编码路径而不是上面的/../../../富矿?