Team Foundation Server Error: tf commands in build scripts fail with "Unable to determine the workspace"

I have a build using a Team Foundation Server VCS root.  
In the build scripts (Nant), I have an external call to the tf history command to retrieve change history information.

The first time I ran the build, the tf.exe history command worked ok, but on every build after that it failed with the error "Unable to determine the workspace".

The only way I have found to fix it is to run the command tf workspaces /s:http://tfs-server:8080 to update the mappings cache file, as explained on this blog post: .
After this fix tf history will work, but it fails on the next build unless I run tf workspaces again.

My checkout settings are:

VCS checkout mode: Automatically on agent
Checkout directory: c:\TeamCityBuild\
Clean all files before build: Off

Has anyone has seen this behavior?

Comment actions Permalink

There is an issue in how TC builds and maintains the versioncontrol.config file.
See here for details.

The first thing I do in my nant scripts is to run the following target:

  <target name="find.workspaces">
    <exec program="${tf}" workingdir="${dir.base}">
      <arg value="Workspaces" />
      <arg value="/Server:[tfsserver]" />

This will clear up the issue.

Comment actions Permalink

An so I did

Thank you for pointing out the existing issue; I'll keep an eye for the fix.


Please sign in to leave a comment.