"My Work" is a TFS feature that makes it easy to switch between multiple different streams of work. We recently turned the feature on in our team project and I've been playing around with it to see whether its benefits justify its requirement for Visual Studio Premium or Ultimate.
I'm always working on multiple work items simultaneously, as each progresses through UAT at different speeds. Previously, I kept all changes for all in-progress work items checked out on my machine. This meant that when a work item was ready for deployment I had to pick through every file to identify those relevant to that work item before checking them in. This was a slow, tedious process, and I'd often miss a file and the build would break as a result.
"My Work" makes it easy to maintain a shelveset for each work item (or group of work items) and switch between them as necessary, effectively keeping each set of changes neatly partitioned without the hassle of having a separate branch for each.
With "My Work", if I need to interrupt something I'm doing to tackle a high priority bug fix, or I want to start work on a second work item while I'm waiting for another to be tested, I can click a single button to suspend my existing changes:
This creates a shelveset of everything in "Included Changes" in the Pending Changes window of Team Explorer, then does an undo checkout on those changes. The undo gave me a fright the first time it happened, as I wasn't expecting it, but it ensures that your workspace only contains changes that you are currently working on (although you can have other checked out files in "Excluded Changes"). The shelveset is visible in "Find Shelvesets" just like any other.
Later, once I've finished the bug fix, or the first item has been signed off and now needs to be checked in, I can resume my previously suspended work:
This gets the changes in the associated shelveset into my workspace, then deletes the shelveset. It also remembers which files and editor windows you had open in Visual Studio when you suspended the work, and restores them too.
The only wrinkle I've hit so far is that I often need to create a single shelveset containing all changes for all in-progress work items, for deployment to UAT. With "My Work" you can only work on one set of changes at once. You can merge different sets of changes, but you cannot subsequently unmerge them. However, I have found a workaround for this:
- Suspend all in progress work (so nothing is checked out and every set of work has a shelveset)
- Go to "Find Shelvesets" and click "Unshelve" on each set of changes in turn that need to be part of the aggregated build. This gets all changes locally, but preserves the shelvesets in "Suspended Work". If two shelvesets affect the same file, the changes can be merged.
- Shelve the changes manually under a new shelveset name
- Kick off the UAT build based on that shelveset
- Manually revert to a clean workspace by undoing all pending changes and removing all Related Work Items. This step makes me slightly nervous, but as long as you don't have any In Progress work it's safe. Also, worst case, all changes will be in the shelveset you created in step 3 anyway.
It means producing a UAT build is a little more work than before, but the advantage of being able to keep each set of work separate more than offsets it.
It's a shame that My Work isn't available in the Professional version of Visual Studio. It may not be as useful for developers who typically only work on one or two things at the same time, but for me it has rapidly become an essential tool, saving me a lot of time and reducing check-in mistakes.