如何使用PowerShell在TFS2013中获取最新的标记代码和标签名称

时间:2017-07-03 10:32:13

标签: powershell tfs tfs2013

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

1 个答案:

答案 0 :(得分: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