我正在尝试在 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/