Search code examples
c#tfstfs-sdkgit-tfs

How to add custom TFS CheckinNoteDefinitions?


Using TFS 2012 client C# API, I can add CheckinNotes to each commit; CheckinNotes need a suitable CheckinNoteFieldDefinition for each CheckinNoteFieldValue, or the checkin will be rejected and an exception is thrown.

How can I add additional (custom) CheckinNoteFieldDefinitions to the tfs server?

I am not really getting any useful information out of the MSDN documentation.

Related MSDN links:


Solution

  • It's created dynamically by the server once you check-in with any custom check-in notes:

    var checkinNoteFieldValues = new[]
    {
        new CheckinNoteFieldValue("Custom Note", "some value"),
        new CheckinNoteFieldValue("Other Note", "other value")
    };
    var checkinNote = new CheckinNote(checkinNoteFieldValues);
    var pendingChanges = workspace.GetPendingChanges(); // workspace is Microsoft.TeamFoundation.VersionControl.Client.Workspace
    workspace.CheckIn(pendingChanges, "comment", checkinNote, null, null); // checkinNote will trigger a new CheckinNoteFieldDefinition