KarmaEDV
KarmaEDV

Reputation: 1691

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

When I open my Visual Studio and get a solution from our TFS I have following message in the Output Window:

TF401190: The local workspace [MACHINE_NAME;USER_NAME] has 158412 items in it, which exceeds the recommended limit of 100000 items. To improve performance, either reduce the number of items in the workspace, or convert the workspace to a server workspace.

This is not an error, but a warning and I can work OK, although I feel there is a real performance hit during my work.

To resolve this I would like on one hand to "cloak" single branches/folders that I don't use. On the other hand I don't want to cloak to much and in general I want to know if there are some folders that have unnecessary many files in them.

Question: Is there a TFS Console/PowerShell Command, or something to retrieve a count of the items in the TFS Local Workspace that can be executed from my Visual Studio client machine? Something like the Treesize-App does, but for TFS?

I googled a little bit, but didn't find anything really helpful. I found this on MSDN that confirms the reason why I am getting the message, but it doesn't provide any solution. Here is a guy that tried to do something as well, but the project never made it to codeplex afaik.

Our Team uses VS2013 Update 5 / TFS 2013 Update 5

Your help is appreciated.

Upvotes: 9

Views: 4590

Answers (1)

eldor
eldor

Reputation: 161

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

Upvotes: 7

Related Questions