There are always those problems that you hit and you feel like you are hitting your head against a wall. This was one of those situations.
Running builds in TFS and we were wanting to update the build version and checkin the result.
Issuing two simple commands to checkout and checkin the file were failing with
“Unable to determine the workspace. You may be able to correct this by running 'tf workspaces /collection:TeamProjectCollectionUrl'.”
Now I know that TFS doesn’t work well if the workspaces are screwed and so started looking into the problem.
Firstly we had just upgraded to TFS 2013 and a new TFS server. This has all sorts of problems with workspaces and solution files as the source control settings are cached and also in the solution and project files. Agghhhh where’s git when you want it.
The caching is easily solved by removing the cached files this can be done by removing
Where <version> is the version of TFS you are using TFS 2013 has a version of 5.0.
Note: you won’t be able to remove the folder if VS is running (on a dev machine) or the Team Foundation Server Build Service Host is running (on a build machine)
I tried this and still no luck.
After some bing juice, I came across some comments in http://blogs.msdn.com/b/granth/archive/2008/07/22/tf-exe-unable-to-determine-the-workspace.aspx that alluded to the PATH pointing to the wrong version of TF.exe
I changed my script to point to the explicit TF.exe and hey presto it worked.
On examining the PATH environment variable I saw that indeed it was pointing to the previous version of TFS tools.
“C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE”
Not sure why the install of TFS 2013 didn’t change the path, probably some back compatibility stuff. Suffice to say, what out if you have multiple versions of VS and TFS installed on your build and dev machines.