How to get a Count of the Items in my TFS Local Workspace?

≡放荡痞女 提交于 2019-12-05 03:04:34

You can do this e.g. with TFS API:

var uri = new Uri("https://tfs.mydomain.com/tfs/myteamprojectcollection")
var tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(uri);
var vcs = tpc.GetService<VersionControlServer>();

var itemSet = vcs.GetItems("$/MyServerPath",RecursionType.Full);

Console.WriteLine(itemSet.Items.Length);

You can just put it into a console app, or if you change the syntax, it can be also called as a PowerShell script.

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Client")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.VersionControl.Client")

$url = "https://tfs.mydomain.com/tfs/myteamprojectcollection";
$tfs = [Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection($url)
$vcs = $tfs.GetService([Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer])
$set = $vcs.GetItems("$/MyServerPath", [Microsoft.TeamFoundation.VersionControl.Client.RecursionType]::Full)

Write-Host $set.Items.Length
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!