Search code examples
msbuildwindows-server-2012-r2

TFS build server duplicate workspaces


Exception Message: Unable to create the workspace '9_20_NAME' due to a mapping conflict. You may need to manually delete an old workspace. You can get a list of workspaces on a computer with the command 'tf workspaces /computer:%COMPUTERNAME%'. 
Details: The path D:\Builds\NAME is already mapped in workspace 9_22_NAME. (type MappingConflictException)
Exception Stack Trace:    at Microsoft.TeamFoundation.Build.Workflow.Activities.TfCreateWorkspace.Execute(CodeActivityContext context)
at System.Activities.CodeActivity`1.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

So the above has been plaguing me for just over a week now and on the surface it seems like a simple issue, delete or rename the workspaces and move on. However this issue won't shift that easily.

In short I have tried the following:

  • Cleared Workspaces
  • Created new build definitions
  • Moved the build folder location (e.g. D:\builds\name to D:\builds\name-2)
  • Build machine restart
  • Uninstalled / Reinstalled TFS (2013 update 3)
  • Rebuild the build machine and restored the TFS database

I've pretty much narrowed down the issue to something within TFS itself, but for all the good will I cannot find out what.

It's worth noting that when I delete the workspaces (using TFS sidekicks) the builds will run upto a handful of times. I've not narrowed down exactly what causes change from success to failure, however I can delete all the workspaces then run the builds a couple of times without issue and then suddenly this will come back (around 2-3 builds before constant recurring failure).


Solution

  • My solution was to edit my build definitions > Source Settings > Build Agent Folder and change this from a hard coded value to $(SourceDir).

    A team member pointed me to this answer but I'm none the wiser as to why this setting would cause this behavior.