Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 867
KarmaEDV Avatar asked Aug 17 '15 09:08

KarmaEDV


People also ask

How do I map a local directory in TFS?

From Visual Studio, go to the Team Explorer Connect page (Keyboard: Ctrl + 0, C) and then connect to the project. (If the project you want to open is not listed, choose Select Projects and then connect to the project.) Map the project to a folder on your dev machine. Map the workspace and get your code.

What is a local workspace?

Local Workspace is a folder on client computers that contains copies made by the Meridian client applications of recently accessed vault documents. The folder also contains a database that tracks the files that are contained in the Local Workspace. Local Workspace does not exist on the server computer.

What is local workspace TFS?

Workspace basics A workspace is basically storing the links between folders in the Team Foundation Server repository and the corresponding local folders on your computer's hard disk. It keeps track of the local version and the remote version and the state of those files.


1 Answers

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
like image 162
eldor Avatar answered Oct 05 '22 07:10

eldor