Archive for March, 2011

TFS Getting Real Slow – Is it TFS? The VM? The Proxy? or IE?

March 30, 2011 Leave a comment

Skip ahead for the remedy for bad TFS performance or read on to share in the tale of my woe.

Spoiler: It was Internet Explorer in the Dining Room with a Candlestick

I’ve spent the past 2 days giving my web operations support personnel hell.  I’ve been trying to resolve a performance issue on a test environment webserver.  As a fallback deployment method we have installed Team Explorer and Team Foundation Power Tools on the test server.  Previously the team this is for used Subversion and had a similar configuration.  The local workspace is mapped to the deployment target directories under inetpub\wwwroot.  So, to update TEST, the team can just execute a Get operation on a site.  Not fancy, but effective for their purposes.

The problem cropped up when trying to initially Get some of these sites.  The performance was beyond poor.  It was abyssmal, ridiculous, ludicrous even!  A different kind of “ludicrous speed”.  I couldn’t pull a 10 MB website down – after 10 minutes it had only retrieved about 644KB.  “Yikes!”  Yikes, indeed.

We’d been using Team Explorer and TFS for the past year in this company and I’d never seen any issues like this.  It was understandable then, for me to assume it was a system issue, especially after hearing some rumors of misconfigured VMs.

So fast forward 2 days and 2 re-created VMs later, nothing has helped and I’m ready to bash my head in one of the drawers of those big cubicle file cabinets.  I get the big idea that maybe this is a network issue and not a VM disk issue.  So I try to copy those same 10MB website files over the network from my laptop to the server.  Takes all of 20 or 30 seconds.  Not stellar speeds, but totally acceptable!  Remarkably adequate even!  OK, so what the hell is going on? Why can’t this particular system talk to TFS?

Initially I blamed TFS.  Don’t get me wrong. I love me some TFS.  But in this case, TFS really pissed me off, or so I thought. Within the config file for Visual Studio / or the Visual Studio Shell with Team Explorer which on this x64 Windows Server was found here:

C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe.config

I added the following additional setting:

<defaultProxy enabled=”false” />
<ipv6 enabled=”true”/>

A miracle happened.  Suddenly I could not only pull down a 10 MB site in a few seconds, but I could pull down all 24 websites in several minutes.  What the freaking hell?  Why was this necessary on this server and none of the others?  That is a mystery I aim to solve tomorrow.  For today, I’m just happy as crap that I can use this server again.

Oh, one more thing. If you use the TF.exe command line you’ll want to make that change to the TF.exe.config file as well.

C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\TF.exe.config

The TF.exe.config file does not have a System.Net element at all.  I just pasted in the entire element as shown above and hoped for the best. It worked.

In truth my beloved TFS was not to blame!

I’ve had a little time to research the real cause of the problem and found that the distinguishing characteristic on the problem server was found in the LAN Settings.  “Automatically detect settings” was checked only on the problem server.  I unchecked that box and removed the <defaultProxy enabled=”false” /> element and all was well.

I followed up with our VMWARE admin and was informed that, although the policies were defined with this flag turned off, Internet Explorer still defaults to “Automatically detect settings”.  Not sure if this is the whole story or not.  In any case, if you’re having similar performance issues with TFS, check your proxy settings.  Try the config fix.  If it works, it’s probably your proxy settings.

Categories: TFS

Bulk Rename Operation in TFS using Powershell

March 25, 2011 Leave a comment

If the structure of your TFS source control requires an overhaul this may help.

Lift With Your LegsFirst if you haven’t already, install the TFS Power Tools. Make sure you find the most recent release.

Here is a link to the most recent version to date:

During installation be sure to install the TFS Cmdlets for Powershell.

If you’ve never used Powershell before fire up a PS Console from the shortcut found under TFS Power Tools in your program menu.

Then set the execution policy by typing the following:

Set-ExecutionPolicy RemoteSigned

OK. Now you’re ready to do some damage. 

SERIOUSLY careful with this!

You don’t want to mess up your repository any more than it already is.
The following snippet is just an example of something you could do, but is not meant to be used as is.  You will need to modify it to suit your requirements.

In my situation I had created about 25+ separate directories for different website projects, each with their own set of branches, Dev, Main, etc.  It looked something like this:


and so on.  I realized I would have to create an additional directory under “Dev” which was the root of the branch to contain each website.   It would have to be modified to look more like this:


So, first I tried to use the Source Control Explorer “Move” command through the GUI.  That didn’t work too well. SCE didn’t seem to want me to move all the files at once in a drag and drop operation and I didn’t want to have to painstakingly drag each directory individually.

Powershell to the rescue…

The Powershell CmdLets for TFS installed with the Power Tools include one item called:


This allows you to recursively enumerate source controlled items.

Try this — Don’t worry it’s safe:

Get-TfsChildItem $/YourProject/*  -Recurse

So, from there we can get the server paths of everything in source control. Combine them with some Where-Object, Select-Object and foreach in Powershell along with the TFS command line utility, TF.exe and we have the makings of a solution.

$sites = “WebSite1”, “WebSite2”, “WebSite3”

foreach($item in $sites){

tf get $/MyProject/$item/Dev/

write-host “Renaming directories”

Get-TfsChildItem $/MyProject/$item/Dev/* -Folder | Where-Object { -not $_.ServerItem.Contains(“/WebSite”)  }| Select-Object ServerItem | foreach { tf rename $_.ServerItem $_.ServerItem.Replace(“/Dev/”,”/Dev/WebSite/” ) }

Write-Host “About to checkin”

tf checkin $/MyProject/$item/Dev/ /recursive /noprompt

Write-Host “Renaming root items”

Get-TfsChildItem $/MyProject/$item/Dev/*.*  -Recurse | Where-Object { -not $_.ServerItem.Contains(“/WebSite”)  }| Select-Object ServerItem | foreach { tf rename $_.ServerItem $_.ServerItem.Replace(“/Dev/”,”/Dev/WebSite” ) }

Write-Host “About to checkin”

tf checkin $/MyProject/$item/Dev/ /recursive /noprompt

Categories: Uncategorized