visual-studio-2017 - 无法找到类型 [Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]

标签 visual-studio-2017 tfsbuild gac

我正在尝试在 TFS 上构建一个构建,该构建通过使用同事之前编写并工作过的 PowerShell 脚本在不同的 TFS 集合中启动另一个构建。然而,这个脚本是在 VS 2015 Professional 上编写和测试的,我使用的是 2017 Enterprise。当我在构建中运行此脚本时,出现以下错误:

Unable to find type [Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]

当它击中这个时:

$tfs = [Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]::GetServer($serverName)

我查看了 C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer 中的 .dll,但找不到这个dll(也许特定于Professional 2015?)

我该如何解决这个问题?根据我的研究,我似乎需要将 dll 添加到 GAC,但不确定要添加哪个 dll。如果此 dll 与 Enterprise 2017 没有关联,我将如何更改此行以适用于我的版本?

最佳答案

对象模型客户端库不在 GAC 中。

添加要通过 Add-Type cmdlet 加载的 dll,如下所示:(在您的场景中,您需要添加 Microsoft.TeamFoundation.Client.dll)

$visualStudiopath = 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer'
    Add-Type -Path "$visualStudiopath\Microsoft.TeamFoundation.VersionControl.Client.dll"
    Add-Type -Path "$visualStudiopath\Microsoft.TeamFoundation.Common.dll"
    Add-Type -Path "$visualStudiopath\Microsoft.TeamFoundation.WorkItemTracking.Client.dll"
    Add-Type -Path "$visualStudiopath\Microsoft.TeamFoundation.Client.dll"
    Add-type -path "$visualStudiopath\Microsoft.TeamFoundation.ProjectManagement.dll"
    Add-Type -Path "$visualStudiopath\Microsoft.TeamFoundation.Build.Common.dll"

关于visual-studio-2017 - 无法找到类型 [Microsoft.TeamFoundation.Client.TeamFoundationServerFactory],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51674032/

相关文章:

visual-studio - VS2017 中缺少 .Net Core 2.1 模板

xamarin.android - 错误 : No resource found that matches the given name (at 'icon' with value '@mipmap/Icon' )

visual-studio - 在Bin中包括GAC程序集

reference - 将我的 DLL 部署到 GAC,引用 GAC 中没有的其他 DLL

c# - 从 GAC 列出所有实现特定接口(interface)的 DLL

c++ - Visual Studio 2017 中是否有自动保存功能来处理其错误和崩溃?

javascript - 如何在网站启动时在 Visual Studio 中启动新的 Chrome 实例而不进行 Javascript 调试?

tfsbuild - tfs构建服务器-字符串插值$字符无效

tfsbuild - 仅使用 VS2013 在 TFS 构建服务器上构建 VS2013

c# - 如何从 C# 客户端发送补丁请求?