25

I have this script (bat file)

tf workspaces /s:http://project02:8080

tf workspace /s:http://project02:8080 Team.descomp;MyDomain\Myuser


tf workfold /workspace:Team.descomp


tf get $/Team/Main/Projects /recursive /force /noprompt

I get this error: Unable to determine the workspace., when I try execute tf get.

Console output is similar like:

Server: project02

Workspace: DESCOMP

Owner : MyUser

Computer : DESCOMP

Workspace: Team.descomp

Owner : MyUser

Computer : DESCOMP

...

Workspace: Team.descomp (MyUser)

Server : http://project02:8080/

$/Team: C:\Temp\Team2

...

Unable to determine the workspace.

Note, for $/Team (team project) has map in two machines: MyUser and Descomp

Workspace: Team Owner : MyUser Computer : MyUser

Workspace: Team.descomp Owner : MyUser Computer : DESCOMP

Any suggestions?

skaffman
  • 398,947
  • 96
  • 818
  • 769
Kiquenet
  • 14,494
  • 35
  • 148
  • 243

3 Answers3

45

From Forums MSDN: Mr. Hofman

http://social.msdn.microsoft.com/Forums/en/tfsbuild/thread/82b13bfd-5fd7-45f7-a681-d84c9ea52765

Change the working folder for the tf get to a folder that is mapped by the workspace.

Execute the command from a folder where the workspace is mapped

(for example if you do it from console:

cd c:\sources\myteamproject

tf get ...

)


Key: Change the working folder for the tf get to a folder that is mapped by the workspace.

I use command pushd C:\Temp\Team2 in my script file.

Update: Comments by Ryan Cromwell

You can create and map a workspace in your script with the following. The second command works, because the first workspace is created in the 'blah' folder. The '.' in the second command is saying map '$/' to the current directory (blah). You could change that to be a named folder or subfolder if you choose.

Create a new workspace
C:\projects\blah>tf workspace /new blah /noprompt /collection:http://<host>:<port>/tfs/<collection> /login:<username>,<pwd>

Map a path in that workspace
C:\projects\blah>tf workfold /map $/ . /login:<username>,<pwd>

Kiquenet
  • 14,494
  • 35
  • 148
  • 243
7

This extends @Kiquenet answer. It wasn't easily done in the comments :(

You can create and map a workspace in your script with the following. The second command works, because the first workspace is created in the 'blah' folder. The '.' in the second command is saying map '$/' to the current directory (blah). You could change that to be a named folder or subfolder if you choose.

Create a new workspace
C:\projects\blah>tf workspace /new blah /noprompt /collection:http://<host>:<port>/tfs/<collection> /login:<username>,<pwd>

Map a path in that workspace
C:\projects\blah>tf workfold /map $/ . /login:<username>,<pwd>

Grhm
  • 6,726
  • 4
  • 40
  • 64
Ryan Cromwell
  • 2,613
  • 1
  • 17
  • 33
  • 1
    If you're creating these for temporary folders, it's good practice to delete them (via `tf workspace /delete`) when you're done (as well as the temporary folder). – BrainSlugs83 Aug 12 '14 at 03:57
2

I had this problem in team city executing a ps1 file with the following:

tf resolve FND.sql /auto:KeepYours

tf checkout FND.sql /noprompt

tf checkin FND.sql /noprompt

when I executed it in a PS window, it worked fine, but when executed by Team City, I got the following response for each tf call:

Unable to determine the workspace. ...

Trying to obtain more information about what was going on, I inserted the following statement before the 1st tf call:

tf workfold

when I ran Team City the next time, the tf workfold showed the mapping that was not previously recognized, and the existing tf commands started working.

It still worked when I took out the tf workflold command.

I don't understand it, but maybe this will work for other people with this problem.

I had previously tried several recommendations from this and other websites without success.

Hope this helps someone.

janderson
  • 21
  • 2
  • Somehow `tf workfold` is able to recognize workspaces that `tf workspace` can’t. Basically, you would map a folder with `tf workfold`. tf.exe may hang at this point. Just kill it and then run `tf workspace` and it should work now. You might have to try 2 or 3 times. – Dennis T --Reinstate Monica-- Jan 23 '19 at 20:32
  • Example command `tf workfold /workspace:"wkspaceEg" /collection:http://tfs.example.com:8080/tfs/collectionEg /login:TFSUsername,TFSPassword /map $/teamProjEg D:\Legacy.00\TFS\Source\Workspaces\teamProjEg`. You cannot specify the workspace owner’s username in this command. It will only try with `TFSUsername` as owner. – Dennis T --Reinstate Monica-- Jan 24 '19 at 20:25