How to improve the performance of the first connect to TFS
When you create your first connection to TFS the local client downloads the metadata required to work with the TFS work items. By default it downloads the metadata for all team projects in a collection, including the ones that you don’t have access to. Martin Woodward has a great blog post if you want to read more on the background info, however the way you enable it has been changed in TFS 2010.
In TFS 2010 we have introduced Team Project Collections, which introduced the need to be able to set this value per collection. So we moved the setting to the TFS registry in TFS 2010 and TFS 2012 instead of in the web.config. This post contains the script for updating this registry value. If you want more information on the TFS registry, see this blog post.
- Open notepad
- Add then the following lines of code to create the PowerShell script to add the update the settings
- The first choice is to load of the correct version of the Client assembly
#TFS 2010 (10.0.0.0)
[Reflection.Assembly]::Load("Microsoft.TeamFoundation.Client, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
#TFS 2012 (18.104.22.168)
[Reflection.Assembly]::Load("Microsoft.TeamFoundation.Client, Version=22.214.171.124, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
- The second choice is whether you want to have the behavior on all the project collections (use the configuration hive), or only a specific collection (use the collection hive). Also make sure that you update the url of your TFS server and the name of the collection in case you use the collection hive.
$configServer = new-object Microsoft.TeamFoundation.Client.TfsConfigurationServer "http://localhost:8080/tfs/"
$hive = $configServer.GetService([Microsoft.TeamFoundation.Framework.Client.ITeamFoundationRegistry])
$projectCollection = new-object Microsoft.TeamFoundation.Client.TfsTeamProjectCollection "http://localhost:8080/tfs/DefaultCollection"
$hive = $projectCollection.GetService([Microsoft.TeamFoundation.Framework.Client.ITeamFoundationRegistry])
- Then add the following lines to enabling the filtering of the metadata cache
# Enable metadata filtering
- Save the script as FilterMetadata.ps1
- Open the Command Prompt and run the following command (make sure you update the path of the file)
powershell -ExecutionPolicy unrestricted -Command "& ‘FilterMetadata.ps1‘"
You can also download a copy of the script that uses
- The TFS 2012 Client OM
- The localhost
- The configuration hive