2016-02-05 57 views
0

我有PowerShell腳本,它增加了管理單元。無法添加PowerShell管理單元,從MSBuild項目執行時

if ((get-pssnapin | select-string "Microsoft.TeamFoundation.PowerShell") -eq $null) { 
    Add-PSSnapin Microsoft.TeamFoundation.PowerShell 
} 

利用PowerShell命令行中調用

然而,當,當我調用它從build.proj(MSBuild項目)它的工作原理:

<Exec Command="powershell -executionpolicy Unrestricted -Command &quot;&amp; { . \&quot;$(SourceDir)myscript.ps1\&quot;; }&quot;" 
     LogStandardErrorAsError="true" ContinueOnError="false"/> 

它說:

此計算機上未安裝Windows PowerShell管理單元「Microsoft.TeamFoundation.PowerShell」。

build.proj(82,5): error : Add-PSSnapin : The Windows PowerShell snap-in 'Microsoft.TeamFoundation.PowerSh 
build.proj(82,5): error : ell' is not installed on this computer. 
+0

這可能是MSBuild運行在32位/ 64位,並且管理單元僅安裝在兩者中的一個上。我會嘗試加載x86和x64 PowerShell控制檯中的管理單元進行檢查。 – makhdumi

+0

當你說它從命令行起作用時,你的意思是本地還是構建代理?什麼版本的TFS? – chief7

+0

@ chief7:我在本地PC上運行它。 VS2015連接到TFS2013。在tfs服務器上,我有另一個問題:'Get-ChildItem:找不到與參數名'Depth'匹配的參數。:) – Liero

回答

相關問題