Home > TFS, TFS2010, TFS2012 > TFS2012: How to delete a workspace using the tf command

TFS2012: How to delete a workspace using the tf command

Today while I am writing another blog post, I encountered the following error

Exception Message: The working folder C:\Builds\5\MyTeamProject\UnitTestProject1\src is already in use by the workspace 6_5_TFS2012Build1;TFS2012BUILD1$ on computer TFS2012BUILD1. The Build Agent TFS2012Build1 – Agent1 is running as a different user Administrator and local paths can only be mapped to a single workspace. To resolve this issue, you can configure the Build Service to run as the user who owns the conflicting workspace, or you can delete the workspace using the ‘tf workspace’ command. (type WorkingFolderInUseException)

I received that error because, I changed the run as service account for the Build Controller. From a machine that has Visual Studio installed, open the VS command prompt.

Then, the first thing you want to do is check what switches TF workspace has by running the following command

tf workspace /?

To learn more about the switches or arguments, check this msdn article http://msdn.microsoft.com/en-us/library/y901w7se(v=vs.100).aspx

You can also use the tf workspaces to target multiple workspaces or to list all workspaces for a collection

tf workspaces /collection:http://tfs2012express:8080/tfs/defaultcollection Collection:http://tfs2012express:8080/tfs/defaultcollection

The above will return you the workspaces on the current machine. If you want to view all workspaces, you need to use the /computer switch

tf workspaces /collection:http://tfs2012express:8080/tfs/defaultcollection Collection:http://tfs2012express:8080/tfs/defaultcollection /computer:*


In my case, I am using the following switches

tf workspace /delete /collection:<a href="http://tfs2012express:8080/tfs/defaultcollection 6_5_tfs2012build1;tfs2012build1$


Type Yes and press enter

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: