3

Is it possible to just say to TFS that I have a file (call it Version.txt) and I want it to be checked in at a location (say $/MyProject/MyVersionLocation) and not have any workspace setup for that location?

Something like (pretend Syntax):

tf.exe c:\Version.txt CheckIn $/MyProject/MyVersionLocation /WorkSpaceOverride

If so, how do you do it?

Vaccano
  • 78,325
  • 149
  • 468
  • 850

1 Answers1

4

It is not possible to checkin a file without a workspace mapping for that path.

One option would be to use a combination of "tf workspace" and "tf workfold" to dynamically create a workspace before checking in.

For example:

tf workspace /collection:http://server:8080/tfs/Collection /new TempWorkspace /noprompt
tf workfold /collection:<server> /workspace:TempWorkspace /map $/MyProject/MyVersionLocation/Version.txt C:\Version.txt
granth
  • 8,919
  • 1
  • 43
  • 60
  • 1
    Notice the mapping of a file here directly to the place in the working folder mapping. That's the clever bit that Grant is doing here. Note that the folders above do not have to exist yet in version control either - they will get created when you check in the file by doing a "tf add Version.txt" and "tf checkin Version.txt" – Martin Woodward Nov 12 '10 at 22:20
  • @Martin Woodward, @Grant Holliday - This is good stuff. The only problem with this, is that the `tf workspace /new` command tries to add a mapping to the current working directory. So if that is already set to another workspace, then it will fail to create. I could change working directories, but I would rather not (I am going to be doing this in my build template). Is there a way to create a workspace without adding the current directory to the workspace? – Vaccano Nov 12 '10 at 22:30
  • @Vaccano - I believe the answer is no. You have to change to a new directory to avoid that conflict (we do this by creating uniquely named folders for each workspace). – Allan Bowe Sep 02 '16 at 10:37