2010-01-14 46 views
14

我们有一个powershell构建脚本,可以调用其他脚本,在Windows 7 64位下给我带来麻烦。它在XP下正常工作。我已经运行set-executionpolicy RemoteSigned(并尝试与旁路和无限制)。我可以从错误消息中拉出命令行并自己运行它,并且它运行正常。msbuild在Windows 7下调用powershell脚本获取签名错误

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


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. 
+0

要最大限度地使用MSBuild脚本任务,可能需要获取证书以签署它们,这将避免需要在每个构建系统上启用未签名的脚本。 – Richard

回答

23

只是猜测:你没有在你的 PowerShell中运行Set-ExecutionPolicy和构建运行 PowerShell的?

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

+0

就是这样!非常感谢! –

+0

很高兴我可以帮助...几次遇到x64/x86问题 – Filburt

0

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

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

+0

我已经将Set-ExecutionPolicy设置为RemoteSigned。我也尝试了无限制和绕道,但没有运气。 –

+0

是的,我的不好,编辑答案。记录我不知道发生了什么:) –

+0

其实,你真的很接近。查看Filburt的答案。 –