Client Virtualization and TFS Version Control

It is becoming more and more common for developers and testers to work with virtualized clients like those offered with Virtual PC or Hyper-V.  We use this at Microsoft a great deal.  Client virtualization offers many benefits for those working with pre-release software or who need to quickly change between client configurations.   However, if you are using TFS version control on these virtualized clients you need to be aware of the impact of rolling back \undoing disks.

Rollback\Undo Disks

When you roll back to a snap shot or undo your session changes (with Virtual PC undo disks) the version of the files you have on disk can be different than the version that TFS thinks you have.  Here is a worse case scenario:

    1. User gets version 1 of foo.cs – takes snap shot of VPC/Hyper-V
    2. A month passes.  User gets latest foo.cs which is version 20
    3. User rolls back VPC/Hyper-V to snap shot in step 1.  Server still thinks user has version 20.
    4. User pends a change on foo.cs and checks in.   All changes in foo.cs that occurred between version 1 and 20 are lost since the server thinks user had the latest version (20) and thinks user deleted those changes with the check-in.

Similarly, if you replace step 4 with a normal get latest foo.cs will not be updated since the server thinks you have the latest version 20 already, which you don't.

What to do if you need to roll back \ undo your virtualized client

Use the Force -  To get the server and workspace versions in sync again perform a get using the force option. 

OR

If you are using Hyper-V a better solution is to put your workspace on a drive that is offline to the host OS (Windows 2008) but known to the Hyper-V machine.  You have to disassociate this offline drive from the Hyper-V machine before you do the rollback and re-attach afterwards.  This keeps the rollback from affecting the workspace drive, leaving your workspace files the same. 

Conclusion

You can enjoy the benefits of client virtualization and TFS Version Control by keeping in mind the impact of rolling back \undoing disks have on your TFS workspace.  A simple post roll back step or putting your workspace on an offline hard drive (for Hyper-V users) is all you need to do.

Comments