找不到类型[Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]

时间:2018-08-03 13:42:49

标签: visual-studio-2017 tfsbuild gac

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

kubectl exec -t octavia-api-worker-pod-test -c octavia-api -- bash -c "unset http_proxy https_proxy ; mv /usr/local/etc/octavia/octavia.conf /usr/local/etc/octavia/octavia.conf-orig ; /usr/local/bin/octavia-db-manage --config-file /usr/local/etc/octavia/octavia.conf ; upgrade ; head"

点击时:

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

我已经浏览了$tfs = [Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]::GetServer($serverName) 中的.dll,但是找不到该dll(也许是Professional 2015的?)

我将如何解决这个问题?从我的研究看来,我需要将dll添加到GAC,但不确定要添加哪个dll。如果该dll与Enterprise 2017没有关联,我如何更改此行以使其与我的版本一起使用?

4 个答案:

答案 0 :(得分:1)

答案 1 :(得分:1)

对象模型客户端库不在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"

答案 2 :(得分:0)

查看this脚本是否有帮助。这种方法不需要二进制文件。

您可以根据自己的需求进行自定义。

P.S。它适用于TFS 2017.1

答案 3 :(得分:0)

在同一情况下,只有VS 2015程序集对我有帮助... 添加顺序也很重要!

    try
{

    $visualStudiopath = 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer'

    Add-Type -Path "$visualStudiopath\Microsoft.TeamFoundation.WorkItemTracking.ControlsCore.dll"
    Add-Type -Path "$visualStudiopath\Microsoft.TeamFoundation.WorkItemTracking.Client.QueryLanguage.dll"
    Add-Type -Path "$visualStudiopath\Microsoft.TeamFoundation.ProjectManagement.dll"
    Add-Type -Path "$visualStudiopath\Microsoft.TeamFoundation.WorkItemTracking.WebApi.dll"
    Add-Type -Path "$visualStudiopath\Microsoft.TeamFoundation.WorkItemTracking.Client.dll"
    Add-Type -Path "$visualStudiopath\Microsoft.TeamFoundation.WorkItemTracking.Common.dll"
    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.DataStoreLoader.dll"
    Add-Type -Path "$visualStudiopath\Microsoft.TeamFoundation.WorkItemTracking.Controls.dll"
    Add-Type -Path "$visualStudiopath\Microsoft.TeamFoundation.WorkItemTracking.Proxy.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"
}
catch [System.Reflection.ReflectionTypeLoadException]
{
   Write-Host "Message: $($_.Exception.Message)"
   Write-Host "StackTrace: $($_.Exception.StackTrace)"
   Write-Host "LoaderExceptions: $($_.Exception.LoaderExceptions)"
}