We have developed a custom check-in policy plugin that traps the check-in events to TFS 2013 on the client. This is used to evaluate certain workflow statuses and generate a meaningful comment for the check-in. For these tasks the Work item selected / associated by the user for the check-in is inspected for validity, and values from the work item are used to generate the comment. This works perfectly in the Visual Studio realm. Until recently all check-ins to TFS were done via Visual Studio 2013. A new team joined us and they make use of XPA Magic. The standard XPA editor seems to makes use of the 32-bit MSSCCI provider for TFS 2013 to perform check outs and check-ins on TFS. When checking in code via the XPA editor, the following dialog is used to allow the user to select / associate his work item and add comments.
Unfortunately when checking-in via this dialog, the functionality does not work anymore. I have debugged the plugin project and when checking OUT via this route, the Evaluate() function is called and exposes the Microsoft.VisualStudio.TeamFoundation.VersionControl.PendingChanges.PendingChangesModelVS . However when checking IN, the Evaluate() function is NOT called.
Is it conceptually possible to also trap the check-in events and achieve the same (or similar) results as when checking in via Visual Studio?
Client machines have Visual Studio Premium 2013 running on Windows 7 connecting to a TFS 2013.Update3 application server.
-
-
Hey Edward,
I am not entirely sure that I am interpreting your reply correctly, but here goes :- )
The idea is to build an comment containing the details from the associated work item (Like the WI number, description and some other custom information) at check-in time. After checking in the file(s) the comment of the change set created, will then contain some useful information . The comment (strings) is generated on the check-in and then set in the following property: PendingCheckin.PendingChanges.Comment = newCheckinComment;
Full NameSpace: {Microsoft.VisualStudio.TeamFoundation.VersionControl.PendingChanges.PendingChangesModelVS}.PendingCheckin.PendingChanges.Comment
We thus need to push the comment in here during the check-in action. At check-in we also know for sure that there is at least one WI associated from where the data can be distilled, as this is enforced.
In debug I see the following events firing every time when these actions are undertaken:
- On a Refresh within Team Explorer. (PendingCheckin.Policies.EvaluationState = Unevaluated)
On a Checkout via the Context menu " Team Foundation Server" in Windows Explorer. (PendingCheckin.Policies.EvaluationState = Unevaluated)
On a Check-in with Visual Studio (PendingCheckin.Policies.EvaluationState = Evaluated)
Seeing that we are only interested in the check-in action, the code only responds to : PendingCheckin.Policies.EvaluationState = Evaluated
public override PolicyFailure[] Evaluate()
{
PolicyFailure[] failures = null;
if (PendingCheckin.Policies.EvaluationState == PolicyEvaluationState.Evaluated)
{
InitConfiguration();
failures = CheckWorkitemStatus();
if (Util.ArePolicyFailuresOk(failures))
failures = ComposeCheckinComment();
if (Util.ArePolicyFailuresOk(failures)) //The setting of the comment -> PendingCheckin.PendingChanges.Comment = newCheckinComment , happen in this function.
failures = CheckFilesToCheckin();
}
return failures;
}
So as you can see the problem arises that the check-in via the Context menu " Team Foundation Server" in a Windows Explorer, never reaches the Evaluate() function, but the check-out from the same Context menu does … Hope it makes sense!