Mr. Boy
Mr. Boy

Reputation: 63748

TFS get <file> removes pre-existing local copies of <file>

I'm porting a legacy VSS-based build script to TFS. The script gets files from several server locations into different directories... to make this work with the same structure in TFS I frequently map & unmap specific working folders.

This seemed to work, until the script gets the same server file into two different local folders. Even though previous working folders are un-mapped, TFS moves the existing copy of the file rather than getting a second copy.

e.g:

  1. cd dir1
  2. tf workfold /map $/SOME_PATH .
  3. tf get file.abc /all
  4. tf workfold /unmap .
  5. cd..\ dir2
  6. tf workfold /map $/SOME_PATH .
  7. tf get file.abc /all
  8. tf workfold /unmap .

On line 7, I get "Replacing file.abc (moved from c:\dir1)" and end up with only one copy of file.abc.

I'm aware our process is not TFS-friendly but right now I just want it working so we can drop VSS, and then focus on re-structuring afterwards. Is there a way to stop this behaviour or a workaround I could use that doesn't totally change our process?

Upvotes: 0

Views: 206

Answers (3)

Jan David Narkiewicz
Jan David Narkiewicz

Reputation: 314

I had the same problem and found no answer online so I figured out the solution and wrote up a blog post: http://www.softwarepronto.com/2013/09/getting-multiple-labels-from-tfs-using.html.

If you don't want to read the blog, the solution is to create the workspaces in different directories (see below):

MKDIR D:\ATest

CD /D D:\ATest

tf workspace /delete WorkSpaceATest /noprompt

tf workspace /new WorkSpaceATest /noprompt

tf workfold /map $/ATest D:\ATest /WorkSpace:WorkSpaceATest

tf get /version:LATest01

MKDIR D:\BTest

CD /D D:\BTest

tf workspace /delete WorkSpaceBTest /noprompt

tf workspace /new WorkSpaceBTest /noprompt 

tf workfold /map $/BTest D:\BTest /WorkSpace:WorkSpaceBTest

tf get /version:LBTest01

Upvotes: 0

Isaiah4110
Isaiah4110

Reputation: 10090

What I would do to get this working fast:

  1. Cd Dir1
  2. tf workfold /map $/SOME_PATH
  3. tf get file.abc /all
  4. Copy file.abc to temp location
  5. tf workfold /unmap
  6. cd..\ dir2
  7. tf workfold /map $/SOME_PATH
  8. tf get file.abc /all
  9. Copy file from temp location to dir1
  10. tf workfold /unmap

Upvotes: 1

Jason Williams
Jason Williams

Reputation: 57902

I don't think you can achieve this in TFS. if you remove a workspace mapping it'll remove the files. If you try to map the same file to 2 places you'll get an error.

You need to fix your build process. A short term solution might be to get the file once and then copy it to any other locationsit is needed. otherwise I think you need to bite the bullet and refactor your build process to be simpler. regardless of what systems you are using, simplifying you're build will help you in the long term.

Upvotes: 0

Related Questions