无法以编程方式显示内置的合并工具来解决合并冲突 [英] Cannot programatically display built in Merge tool to resolve a merge conflict

查看:83
本文介绍了无法以编程方式显示内置的合并工具来解决合并冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用单元测试项目 VS 2012 ,也使用控制台应用程序项目 VS 2012 ,它们使用 TeamFoundationClient 11.0 TFS 2008 .

我使用 MergeContent(Conflict,true) ,但未显示UI(用于合并的对话框模式).

我看过这个参考文献:

无法以编程方式显示内置的合并工具来解决合并冲突 http://msdn.microsoft.com/zh-cn/library/microsoft.teamfoundation.versioncontrol.client.workspace.mergecontent(v = vs.110).aspx

在未配置任何用户工具的情况下将VS 2010与TFS 2010一起使用 当我们调用Workspace.MergeContent()时执行合并操作 如果useExternalMergeTool = true,则使用内置的VS合并工具.

在未配置任何用户工具的情况下将VS 2012与TFS 2012一起使用 当我们调用Workspace.MergeContent()时执行合并操作 使用useExternalMergeTool = true时,函数将返回fals,而不会 打开内置的VS合并工具.最后,与以前的版本不同, VS 2012内置的合并工具相当不错,但是现在没有办法 以编程方式打开它以解决合并冲突.这是 VS 2010的功能回归.

关于它的任何建议或用于合并内容的显示模式对话框的任何解决方法?

解决方案

从Visual Studio安装目录C:\ Program Files(x86)\ Microsoft Visual Studio 12.0 \ Common7 \ IDE复制Visual Studio安装目录中的vsDiffMerge.exe

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();

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 ?

解决方案

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();

这篇关于无法以编程方式显示内置的合并工具来解决合并冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆