解决TFS API中的合并冲突

解决TFS API中的合并冲突,tfs,tfs-sdk,Tfs,Tfs Sdk,我正试图解决与tfsapi的合并冲突,我正在努力。我的问题如下: 从主干合并->分支 合并过程中发生冲突(在两个文件中编辑的文件的同一行) 在这一点上,我只想为合并文件的外观提供我自己的文本,然后将其标记为已解决 我想不出怎么做。见下面的代码: // merge was performed and there are conflicts to resolve Conflict[] conflicts = ws.QueryConflicts(new string[] {"$/ProjectName

我正试图解决与
tfsapi
的合并冲突,我正在努力。我的问题如下:

  • 从主干合并->分支
  • 合并过程中发生冲突(在两个文件中编辑的文件的同一行)
  • 在这一点上,我只想为合并文件的外观提供我自己的文本,然后将其标记为已解决
  • 我想不出怎么做。见下面的代码:

    // merge was performed and there are conflicts to resolve
    Conflict[] conflicts = ws.QueryConflicts(new string[] {"$/ProjectName/solution/"}, true);
    Console.WriteLine(" - Conflicts: {0}", conflicts.Count());
    
    if (conflicts.Any())
    {
        Console.WriteLine(" - Resolving conflicts");
    
        // There are conflicts to deal with
        foreach (Conflict conflict in conflicts)
        {
            // Attempt to perform merge internally
            ws.MergeContent(conflict, false);
    
            if (conflict.ContentMergeSummary.TotalConflicting > 0)
            {
                // Conflict was not resolved
                // Manually resolve  
                // PROBLEM IS HERE <--------------
                var allLines = File.ReadAllLines(conflict.TargetLocalItem).ToList();
                allLines.Add("This is the MANUAL merge result");
                File.WriteAllLines(conflict.TargetLocalItem, allLines.ToArray());
            }
    
            //conflict was resolved
            conflict.Resolution = Resolution.AcceptMerge;
            ws.ResolveConflict(conflict);
        }
    }
    
    Checkin(ws, "Merge comment");
    Console.WriteLine("Done");
    
    //已执行合并,存在需要解决的冲突
    Conflict[]conflicts=ws.QueryConflicts(新字符串[]{“$/ProjectName/solution/”},true);
    WriteLine(“-Conflicts:{0}”,Conflicts.Count());
    if(conflicts.Any())
    {
    Console.WriteLine(“-解决冲突”);
    //有冲突需要处理
    foreach(冲突中的冲突)
    {
    //尝试在内部执行合并
    合并内容(冲突,错误);
    if(conflict.ContentMergeSummary.TotalConflicting>0)
    {
    //冲突没有得到解决
    //手动解析
    //问题就在这里试试这个

    string tmpOutFile = Path.GetTempFileName();    
    conflict.MergedFileName = tmpOutFile;                                   
    // do stuff with tmpOutFile
    conflict.Resolution = Resolution.AcceptMerge;
    ws.ResolveConflict(conflict);