TFS in a lab environment - Beware caching issues
As a consultant specializing in Visual Studio Team System, I spend a significant amount of my time customizing and extending Visual Studio and Team Foundation Server. Just as most people develop applications in a development environment before deploying to a production environment, I do my TFS development in a lab environment and only push to a client's server after the work is mostly complete. I work with many difference clients and tend to need different lab environments for each.
Which brings us to one of my favorite technologies for this purpose but also one to watch out for... Microsoft Virtual PC. Regardless of which virtualization technology you prefer, creating a virtual machine to act as your lab TFS makes perfect sense. In my case, I have several variations of the same TFS virtual image that I run depending upon which client or project I'm supporting. As long as I only have one copy booted at a time, everything works great, except for...
Visual Studio and Team Explorer provide a caching mechanism which can get out of sync. If I have multiple instances of a single TFS which can be connected to from a single Visual Studio client, that client can become confused. Symptoms vary, but I've had what appears to be connectivity or security issues but were actually related to trying to use cached data from one TFS instance against a different instance. Some of the problems were more esoteric but equally confusing, including phantoms in work item definitions or TFVS.
Although there are probably other ways to help, the simplest way that I've found is to delete the cache for the TFS on the client machine. The cache is kept in two subdirectories, named based on a server GUID, under:
C:\Documents and Settings\{your account}\Local Settings\Application Data\Microsoft\Team Foundation\1.0\Cache
Although I connect to many different TFS servers, I know the GUID for my favorite lab TFS server. Whenever I need to switch between VPC instances of that server, I clear the cache by shutting down Visual Studio, deleteing directories {Server GUID} and {Server GUID}_http from the aforementioned directory, and then restarting Visual Studio.
In many cases things looked like they were working fine without clearing the cache, but not that I know how this caching mechanism works, I always clear it when I move between different instances of the same TFS - just in case.