Search code examples
c#tfscheckin-policy

How to load Checkin Policy in custom TFS-Plugin


I've created a plugin for a program adding TFS-VCS integration to that program using the Microsoft.TeamFoundation.*-Namespaces.

Basicaly that works, but now I have a problem with custom checkin policies:
We have 2 checkin policies activated for the project: The ChangesetCommentPolicy from the TFS Power Tools and a custom policy wich is created by us. Both work in Visual Studio and the Shell Integration, but in my plugin I get the following error:

Internal error in Changeset Comments Policy. Error loading the Changeset Comments Policy policy. Installation instructions: To install this policy, follow the instructions in CheckForComments.cs.

Same for our custom policy, just with the other policy name.

Here a code snippet how I get the policy warnings:

//CurrentWorkspace is Microsoft.TeamFoundation.VersionControl.Client.Workspace
CheckinEvaluationResult result = Manager.CurrentWorkspace.EvaluateCheckin(CheckinEvaluationOptions.Policies,
    PendingChanges.ToArray(), changes.ToArray(), textBoxComment.Text, GetCurrentCheckinNotes(), GetSelectedWorkItems());
if (result.PolicyEvaluationException != null || result.PolicyFailures.Length > 0)
{
    labelPolicyWarning.Text = "The following check-in policies have not been satisfied";
    pictureBoxWarning.Visible = true;

    foreach (PolicyFailure failure in result.PolicyFailures)
    {
        items.Add(failure);
    }
    if (result.PolicyEvaluationException != null)
        items.Add(result.PolicyEvaluationException);

    objectListViewPolicyWarnings.SetObjects(items);
}
else
{
    labelPolicyWarning.Text = "All check-in policies are satisfied";
    pictureBoxWarning.Visible = false;
}

How can I "load" the policies in my plugin so they can be executed?

P.S.: The program the plugin is for is FlashDevelop if that matters.


Solution

  • It seems this is not supported at the moment as even MS does not have a solution: http://social.msdn.microsoft.com/Forums/pl-PL/tfsgeneral/thread/344b1846-d571-4d17-842b-70fc05f5a83a