VS 2005 IDE Caching of Workspaces can cause a Team Build to Fail

When you initiate a Team Build from your local client machine, the VS 2005 IDE and Team Explorer will cache the workspace settings for that build on your machine. If at some later point, you delete that Team Build and create a new one that uses the same folder path for it’s workspace, you may encounter the following error:

Target InitializeWorkspace:
DeleteWorkspaceTask Name=”[YourWorkspaceName]” TeamFoundationServerUrl=”http://yourTFSServer:8080″
Workspace [YourWorkspaceName] does not exist.
CreateWorkspaceTask Name=”[YourWorkspaceName]” TeamFoundationServerUrl=”http://yourTFSServer:8080″ MappingFile=”WorkspaceMapping.xml” LocalPath=”C:Projects” TeamProject=”[yourProject]
C:Program FilesMSBuildMicrosoftVisualStudiov8.0TeamBuildMicrosoft.TeamFoundation.Build.targets(306,5): error : The path C:Projects is already mapped in workspace [YourWorkspaceName].

This is due to this caching on your local machine.

If you have cleared the workspace from the TFS server, but still see this error, run the following command on your client machine and possibly on the Build Server:

tf workspaces /o:* /s:http://yourTFSServer:8080

This will update your local cache with the correct data from the TFS Server. Update the yourTFSServer with your Production TFS server name.

Update (22-Jun-2006): After actually re-reading the tf.exe command line documentation for the workspaces command, I noticed that you could also have used the /remove option. this option clears the cache on the local PC for the given server, so the next time you run, the workspace cache is updated from the server. Much better! Here’s the command line:

tf workspaces /remove:* /server:http://yourTFSServer:8080

More info on the workspaces command can be found on MSDN at http://msdn2.microsoft.com/en-us/library/54dkh0y3(d=ide).aspx