2017-09-13 111 views
-2

我正在使用最新的tfs api使用.net客戶端庫來獲取變更集詳細信息。但我無法這樣做。我可以得到工作項目的詳細信息,但不是像檢入用戶,日期等更改集的詳細信息。有沒有辦法使用C#代碼來做到這一點。變更集詳細信息的Tfs api

+0

那你試試? – isalgueiro

回答

0

我可以使用API​​從TFS查詢,下面是我的代碼:

您需要安裝NuGet包Microsoft.TeamFoundationServer.ExtendedClient

using System; 
using Microsoft.TeamFoundation.Client; 
using Microsoft.TeamFoundation.VersionControl.Client; 

namespace _0914_GetChangesetDetails 
{ 
    class Program 
    { 
     static void Main(string[] args) 
     { 
      TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri("http://server:8080/tfs/CollectionLC")); 
      new System.Net.NetworkCredential("Domain\user", "password"); 
      tpc.EnsureAuthenticated(); 
      VersionControlServer vcs = tpc.GetService<VersionControlServer>(); 

      int cid = vcs.GetLatestChangesetId(); 
      string path = "$/0418Scrum"; 
      var history = vcs.QueryHistory(path, RecursionType.Full, 10); 
      Console.WriteLine("Following are the latest 10 changeset in " + path + ":"); 

      foreach (Changeset item in history) 
      { 
       Console.WriteLine("{0} {1} {2} {3}", item.ChangesetId, item.Owner, item.CreationDate, item.Comment); 
      } 
      Console.WriteLine("The latest changeset ID is:" + cid); 
      Console.ReadLine(); 
     } 
    } 
} 

enter image description here