1
votes

Somebody know how to solve my question?

I'm using a console application (I tried to use windows app) that interacts with TFS API using C#. But when I tried to merge two solutions, some files has conflicts and no conflict window was showed.

Before, I was using Visual Studio 2013 and all worked fine, but now, we changed to VS 2015, and DLLs was not in GAC, but I changed to Nuget.

I tried Local workspace and Server workspace.

The code below, when i debugged, returns "Evaluation Timeout" and no window was showed.

workspace.MergeContent(conflict, true)


Microsoft Visual Studio Enterprise 2015 Version 14.0.24720.00 Update 1 Microsoft .NET Framework Version 4.6.01038

Installed Version: Enterprise


TFS: TFS 2013


Code:

public bool Merge(string branchOrigem, string branchDestino)
{
    TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri("xxxxx"));
    tfs.EnsureAuthenticated();

    VersionControlServer vcs = tfs.GetService<VersionControlServer>();
    Workspace workspace = vcs.GetWorkspace("xxxx", "xxxx");

    GetStatus status = workspace.Merge(branchOrigem,
                       branchDestino,
                       null,
                       null,
                       LockLevel.None,
                       RecursionType.Full,
                       MergeOptions.None);

    Conflict[] conflicts = workspace.QueryConflicts(new string[] { branchDestino }, true);

    foreach (Conflict conflict in conflicts)
    {
        if (workspace.MergeContent(conflict, true))
        {
            conflict.Resolution = Resolution.AcceptMerge;
            workspace.ResolveConflict(conflict);
        }
    }

    return true;
}

I have news, a guy in MSDN helped me and worked fine: https://social.msdn.microsoft.com/Forums/en-US/490c4a97-872d-4492-92e9-50df5e514082/conflict-resolution-window-dont-appear-in-visual-studio-2015-using-tfs-api-with-c?forum=visualstudiogeneral


Hi MarcoVinicioFerreira,

Thanks for your post.

First, please manually perform the same Merge option on that same files using VS 2015, ensure this the conflict window will be showed successfully.

Then add the TFS 2015 dlls from this path: ‘C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer’ in your project, and run your API code.

And you can refer to below code snippet:

TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri("URL"));

tfs.EnsureAuthenticated();

VersionControlServer vcs = tfs.GetService();

Workspace workspace = vcs.GetWorkspace("workspacename", "ownername");

GetStatus status = workspace.Merge("sourceitem",

               "targetitem",

               null,

               null,

               LockLevel.None,

               RecursionType.Full,

               MergeOptions.None);

Conflict[] conflicts = workspace.QueryConflicts(new string[] { "targetitem" }, true);

foreach (Conflict conflict in conflicts)

{

if (workspace.MergeContent(conflict, true))

    {

        conflict.Resolution = Resolution.AcceptMerge;

        workspace.ResolveConflict(conflict);

    }

}

1
Which nuget package are you using?Eddie Chen - MSFT
Hi Eddie, here is the solution: social.msdn.microsoft.com/Forums/en-US/…Marco Ferreira

1 Answers

0
votes

I can reproduce this issue too. Not sure what is the root cause, but I get it work by reinstalling Team Explorer for Microsoft Visual Studio 2013. After installing Team Explorer 2013, Workspace.MergeContent method will call the merge tool with VS2013 Shell.