Tag Archives: TFS Power Tools

Massive search/replace for files checked in to TFS

Several times there is the need to apply changes to many files checked in to TFS. A simple example is a change made to a configuration file within several projects. This can be achieved by opening each project, and applying a simple check out => search/replace => check in. It works, but it is very inefficient. And your time is best spent doing other, more important stuff.
If you are like me and don’t like doing repetitive tasks, there is a quicker procedure for this type of changes.

Requirements:

  1. Install TFS Power Tools, available here.
  2. Make sure the setup option “Windows Shell Extensions” is selected

Procedure:

  1. Open Windows Explorer in the folder where the changes will be applied.
  2. Get latest sources if necessary (right-click, select Team Foundation Server | Get Latest Version).
  3. Search the folder using a criteria that includes the files to update (*.cs, *Manager*.vb, etc.).
  4. Select the files to change from the results list.
  5. Check Out (right click, select Team Foundation Server | Check Out for Edit…).
  6. Open all files in your favorite text editor (VS, Context, Notepad++, etc.).
  7. Search/replace in all files according to a criteria – text or regular expression.
  8. Verify the changes.
  9. Check In (right-click, select Team Foundation Server | Check In…). Fill the check in comment.

These changes must be done with care, but without fear. If the changes must be rolled back, its easy to find the Change Set in TFS by user, date or check in comment.