Yesterday, my team had a developer forum session to assist one our own get our latest release to build on our build server from a new branch. He had been working on it for a couple days and was getting nowhere. He would follow our documented process to create the new build and when he got to the end of it the build threw the following error:
The path C:\Build\ProductReleases\FullBuildv5.4.2x\Sources is already mapped to workspace BuildServer_23.
We used the Team Explorer IDE and attempted to identify this rogue workspace. Try as we might we couldn't locate it. We tried deleting all the source code on the file system. We tried nuking all the workspaces we could see through the IDE.
In the end we had seven developers in a room shouting out ideas to a frustrated developer sitting the keyboard. So we broke for lunch.
After lunch, I returned to my desk to troll the MSDN Team Foundation Server Developer Center. Using the tf workspaces command, you can get a list of all the workspaces you have created:
C:\>tf workspaces
Server: BuildServer
Workspace Owner Computer Comment
--------- -------------- -------- --------
BOBBY work\Bobby BOBBY
But if you add the owner switch, you can get a list of all the workspaces on the server:
C:\>tf workspaces /owner:*
Server: BuildServer
Workspace Owner Computer Comment
----------- ---------- --------- -------------------------------
BuildServer Shane BuildServer
BuildServer Craig BuildServer
BuildServer TFSSETUP BuildServer
BuildServer Keith BuildServer
BuildServer_1 TFSSERVICE BuildServer Workspace created by Team Build
BuildServer_10 TFSSERVICE BuildServer Workspace created by Team Build
BuildServer_12 TFSSERVICE BuildServer Workspace created by Team Build
BuildServer_13 TFSSERVICE BuildServer Workspace created by Team Build
BuildServer_14 TFSSERVICE BuildServer Workspace created by Team Build
BuildServer_16 TFSSERVICE BuildServer Workspace created by Team Build
BuildServer_2 TFSSERVICE BuildServer Workspace created by Team Build
BuildServer_23 TFSSERVICE BuildServer Workspace created by Team Build
BuildServer_28 TFSSERVICE BuildServer Workspace created by Team Build
BuildServer_3 TFSSERVICE BuildServer Workspace created by Team Build
BuildServer_30 TFSSERVICE BuildServer Workspace created by Team Build
BuildServer_31 TFSSERVICE BuildServer Workspace created by Team Build
BuildServer_32 TFSSERVICE BuildServer Workspace created by Team Build
BuildServer_4 TFSSERVICE BuildServer Workspace created by Team Build
BuildServer_6 TFSSERVICE BuildServer Workspace created by Team Build
BuildServer_7 TFSSERVICE BuildServer Workspace created by Team Build
BuildServer_8 TFSSERVICE BuildServer Workspace created by Team Build
BuildServer_9 TFSSERVICE BuildServer Workspace created by Team Build
From this output we can see that our build service user TFSSERVICE has a lot of workspaces defined. Considering we have 3 builds so far. Something is very wrong here.
Our original error message referenced a workspace named BuildServer_23 which does show up in our list. Using the tf workspace command, we can completely remove the workspace:
C:\>tf workspace /delete /server:BuildServer BuildServer_23;TFSSERVICE
A deleted workspace cannot be recovered.
Workspace 'BuildServer_23;TFSSERVICE' on server 'BuildServer' has 0 pending change(s).
Are you sure you want to delete the workspace? (Yes/No) Y
Our build now runs as expected. It's now time to verify what all those other workspaces are and remove them if they are not needed.
Hope this helps someone out there if you are desparately googling for away around this error.