-->

TFS Check-in Policy - Force a shell command to hav

2019-07-29 10:01发布

问题:

On the project that I'm currently working I have a requirement to run a shell command over some static files prior to check-in into TFS.

Is it possible to use TFS checkin policies to force a developer to run a shell script prior to check-in?

回答1:

Check-in Policies are designed for this purpose: to check for something in order to "authorize" the check-in.

You'll find an interesting video here about how to develop one. You'll see that it's really easy and once you did your first you will want to customize more TFS.

In you case you will have two options (IMHO):

  1. Run the shell command in the Evaluate method of the check-in policy.
  2. Make the check if the user manually ran the shell command in the Evaluate method.

The first should be the best but it bothers me a bit because it's not the true purpose of the check-in policies to perform a task upfront, but I can't think about why it shouldn't work. And maybe you'll have to go that way it the second solution is not possible.



回答2:

In the end we didn't need to use a Checkin policy.

Instead we turned the resolution on its head as I found that running tf.exe checkin from a command prompt, without any further arguments, causes the TFS checkin dialog to popup.

This means that we can add an additional step at the end of our shell script that runs:

C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\tf.exe checkin