using System; using System.IO; using System.Text; using System.Windows.Forms; using Microsoft.TeamFoundation.Client; // NuGet using Microsoft.TeamFoundation.VersionControl.Client; // GAC namespace TFSHistory { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { var tpp = new TeamProjectPicker(TeamProjectPickerMode.SingleProject, true); var result = tpp.ShowDialog(); if (result != DialogResult.OK) return; var tpc = tpp.SelectedTeamProjectCollection; var versionControl = tpc.GetService<VersionControlServer>(); var tp = versionControl.GetTeamProject(tpp.SelectedProjects[0].Name); var path = tp.ServerItem; var q = versionControl.QueryHistory(path, VersionSpec.Latest, 0, RecursionType.Full, null, new ChangesetVersionSpec(1), VersionSpec.Latest, Int32.MaxValue, false, true, false, false); using (var file = new StreamWriter(@"fichier.csv", true, Encoding.UTF8)) { file.AutoFlush = true; file.WriteLine("CS, Date, User, Comment"); foreach (Changeset cs in q) { if (cs.Committer.Contains("Elastic")) continue; if (string.IsNullOrWhiteSpace(cs.Comment)) continue; var comment = cs.Comment; comment = comment.Replace(',', ' '); comment = comment.Replace(Environment.NewLine, " "); file.WriteLine(string.Format("{0},{1},{2},{3}", cs.ChangesetId, cs.CreationDate, cs.Committer, comment)); } } } } }