rss
twitter

Wednesday, September 21, 2016

Programmatically adding Labels in TFS


            Using C# code we can Label the files in particular changeset. Below is the code snippet for labeling all files in  given changeset.

 private void LabelChangeset(string fileLabel, Changeset changeset)  
   {  
     VersionControlLabel vcl = new VersionControlLabel(vcServer, fileLabel, null, cbProjects.SelectedItem.ToString(), "Autogen label.");  
     LabelItemSpec[] itemSpecs = new LabelItemSpec[changeset.Changes.Length];  
     string ver = string.Format("C{0}", changeset.ChangesetId);  
     VersionSpec fileVersion = VersionSpec.ParseSingleSpec(ver, null);  
     int index = 0;  
     foreach (Change c in changeset.Changes)  
     {  
       itemSpecs[index++] = new LabelItemSpec(new ItemSpec(c.Item.ServerItem, RecursionType.None), fileVersion, false);  
     }  
     LabelResult[] results = vcServer.CreateLabel(vcl, itemSpecs, LabelChildOption.Replace);  
   }  
Original post can be found here: https://goo.gl/DGiB5N

Bookmark and Share

0 comments:

Post a Comment

  © Blogger templates by Ourblogtemplates.com updated with zenplate.com tips

Back to TOP