Cannot programatically display built in Merge tool to resolve a merge conflict

别来无恙 提交于 2019-12-13 04:47:56

问题


I use Unit Testing project VS 2012 and too an Console Application project VS 2012 using TeamFoundationClient 11.0 and TFS 2008.

I use MergeContent(Conflict, true) but not shown UI (dialog modal for merge).

I have seen this reference:

Cannot programatically display built in Merge tool to resolve a merge conflict https://connect.microsoft.com/VisualStudio/feedback/details/783320/cannot-programatically-display-built-in-merge-tool-to-resolve-a-merge-conflict

Workspace.MergeContent() with useExternalMergeTool = true does not open the built in VS merge tool using VS 2012

http://msdn.microsoft.com/en-us/library/microsoft.teamfoundation.versioncontrol.client.workspace.mergecontent(v=vs.110).aspx

Using VS 2010 with TFS 2010 without any User Tool configured for performing a merge operation, when we call Workspace.MergeContent() with useExternalMergeTool = true, the built in VS merge tool was used.

Using VS 2012 with TFS 2012 without any User Tool configured for performing a merge operation, when we call Workspace.MergeContent() with useExternalMergeTool = true the function returns fals without opening the built in VS merge tool. At last, unlike previous versions, the VS 2012 built in merge tool is quite nice, but now there is no way to open it programatically to resolve a merge conflict. This is functional regression from VS 2010.

Any suggestions about it or any workaround for show modal dialog for merge content ?


回答1:


copy vsDiffMerge.exe from visual studio installation dir C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE inside App Exe file

var mergetool = new ThirdPartyToolDefinition(".*",ToolOperations.Merge,"vsDiffMerge.exe","","/m %1 %2 %3 %4");
var toolcol= ThirdPartyToolDefinitionCollection.Instance.FindTool(".*",ToolOperations.Merge);
if (toolcol == null)
   {
    ThirdPartyToolDefinitionCollection.Instance.AddTool(mergetool);
    ThirdPartyToolDefinitionCollection.Instance.PersistAllToRegistry();
   }

var controlsAssembly = Assembly.GetAssembly(typeof(ControlAddItemsExclude));
var vcResolveCoinflictsDialogType = controlsAssembly.GetType("Microsoft.TeamFoundation.VersionControl.Controls.DialogResolveConflicts");
var ci = vcResolveCoinflictsDialogType.GetConstructor(BindingFlags.Instance | BindingFlags.Public, null, new[] { typeof(Workspace), typeof(string[]), typeof(bool) }, null);
var resolveCoinflictsDialog = (Form)ci.Invoke(new object[] { workspace, null, true });
resolveCoinflictsDialog.ShowDialog(parent);

ThirdPartyToolDefinitionCollection.Instance.Remove(mergetool);
ThirdPartyToolDefinitionCollection.Instance.PersistAllToRegistry();


来源:https://stackoverflow.com/questions/27405155/cannot-programatically-display-built-in-merge-tool-to-resolve-a-merge-conflict

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!