Build fails when multiple Build Agents are building in parallel


When multiple Solutions are being build at the same time and therefore the Build Agents are running in parallel there is an issue when getting files from Source Control. The problem is when trying to download a file a workspace is created, the name of the workspace that is being created is static ('NuGetterTemp') and here tfs-build will throw the exception WorkspaceExistsException.

A possible solution could be to make the workspace name that is created unique across all Build-Agents, this could be possibly made by appending the name of the agent to the name of the workspace.

Another solution could be to replace the way of getting the files with DownloadFiles tfs activity instead of using a workspace. DownloadFiles doesn't need any workspace, it just downloads the needed file from source control into a directory of your choice.

I already did the changes mentioned above, I could share the code if you are interested.
 Exception Message: The workspace NuGetterTemp;TFS BuildRI already exists on computer TFS-BUILD1. (type WorkspaceExistsException)
Exception Stack Trace:    at Microsoft.TeamFoundation.Client.Channels.TfsHttpClientBase.HandleReply(TfsClientOperation operation, TfsMessage message, Object[]& outputs)
   at Microsoft.TeamFoundation.VersionControl.Client.Repository.CreateWorkspace(Workspace workspace)
   at Microsoft.TeamFoundation.VersionControl.Client.Client.CreateWorkspace(CreateWorkspaceParameters cwp)


marknic wrote Jul 3, 2013 at 4:22 AM

Same issue as TfsVersioning. Modified GetFile to absorb the exception and use the existing file.