2013-08-21 99 views
1

我在執行powershell腳本的msbuild配置文件中有一個構建後步驟。如果我直接從Powershell調用它,但通過msbuild失敗,powershell腳本完美工作。 Import-Module WebAdministration無法通過msbuild獲取powershell腳本導入模塊

我得到的錯誤「錯誤:檢索COM類工廠CLSID {688EEEE5-6A7E-422F-B2E1-6AF00DC944A6組件

看來它,它會嘗試使用類從導入失敗之後}失敗,由於以下錯誤:80040154類未註冊(異常從HRESULT:0x80040154(REGDB_E_CLASSNOTREG))「

我試過改變的版本從msbit從64位加載到32位的PowerShell,但它沒有區別。

這裏是的MSBuild步:

<Target Name="DevPostBuild"> 
<PropertyGroup> 
    <PowerShellExe Condition=" '$(PowerShellExe)'=='' ">%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe</PowerShellExe> 
    <ScriptLocation Condition=" '$(ScriptLocation)'=='' ">$(ProjectDir)DevPostBuild.ps1</ScriptLocation> 
</PropertyGroup> 
<Message Text="$(ScriptLocation)" /> 
<Exec Condition="Exists($(ScriptLocation))" Command="$(PowerShellExe) -NonInteractive -executionpolicy Unrestricted -command &quot;&amp; { &amp;'$(ScriptLocation)' } &quot;" /> 

我使用的是64位機器上VS2010。

謝謝!

+0

你見過這個:http://www.techblogistech.com/2012/05/errors-with-powershell-webadministration-module/#more-857? – JohnL

回答

0

Visual Studio 2010是一個32位的進程。 Powershell將作爲一個32位進程運行。 Web管理模塊只有64位。嘗試使用%SystemRoot%\syswow64\WindowsPowerShell\v1.0\powershell.exe代替PowerShellExe

+0

嗨厄里斯。我試過使用兩種可執行文件,而且似乎無論如何都以32位模式運行。但是,如果您啓動與獨立進程相同的可執行文件,它將作爲64位進程加載。有沒有辦法解決?? – smithy

+0

可能http://stackoverflow.com/questions/6514416/wow64-running-powershell-from-within-visual-studio會工作嗎? – Eris

相關問題