command-linetfstfs-sdkvisual-studio-macros

How to get specific version of folder from tfs without creating a workspace?


I would like to get the source code of a project at specific time (changeset). So I need do download whole folder. I would like to do it for different times and handling a different workspace is not very convenient.

I know about TFS Get Specific Version into separate folder (with workspace) and Need command to get a file from TFS without a workspace (one file).

Is there some solution for whole folder without creating a new workspace?

Edit I have found the accepted answer too ambitious. I needed something more simple.

Assumptions:

I run the following batch from a destination folder in Visual Studio Command Prompt

set workspace_name=TemporaryWorkspace%username%
set changeset= ChangeSetNumber                
tf workspace -new %workspace_name% -noprompt
tf workfold -map $/tProj . -workspace:%workspace_name%
tf get $/tProj/DesiredFolder -version:C%changeset% -recursive -noprompt
tf workfold -unmap . -workspace:%workspace_name%
tf workspace -delete %workspace_name% -noprompt

It is necessary to confirm remove source control association when starting the downloaded solution.

Edit 2023 I wanted to use the script but I was getting the following error:

Unable to determine the workspace.

I managed to find a solution in SO:Unable to determine the workspace using TF.exe. And from it I have a corrected script:

set workspace_name=TemporaryWorkspace%username%
set changeset=ChangeSetNumber
tf workspace -new %workspace_name% -noprompt /collection:<team-project-collection-url>
tf workfold -map $/ . -workspace:%workspace_name%
tf get $/tProj/DesiredFolder -version:C%changeset% -recursive -noprompt
tf workfold -unmap . -workspace:%workspace_name%
tf workspace -delete %workspace_name% -noprompt

Where <team-project-collection-url> is the URL of the project collection that contains the workspace that you want to create, for example, https://myserver:8080/tfs/DefaultCollection.

Probably something has changed during past five or six versions of Visual Studio


Solution

  • I use this syntax for temporary workspaces:

    tf workspace -new %JOB_NAME%;%user% -noprompt -server:http://%host%:8080/tfs/%project% -login:%user%,%password%
    tf workfold -map $/Release/MilestoneX.X . -workspace:%JOB_NAME% -server:http://%host%:8080/tfs/%project% -login:%user%,%password%
    tf get . -version:L%TFS_LABEL% -recursive -noprompt -login:%user%,%password%
    tf workfold -unmap . -workspace:%JOB_NAME% -login:%user%,%password%
    tf workspace -delete %JOB_NAME%;%user% -noprompt -server:http://%host%:8080/tfs/%project% -login:%user%,%password%