Programmatically Merging using TeamFoundationClien

2019-02-15 09:30发布

I have Addin VS (maybe in future VSIX) for VS 2010. I want to do branch of any single files (sql files) and later do merge programmatically.

I have seen several options:

GetStatus status = workspace.Merge

How to merge TFS change sets programmatically?

http://blogs.microsoft.co.il/shair/2009/04/20/tfs-api-part-19-merge/

MergeContent(Conflict, true);

workspace.Merge can show dialog modal for merge (diffmerge.exe I think) and show results (resolveing conflicts) ? Note: in my case, now, I want show merge tool.

TFS API MergeContent returns false without showing merge tool

There are tf commands (command line, not C##

tf diff[erence] itemspec [/version:versionspec]

tf merge [/recursive] [/force] [/candidate] [/discard] [/version:versionspec] [/lock:none|checkin|checkout] [/preview] [/baseless] [/nosummary] [/noimplicitbaseless] [/conservative] [/format:(brief|detailed)] [/noprompt] [/login:username,[password]] source destination

tf resolve [itemspec]

[/auto:(AutoMerge|TakeTheirs|KeepYours|

OverwriteLocal|DeleteConflict

|KeepYoursRenameTheirs)]

[/preview] [(/overridetype:overridetype | /converttotype:converttype] [/recursive]

[/newname:path] [/noprompt]

[/login:username, [password]]

any suggestions for do merging of files, and have to options:

1) show dialog for merging (diffmerge)

2) auto, without show dialog for merging (diffmerge or another?) and resolving conflicts.

标签: c# tfs merge
1条回答
家丑人穷心不美
2楼-- · 2019-02-15 10:06

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();
查看更多
登录 后发表回答