2010-01-22 5 views
0

우리 회사의 개발자를 돕기 위해 TFS 도구를 개발하고 있습니다.Visual Studio 외부에서 VersionControlExt.Explorer 사용

이 도구는 소스 제어 탐색기 에서처럼 TFS 서버를 "탐색"할 수 있어야합니다. 나는 VersionControlExt.Explorer.SelectedItems를 사용함으로써 사용자가 TFS 서버를 브라우즈 할 수있게 해주는 팝업이 나타날 것이라고 생각한다.

그러나 VersionControlExt는 Visual Studio (일명 Plugin)에서 개발할 때만 액세스 할 수 있습니다. 불행히도, 나는 이길 수있는 Windows 응용 프로그램을 개발 중입니다.

그래서 Visual Studio 외부에서 VersionControlExt를 사용할 수 있습니까? 그렇다면 어떻게?

Here's

string path = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); 
Assembly vcControls = Assembly.LoadFile(path + @"\Microsoft.TeamFoundation.VersionControl.Controls.dll"); 
Assembly vcClient = Assembly.LoadFile(path + @"\Microsoft.TeamFoundation.VersionControl.Client.dll"); 

Type dialogChangesetDetailsType = vcControls.GetType("Microsoft.TeamFoundation.VersionControl.Controls.DialogChangesetDetails",true); 
Type[] ctorTypes = new Type[3] {vcClient.GetType("Microsoft.TeamFoundation.VersionControl.Client.VersionControlSever"), 

vcClient.GetType("Microsoft.TeamFoundation.VersionControl.Client.Changeset"), typeof(System.Boolean)}; 

ConstructorInfo ctorInfo = dialogChangesetDetailsType.GetConstructor(ctorTypes); 
Object[] ctorObjects = new Object[3] {VersionControlHelper.CurrentVersionControlServer, uc.ChangeSet, true}; 
Object oDialog = ctorInfo.Invoke(ctorObjects); 
dialogChangesetDetailsType.InvokeMember("ShowDialog", BindingFlags.InvokeMethod, null, oDialog, null); 
+0

그냥 궁금뿐만 아니라 TFS2010에 기본 설치에 포함 된 MS가 제공하는 웹 버전을 사용하지 이유 : http://msdn.microsoft.com/en-us/teamsystem/bb980951.aspx I을 우리가 비슷한 상황에 처했기 때문에 호기심이 생겼습니다. 웹 버전이 어떤 요구를 충족시키지 못했습니까? –

+0

또한이 도구를 빌드 시스템에 통합 할 계획이 있습니다. 우리의 빌드 시스템은 1995 년부터 사용되었으며 여전히 TFS 빌드 시스템이 아닌 배치 파일을 사용합니다. – Ian

답변

0

난 정말하지 않는 것이 밝혀 비주얼 스튜디오의 외부 Changset 세부 사항 대화 상자 사용에 대한 시도는 탐색기가 필요합니다.

이 작업은 TreeView 컨트롤과 VersionControlServer.GetItems()를 사용하여 수행했습니다. 아래

코드는 :

 treeView.Sort(); //Alphabetically ordered 

     //Get Initial List of Projects 
     try 
     { 
      ItemSet itemSet = vcs.GetItems(@"$/", RecursionType.OneLevel); 

      foreach (Item item in itemSet.Items) 
      { 
       if (item.ServerItem == @"$/") //Ignore self 
        continue; 

       TreeNode node = new TreeNode(item.ServerItem, new TreeNode[] { new TreeNode() }); 
       node.Tag = item.ServerItem; 

       if (item.DeletionId != 0) 
        node.ForeColor = Color.Red; 

       treeView.Nodes.Add(node); 
      } 
     } 

그런 다음, 매번 사용자는 내가 해당 노드 아래에있는 모든 항목을 얻을 노드를 확장합니다.

TreeNode curNode = e.Node; 
       curNode.FirstNode.Remove(); //Remove blank dummy node 


       ItemSet items = vcs.GetItems(curNode.Tag.ToString(), VersionSpec.Latest, RecursionType.OneLevel, DeletedState.Any, ItemType.Folder); 

       foreach (Item item in items.Items) 
       { 
        if (item.ServerItem == curNode.Tag.ToString()) //Ignore self 
         continue; 

        string Name = System.IO.Path.GetFileName(item.ServerItem); 

        TreeNode node = new TreeNode(Name, new TreeNode[] { new TreeNode() }); 
        node.Tag = item.ServerItem; 

        if (item.DeletionId != 0) 
         node.ForeColor = Color.Red; 

        curNode.Nodes.Add(node); 
       } 
1
public void ShowChangeSetDetails(Form owner, Changeset changeSet) 
     { 
      string path = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); 
      Assembly vcControls = Assembly.LoadFrom(path + @"\Microsoft.TeamFoundation.VersionControl.Controls.dll"); 
      Assembly vcClient = Assembly.LoadFrom(path + @"\Microsoft.TeamFoundation.VersionControl.Client.dll"); 

      Type dialogChangesetDetailsType = 
       vcControls.GetType("Microsoft.TeamFoundation.VersionControl.Controls.DialogChangesetDetails", true); 

      MethodInfo methodInfo = 
       dialogChangesetDetailsType.GetMethod(
        "ShowChangeset", 
        BindingFlags.Static | BindingFlags.NonPublic, 
        null, 
        new Type[] { typeof(IWin32Window), changeSet.VersionControlServer.GetType(), changeSet.GetType(), typeof(bool) }, 
        null); 
      methodInfo.Invoke(null, new object[] { owner, changeSet.VersionControlServer, changeSet, true }); 
     } 
관련 문제