【问题标题】:TFS Build: `Microsoft.TeamFoundation.PowerShell' is not installed on this computerTFS 构建:此计算机上未安装“Microsoft.TeamFoundation.PowerShell”
【发布时间】:2019-04-03 20:35:08
【问题描述】:

当我使用本地帐户登录到 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 Power Tools

【问题讨论】:

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


    【解决方案1】:

    我遇到了这个问题,为了解决这个问题,我注意到默认情况下,在 PowerTools 安装期间不会添加 cmdlet。您需要运行完整安装才能使其正常工作。

    我在这里发布了一些图片: https://fabiostawinski.wordpress.com/2016/07/11/the-windows-powershell-snap-in-microsoft-teamfoundation-powershell-is-not-installed-on-this-computer/

    【讨论】:

      【解决方案2】:

      我将在这里简单地讨论一下,这可能与 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

      【讨论】:

      • 在我的机器上,单击 PS 脚本上的编辑会打开 (x86) 版本的 ISE。从开始菜单中选择它会打开 64 位版本。如果您收到此错误,请注意标题栏以确保您没有使用 (x86)。在今天之前我从未注意到这种行为。
      【解决方案3】:

      对我来说这是另一个问题,因为我试图使用仅安装 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,因为安装了 Visual Studio 2015(任何版本)是安装 Microsoft Team Foundation Server 2015 Power Tools 的要求。

      换句话说,我必须安装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

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2019-10-01
        • 2013-04-09
        • 1970-01-01
        • 2012-04-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多