Question

There is one file I want to get from TFS. In the same situation in Mercurial I would just do hg cat.

Is there an equivalent to hg cat in TFS?

I was trying the following command line:

tf get $/dev/components/log.zip

But it fails with:

No appropriate mapping exists for $/dev/components/log.zip.

How do I do this?

Was it helpful?

Solution

TFS needs a workspace to have a mapping between the server repository and your local machine. If you already defined a workspace that includes $/dev/components/log.zip, then switch to that folder in the command line tool.

If you want to get the file to the folder where you are at the moment, you need to create a new workspace. This can be done in Team Explorer or by using tf.exe:

tf workspace /new logZipWs /collection:http://tfsserver:8080/tfs/DefaultCollection

Now you have a workspace, but you need to map the server path to the local folder:

tf workfold /map $/dev/components . /collection:http://tfsserver:8080/tfs/DefaultCollection /workspace:logZipWs

Now your command should work. But the creation of workspaces is much easier using the Team Explorer.

When you're done, make sure you remove the workspace, so it's unregistered from the TFS server (TFS tracks workspaces both on the server and on the client):

tf workspace /delete logZipWs /collection:http://tfsserver:8080/tfs/DefaultCollection

OTHER TIPS

You can download a file without setting up a workspace by using the view sub-command.

tf view $/dev/components/log.zip /output:log.zip

Unfortunately, although the command supports the /recursive option, recursive retrieval isn't really practical. If you try to use it, all of the files will actually be opened using the default program for the given file type, rather than simply saved into a directory. But for getting one specific file, it works fine.

You might also want to check out Neno Loje's TfsExport tool which can download individual files or whole path structures from TFVC to disk.

When you do take the route of creating a (temporary) workspace, make sure you remove it once you're done, otherwise you'll be registering a lot of workspaces with your TFS server, these will just linger int he database and take up space and increase the time required for upgrades.

tf workspace /delete logZipWs /collection:http://tfsserver:8080/tfs/DefaultCollection
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top