How do I delete a workspace using tf.exe that starts with a dash/hyphen?

973 views Asked by At

I have a specific command that I use to delete a Team Foundation Server workspace:

tf workspace /delete "packages sacred";domain\user /server:http://domain:8080/tfs

We've recently had someone leave who prefixed about half of his workspaces with a dash/hyphen, so running my usual command line

tf workspace /delete "-name";domain\user /server:http://domain:8080/tfs

returns the error Unrecognized command option 'name;domain\user'.

If I try using "^-name" I get TF14061: The workspace ^-name;FirstName LastName does not exist.

tf workspace /delete ^-name;domain\user /server:http://domain:8080/tfs

returns the error Unrecognized command option 'name;domain\user'. as well.

Double hyphen and single quotes doesn't work either.

Ideally I'd like to know how to delete a workspace that starts with a hyphen using the tf command line tool, so unless it's impossible, I'm not looking for a link to another tool to use. Is there a way to escape the name correctly?

1

There are 1 answers

0
jessehouwing On

This seems to be a bug in the tf client and I do not see (while browsing the decompiled code of tf.exe) any attempt to escape a / or - at the start of any argument. If you have access to the workspace itself, on the client machine, you can use tf workspace /newname:ANewName to change it, but any 'free' argument that starts with a - will cause issues.

You'll probably need a tool like the Team Foundation Sidekicks (workspace sidekick should do) or script the deletion of the workspace through the TFS Client Object Model and Powershell.