Search code examples
command-linetfsmappingworkspace

TFS Command Line: How to unmap entire workspace?


Here is my problem. I have a build script which adds mappings to a certain workspace dynamically, then unmaps them when it is through. I am worried that if (when) my script fails before the unmapping is done, the mappings will holdover until the next time and screw things up.

So I would like to unmap the entire workspace at the start of the script, and recreate it, but the problem is I don't know specifically what might be there. Through the TFS command line I can unmap easily enough, but you have to know exactly what the mapping is. My question is how is the easiest, best way to get this done?

Thanks for your help!


Solution

  • If you're sure there won't be any pending changes in the workspace you need to preserve, it's probably easier to delete it entirely and create a new one.

    Or if you do want to stick with your algorithm, the Power Tools make it much easier:

    $ws = get-tfsworkspace .
    $ws.Folders | % { $ws.DeleteMapping($_) }