TFS Build:此计算机上未安装`Microsoft.TeamFoundation.PowerShell'

时间:2016-02-09 13:11:14

标签: powershell tfs tfsbuild build-automation tfs-power-tools

当我使用本地帐户登录到tfs构建服务器并执行以下powershell命令时:

Add-PSSnapin Microsoft.TeamFoundation.PowerShell

正确加载tfs cmdlet。但是,当我在调用脚本的tfs服务器上触发构建时,它会失败并显示消息:

  

此计算机上未安装“Microsoft.TeamFoundation.PowerShell”。

构建代理在服务帐户下运行。我该怎么办?

修改: 我必须在@Alexis Coles回答的第一个链接中编辑reqistry条目,以使其适用于TFS PowerTools的2015版本:

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\PowerShellSnapIns\Microsoft.TeamFoundation.PowerShell]
"PowerShellVersion"="4.0"
"Vendor"="Microsoft Corporation"
"Description"="This is a PowerShell snap-in that includes the Team Foundation Server cmdlets."
"VendorIndirect"="Microsoft.TeamFoundation.PowerShell,Microsoft"
"DescriptionIndirect"="Microsoft.TeamFoundation.PowerShell,This is a PowerShell snap-in that includes the Team Foundation Server cmdlets."
"Version"="14.0.0.0"
"ApplicationBase"="C:\\Program Files (x86)\\Microsoft Team Foundation Server 2015 Power Tools"
"AssemblyName"="Microsoft.TeamFoundation.PowerTools.PowerShell, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
"ModuleName"="C:\\Program Files (x86)\\Microsoft Team Foundation Server 2015 Power Tools\\Microsoft.TeamFoundation.PowerTools.PowerShell.dll"
"CustomPSSnapInType"="Microsoft.TeamFoundation.PowerTools.PowerShell.TFPSSnapIn"

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\PowerShell\1\PowerShellSnapIns\Microsoft.TeamFoundation.PowerShell]
"PowerShellVersion"="4.0"
"Vendor"="Microsoft Corporation"
"Description"="This is a PowerShell snap-in that includes the Team Foundation Server cmdlets."
"VendorIndirect"="Microsoft.TeamFoundation.PowerShell,Microsoft"
"DescriptionIndirect"="Microsoft.TeamFoundation.PowerShell,This is a PowerShell snap-in that includes the Team Foundation Server cmdlets."
"Version"="14.0.0.0"
"ApplicationBase"="C:\\Program Files (x86)\\Microsoft Team Foundation Server 2015 Power Tools"
"AssemblyName"="Microsoft.TeamFoundation.PowerTools.PowerShell, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
"ModuleName"="C:\\Program Files (x86)\\Microsoft Team Foundation Server 2015 Power Tools\\Microsoft.TeamFoundation.PowerTools.PowerShell.dll"
"CustomPSSnapInType"="Microsoft.TeamFoundation.PowerTools.PowerShell.TFPSSnapIn"

仔细检查AssemblyNameApplicationBaseModuleNameVersion条目。上面的脚本适用于 Microsoft Team Foundation Server 2015电动工具

3 个答案:

答案 0 :(得分:9)

I had this issue and to solve I notice that by default the cmdlets are not added during the PowerTools installation. You need to run a full install to make it work.

I posted here some pictures: https://fabiostawinski.wordpress.com/2016/07/11/the-windows-powershell-snap-in-microsoft-teamfoundation-powershell-is-not-installed-on-this-computer/

答案 1 :(得分:3)

我将在这里快速发布并说它可能与32位与64位PowerShell有关。如果我从正常的64位PowerShell运行Add-PSSnapinicrosoft.TeamFoundation.PowerShell罚款。但是,如果我从C:\ Windows \ SysWOW64 \ WindowsPowerShell \ v1.0 \ powershell_ise.exe运行它我得到上述异常。我将继续说,构建服务器是一个32位应用程序,并在那里启动32位运行时。

不确定修复的确切内容,但以下内容可能会指出正确的方向。

PowerShell (2.0, 32-bit) can't load TFS 2010 snap-in... except when it can

https://social.msdn.microsoft.com/Forums/en-US/a116799a-0476-4c42-aa3e-45d8ba23739e/tfs-power-tools-2008-powershell-snapin-wont-run-in-on-64bit-in-windows-2008-r2?forum=tfspowertools

答案 2 :(得分:0)

对我来说,这是另一个问题,因为我试图使用仅安装Visual Studio 2017 Pro的Power Tools。

对于Visual Studio 2017,他们没有发布Microsoft Team Foundation Server 2017 Power Tools。他们说以前的版本应该可以与具有TFS的任何更高版本的Visual Studio一起使用。

问题是,如果仅安装了Visual Studio 2017,则将无法安装Microsoft Team Foundation Server 2015 Power Tools,因为要安装Microsoft Team Foundation Server 2015 Power Tools,必须安装Visual Studio 2015(任何版本)

换句话说,我必须先安装Visual Sudio 2015,然后再安装Microsoft Team Foundation Server 2015 Power Tools,然后Add-PSSnapin Microsoft.TeamFoundation.PowerShell才能正常工作。

另请参阅: https://developercommunity.visualstudio.com/content/problem/103642/team-foundation-server-2015-power-tools-install-is.html

希望这会对某人有所帮助。