jurgenb
jurgenb

Reputation: 472

Visual Studio 2008: how to avoid project file merge hell?

When you're working on a VS C# project with multiple developers which all add new projects and files to the same solution the last one to try and check in his changes gets conflicts on the project solution file which aren't easy to merge.

The easiest solution to this problem I've found is to dismiss my own changes and accept the server's latest version. Then I reintegrate my own changes. Depending on the amount of new files added to the project this can be easy, or a really annoying tasks.

I'm wondering if there's an easier way to do this. Read: can I make VS/TFS/merge do this for me?

Upvotes: 7

Views: 3175

Answers (5)

Christian Warren
Christian Warren

Reputation: 61

I made a tool to specifically to compare / merge solution file (and can also be used to dynamically create filtered solution as well).

It can be found at: http://slntools.codeplex.com/

Upvotes: 6

user420442
user420442

Reputation:

I too was very fed up with merge problems with project files. (At one point I was trying to resolve 9000+ conflicts in a single project file.)

So I did something about it: http://www.projectmerge.com

Although this started out as a project file compare/merge tool, it quickly evolved into something that can compare and merge any XML file.

Hope you find it useful.

Upvotes: 1

Bevan
Bevan

Reputation: 44327

One suggestion to add to the pool of comments ...

Work on minimizing the changes you make to the SLN file when you commit, to make it easier for others to merge.

(Of course, the same goes for the others as well).

To illustrate, assume your SLN file currently lists four projects:

SLN: A, B, C, D

You and a co-worker both make changes. You add project E, plus (for some reason) things get reordered:

Yours:  A, E, D, C, B

Your co-workers changes involve adding project F:

Co-Worker: A, B, C, D, F

If you commit your changes as is, then your co-worker has to face merging these two:

SLN: A, E, D, C, B
Co-Worker: A, B, C, D, F

Nasty.

Instead, if you (carefully!) work to minimise your differences, you can make your working copy look like this:

Yours:  A, B, C, D, E

In this case, when your co-worker needs to merge, they'll have to face this:

SLN: A, B, C, D, E
Co-Worker: A, B, C, D, F

Much easier to merge.

Upvotes: 0

Reed Copsey
Reed Copsey

Reputation: 564831

My suggestion would be to update and commit more frequently. In particular, make sure you run Get Latest before pending any changes on a solution file.

"Merge hell" with things like XML and text files (which all project and solution files are) typically only occurs because people are trying to commit single changes that are very large.

If you get into the habit of doing regular commits, the merges tend to be smaller, and the tools tend to do a perfect job of it.

Upvotes: 19

AaronLS
AaronLS

Reputation: 38394

I never add files to the Solution, only projects. If you need to add files, add them to a project.

If you don't want to merge, then the alternative is if someone checks in a solution with a new project, then pull that project and the solution down, overwriting your own solution file, then re-add your project to the solution and check that back in. Now the solution has both their project and yours.

Upvotes: 1

Related Questions