Search code examples
tfstf-cli

Checkin multiple files with tf.exe in one changeset


On one of our builds we are kicking off some automated process which is checking out and checking in some files automatically.

This all works rather well, but at this time we are running the checkin command which looks like the following

tf.exe checkin /force /comment:"foo" /noprompt /bypass /override:"bar"

All of the files with a Pending status will get checked in.

I'd like to make this script a bit more specific and only checkin the files (2 in total) which we actually change during the build, so we know for sure no files will get checked in 'by accident'.

I've already seen we can specify a single filename with the checkin command, but doing so we will get 2 different changesets in TFS, instead of 1. We would really like to have 1 changeset, containing both changed files as the changes belong to eachother.

Any ideas on how to approach this?

Minor addition / Short term solution

For the moment I've solved our 'problem' by specifying the folder where our modified files are located, which kind of looks like this

tf.exe checkin "/my/folder/location/" /recurse /force /comment:"foo" /noprompt /bypass /override:"bar"

Note the folder location and the /recurse parameter added.


Solution

  • You simply separate the files by spaces:

    tf.exe checkin file1.ext file2.ext /force /Comment:"foo" /noprompt /bypass /override:"bar"
    

    The documentation is not clear about this point but it might be a general specification of an itemspec that it can be multiple items.

    See similar question about checkout: Is there a way to check-out multiple files from various folders in TFS in a single operation

    As mentioned by others you might run into problems with the command line being longer than the system supports, in which case you might need to look at other solutions.