50

In using tfpt from the command, I'm getting the error:

PS D:\Main Line> tfpt uu /noget
Unable to determine the workspace.

Here I'm trying to use the Undo Unchanged command, but I've seen this error with other commands too. The path I'm at is the exact path that is mapped in my TFS workspace. I also tried this which doesn't work either

PS D:\Main Line> tfpt uu /recursive /noget 'D:\Main Line'
Unable to determine the workspace.

I thought it was just using the current path to figure it out, but I can't get it to work right. Does anyone know how this works?

TheSean
  • 4,516
  • 7
  • 40
  • 50

5 Answers5

63

I ran into this same issue, I found the answer at the bottom of the page in one of the help files that came with The power tools. (TFPTCommandLineTool.mht)

Errors

TFPT Error: Unable to determine the workspace

When running tfpt using a command that works with Version Control, you may receive one of the errors:

Unable to determine the workspace 
Unable to determine the source control server

Solutions:

  • Run tfpt.exe from within a directory that is already mapped to Team Foundation source control.
  • Update your local workspace cache using the tf workspaces command. The tf.exe tool is available in the subfolder Common7\IDE of your Visual Studio installation folder. If you launch a Visual Studio command prompt, you can then run the following command (which depends on your versions of TFS/VisualStudio - you should use the version that matches version of TFPT you are using, e.g. if you have TFPT for VS2015, use TF from a VS2015 command prompt):
    • VS 2008-2013 / TFS 2008:
      • tf workspaces /s:serverURL
    • VS 2010-2013 / TFS 2010 (and probably later versions as well):
      • tf workspaces /collection:collectionURL
    • VS 2008 / TFS 2010 (and probably later versions as well):
      • tf workspaces /s:collectionURL
  • If you have recently installed Visual Studio 2012, you might have to connect it to the same TFS server/collection you were using in Visual Studio 2010.
DaveShaw
  • 52,123
  • 16
  • 112
  • 141
BFoust
  • 683
  • 7
  • 9
  • 7
    didn't believe this at first (running from mapped directory) - but it's true! – Simon_Weaver Mar 25 '11 at 01:44
  • strange... when opening Command prompt via the [VSCOMMANDS](http://vscommands.com/features/#OpenCommandPrompt) tool built into the solution explorer i cannot invoke tfpt.exe . For some reason it does not pick up the environment variables. Opening via run->cmd this works like a charm being in the right directory! – felickz Aug 26 '11 at 20:14
  • 3
    My confusion with this issue was that I was thinking of the top level directory of my workspace as being _in_ the workspace which it turned out not to be. All the workspace definitions were mapping directories below the root. e.g., with $/Collection/foo/bar mapped to c:\workspace\foo\bar, tf.exe won't recognize the workspace in c:\workspace or c:\workspace\foo, only in c:\workspace\foo\bar – Jeff Youngstrom Dec 06 '11 at 03:16
  • Updating the workspace cache was the trick for me as I had just renamed my workspace using Visual Studio. – Holistic Developer Oct 12 '12 at 17:06
  • 1
    +1 for the Visual Studio 2012 bit. I didn't have to map the Workspace in 2012, I but I did have to connect to the same Server/Collection I was using in 2010. Just, wow. – BrainSlugs83 Dec 23 '13 at 21:06
  • @Felickz are you running Visual Studio as an admin? Remember you have environment variables for your account and for the whole computer. If you run cmd as an admin you'll get admin's variables+computer's, but if you run as you, you'll get your variables+computer's. (You can check to see if PATH is configured per account instead of per computer, mayhaps?) – BrainSlugs83 Mar 29 '14 at 04:30
  • Make sure to run the command as listed including the collection, that forces the refresh – TJB Apr 17 '14 at 16:54
  • I followed all the advice above, which was essential ... the two final pieces that kept me from performing the tfpt task was that 1) I had to be in one of the folders of the Workspace and not just the "root" of the workspace; the operation still did all the folders of the shelveset, and 2) the Shelveset was unshelved in my source working folder, I had to clean it out by performing an Undo (or a Save to Shelveset with the same name so as to overwrite the original and then unchecking the Preserve shelveset to get the working folders clean), either way it then worked. – SnapJag Dec 03 '15 at 14:58
  • It's worked. Fix was down to having TFS connection set up (and cache refreshed) in the appropriate version of VS. I use symbolic links all over and have TFS workspace mapped to such folders and posts elsewhere suggested it was down to the usage of sym link. But, turns out not to be the case. I was using TFPT version 2015 from 2019 Dev Cmd Prmpt, where TFS connection was set up as necessary. But VS 2015 didn't have TFS connection set up. When that was fixed (tf vc workspaces /collection:), TFPT started working fine in VS 2019 as well. – Social Developer Jul 29 '20 at 13:33
19

When using tf workspaces /s:serverURL make sure you use the right tf.exe!
I had the same problem and was stuck because I used the tf.exe from:

\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE

and not the one from:

\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE

Nitzan
  • 1,669
  • 3
  • 19
  • 33
  • Thank you! I was without tfpt shell extensions for a couple of months since I moved my mapped folders to a different location. tried everything to get it going and finally this worked. Though I don't know why it's using tf.exe in my 11.0 folder when I only have VS 12.0 installed. – Samih Dec 05 '14 at 15:10
  • The realization that you could possibly be using the wrong tf.exe solved my problem. The company I work in requires that we keep 4 different versions of visual studio installed in our machines to build different products that we maintain so this matters a lot. – vullnetyy Oct 26 '17 at 11:58
4

For Visual Studio 2017 users

I had the same problem when trying to run the tfpt command line on a fresh machine installation with VS215 and VS2017 installed. The latest version for the tfpt tool at the time of writing is from TFS Power Tools 2015. That means the local workspace mapping has to be loaded in VS2015 first before the tfpt tool can find the workspace.

Since my team is using VS2017, I only did the workspace mapping in this Visual Studio version. When I opened the VS2017 developer command prompt to use this tool, I got the 'Unable to determine the workspace' message.

To solve this I opened VS2015 and connect the Team Explorer to the TFS server. It immediately recognizes the workspace mapping that was made under VS2017. After this the tfpt tool works correctly under VS2015 and VS2017 developer command prompts.

pogosama
  • 1,818
  • 1
  • 24
  • 29
1

I tried all of this and still i got the same error. The error is generic enough to represent multiple issues, i guess..

re-installing TFPT from

https://visualstudiogallery.msdn.microsoft.com/f017b10c-02b4-4d6d-9845-58a06545627f

fixed the issue for me.

Ravi Sankar Raju
  • 2,850
  • 3
  • 18
  • 16
0

Actually, although I believe that in some cases these workarounds may fix things, they do not work in all cases. And I strongly suspect that ultimately this points to what could be considered a bug somewhere in the PowerTools code. The reason I say this is that the tf workspace command has no problem detecting the workspace on my machine from the VS Command console, but from that very same console with all of the same path info, TFPT cannot detect it on my lap top no matter what I try. I just got this laptop and installed VS 2010, 2012 and 2013, along with the respective Power Tools installs, and pointed to a suite of projects that currently spans several TFS 2010 and TFS 2012 instances. Because of this many-to-many relationship, I suspect there is an incorrect assembly reference somewhere, some combination of factors, GAC, Path, Environment Variables, VS Installations, TFS repositories. In each VS version I attempted to run the TFPT 2010 executable from the VS 2010 Command, and so on with the remaining versions, and tried the above workspace cache updates in all their forms... nothing. But using the same project I connected from an old server with VS 2010 and TFPT 2010 installed and ran the same command perfectly. So I think it has to do with what is running on your system, and in the future I will be much more skeptical about running the different versions side-by-side.

paulyphonic
  • 854
  • 1
  • 6
  • 15