3

I need a batch script that uses tf to retrieve the directory structure for a label in TFS, something like the equivalent of svn export, while not messing up with my current working workspace.

This is what I managed to come up with:

tf workspace /new TemporaryWorkspace /noprompt

This will create a new workspace, but with the following working folder: $/: C:\ (considering that I ran the command from C:)

This is not what I want, but "tf workspace /new" doesn't seem to allow specifying the mapping, so I ran this to remove the default mapping:

tf workfold /unmap $/ /workspace:TemporaryWorkspace

then this one to create my desired mapping.

tf workfold /workspace:TemporaryWorkspace /map $/Project/Path C:\Temp\Path

Change the current directory to the local working folder (I don't know of another way to select the current workspace)

PUSHD C:\Temp\Path

Now I can finally retrieve the label and do my stuff with it.

tf get /version:LMyBeautifulLabel

Now the clean up.

tf workspace /delete TemporaryWorkspace /noprompt

Go back

POPD

All these seems a bit too cumbersome for my humble purpose. Is there a simpler way?

Thanks.

Paul
  • 1,224
  • 2
  • 14
  • 31

1 Answers1

1

Unfortunately, you will need to create a workspace with the proper working folder mappings and then run the get. There's no one-liner alias to set this up for you.

You may be able to get by with creating a longer-lived workspace with the proper working folder mappings that you need not delete, but certainly if you're using this workflow frequently but with different labels or in different locations, creating a new temporary workspace each time probably does make the most sense.

Your best solution here is to either create a command script that executes this workflow or use the little known script functionality of the tf command line client. You can run a tf script by using:

tf @<filename>

or simply using:

tf @

to read from standard input.

Edward Thomson
  • 74,857
  • 14
  • 158
  • 187