【问题标题】:How to get the latest labeled code and label name in TFS2013 using powershell如何使用powershell在TFS2013中获取最新的标签代码和标签名称
【发布时间】:2017-12-06 14:13:15
【问题描述】:

我正在尝试使用 PowerShell 获取 TFS 2013 中特定解决方案/项目的最新标记代码。如果有人知道如何获取最新标签,请在此处发布。

【问题讨论】:

    标签: powershell tfs


    【解决方案1】:

    您可以使用以下脚本获取特定项目的最新标签:

    #Add Reference Assemblies to be loaded accordingly based on your VS client.
    
    add-type -Path 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Microsoft.TeamFoundation.VersionControl.Client.dll'
    add-type -Path 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Microsoft.TeamFoundation.Client.dll'
    
    $CollectionUrl = 'http://servername:8080/tfs/DefaultCollection'
    $tfs = [Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection($CollectionUrl)
    $vcs = $tfs.GetService([Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer])
    $labels = $vcs.QueryLabels('*','$/ProjectName',$null,$true)
    $latestlabel = $labels | Select-Object -first 1
    
    write-host "The Latest Lable Name:" $latestlabel.Name
    write-host "The Latest Lable ID  :" $latestlabel.LabelID
    

    【讨论】:

    • 嗨@Andy-MSFT:: 我之前也尝试过提到的命令,但它给了我空白值。请检查并帮助我了解我是否在这里遗漏任何内容(我只提到了我修改的行)- $CollectionUrl = 'servername:8080/tfs' $tfs = [Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection($CollectionUrl) $vcs = $tfs.GetService([Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer]) $labels = $vcs.QueryLabels('*','$/project path/project.sln',$null,$true) $最新标签 = $标签 | Select-Object -first 1
    • @PratikBompilwar 请将 '$/ProjectName' 更改为真实的项目名称,而不是 '$/project path/project.sln',例如:如果项目名称是“Test”,只需将其设置为 $/Test
    • 谢谢,@Andy-MSFT。这样可行。您是否知道我是否可以对标签名称使用任何过滤器。假设我想搜索一些以“test***.***.*”开头的标签。我们可以使用任何包含(测试)的东西吗?
    猜你喜欢
    • 1970-01-01
    • 2014-07-12
    • 1970-01-01
    • 2011-11-18
    • 2010-11-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多