views:

1951

answers:

4

Microsoft Visual Studio uses XML to save its .vcproj project files. So diffing XML project files should be easily.

Unfortunately, if you change any of the project file's properties, Visual Studio insists on randomly shuffling the XML nodes of the project file! This makes textual diffing and merging of project file changes basically impossible. Changing one compiler setting can make my visual diff tool think I've changed 50% of the lines in the file! I've even tried some XML diff tools, but they just show a more structured view of the same mess.

Does anyone have any suggestions for maintaining .vcproj files in source control? Or a way to convince Visual Studio to not rearrange the XML nodes in the .vcproj file?

(I have also investigated using tools like CMake to generate .vcproj files from a more diff-friendly text file, but CMake has its own problems.)

+1  A: 

I use WinMerge as my diff-tool and I enabled the moved block detection. It doesn't quite fix the issue, but it makes visualizing the differences a little bit more bearable.

Ben S
+3  A: 

This seems to come up every now and then.

Perhaps it is a problem ripe for a plug-in or other normalizing tool.

It would be a great side-business, until MS decides to fix it. Then you're out of luck - unless of course they offer to buy your IP.

Anyone want to start an open source project, or commercial product? I'm game.

I might have a go at a stand-alone normalizing tool, then see if I can turn it into a plugin.

Tim
I guess it would be easy to write a short Python script to alphabetize a .vcproj files <Configuration> XML nodes. I see that WinMerge has plugins for diffing XML; perhaps someone should write the "vcproj alphabetizer" WinMerge plugin? Maybe I will. :)
cpeterso
A: 

Which version of Visual Studio are you seeing this in?

I do a lot of work with .vcproj files (we maintain versions of the project files for our libraries in multiple Visual Studio versions, and I'm always diffing and merging the things) but I've never seen this behaviour.

Anna-Jayne Metcalfe
VS2008, but I've heard that VS2005 has the same problem. The "vcproj shuffle" happen randomly. My projects have a few (Headers and Sources) subfolders. When navigating them, VS will occasionally reorder the projects in the GUI, sorting them either randomly or alphabetically. That might be related.
cpeterso
Thanks. I'll certainly keep an eye out for this, and if I learn anything which might help, I'll post it here.
Anna-Jayne Metcalfe
A: 

My team at Adobe has seen the same thing in vs2008. Just a basic Debug/Release, win32/win64 project gives you 4 configurations and random shuffling. Several people have tried to figure out when and why devstudio reorders, but current thought is the sort key is a keyword hash - hence semi-random. We've given up and in code reviews just summarize the "real" changes.

Dave Sawyer
Why not create an XSLT that reorders the .vcproj file according to some standard sequence. Do that for both files you're comparing ahead of time, and you'll be comparing apples to apples. I've done this with SSIS .dtsx files, which change if you stare at them for too long.
John Saunders