views:

1046

answers:

9

Hi,

I'd like to synchronize a VC++ 2010 project with a VC++ 2008 one. Is it even possible ? Basically, if I'm adding/deleting/renaming a file to a project in VS2010, I'd like it to be added/deleted/renamed to the corresponding VS2008 project. Project options synchronization would be awesome too, but not necessary. I don't need a solution-level synchronization either.

Edit: I've been suggested to "merge" the project files at check-in or build time with a script or tool. Unfortunately, VC++ project file format has changed from VS2008 to VS2010 and have nothing in common. So my question is more like: Is there a tool out there capable of merging/converting between vc9 and vc10 project files ? I might write my own tool if there is not any other way to address this.

Thanks.

+1  A: 

You only can maintain those solution/project files separately. if you'll write your add-on please let me know!

Trickster
+2  A: 

Source control helps here. I have done this before with previous versions by making an upgraded (VS2010) branch and merging changes back and forth between it and the trunk (VS2008). While certainly not seamless, it works.

I don't know if the project changes in VS2010 would make it any better or worse than before!

GraemeF
This project is source controlled with TFS, so I'm very interested in that. But I don't understand how I could merge changes between a .vcproj (2008) project and a .vcxproj (VC++2010). How can I achieve that ?
Samuel_xL
You would merge changes between the two in the same way you would for any other files under TFS.
GraemeF
+1  A: 

I don't have 2010 installed at work so I'm going mostly from memory here. Very little has changed in the project file schema from 2005 to 2008 to 2010. For the most part I simply use a text comparison tool like WinDiff or BeyondCompare to highlight the changes and copy them from one file to the other. I haven't played with any of the web project types, but I'm assuming for the most part the same technique will work. Since their basically XML schema's you could also use an XML mapping tool to do the same job.

I did notice when I converted an open source project that 2010 really did not like ClickOnce project settings. It would convert fine, but would ask me to convert again every subsequent time I opened the project. I ended up having to completely remove the ClickOnce information from the project file in order to get it to stop.

EDIT: My experience is mostly based on the C# project schema, which hasn't changed much over time. As TheSamFrom1984 has pointed out, there are some big changes in the C++ schema that hasn't made it into the MSDN documentation on version 10 yet.

Jeremy Seghi
Unfortunately, VC10 and VC9 project files differs completely.
Samuel_xL
I haven't had the opportunity to directly work with any VC++ project files lately, but the XSD schemas published by MS indicates no change to the structure. Where are the differences that you're seeing?
Jeremy Seghi
For example, files are listed with <VisualStudioProject><Files><Filter><File> in vc9, and <Project><ItemGroup><ClCompile> in vc10. A diff shows only one common line: the first one.
Samuel_xL
Thanks for pointing that out. I just noticed the published schema for VC10 on MSDN shows Version="9.00"; I probably should have caught that the first time. I'll have to take a closer look at the actual XSD files when I have access to them. I'm also editing my answer to note the dicrepancy
Jeremy Seghi
If you do a more accurate diff on the .vcproj files, (per word, separated by whitespace and punctuation in WinMerge or per char), can identify a replaceable pattern?
Danny Varod
Jeremy Seghi
+6  A: 

The Gallio OSS project is built using VS2010 while most of the contributors still use VS2008. To keep the *.csproj files synchronized with the *.vs2010.csproj files, we use a simple PowerShell script that runs WinMerge against every pair of project files. Nothing complicated, but very handy.

You can download the script at Google Code. To run it, just type the following command:

@echo off
powershell "& './Compare VS2010 Projects.ps1' -sync %*"

I hope it helps.

Yann Trevin
Would help in c#, but C++ project files can't be merged since the layout is completely different from VC++2008 to VC++2010. Good idea though.
Samuel_xL
Mmh... I had not seen that you talk about VC++ projects and not C# projects. So I don't know if my solution is really applicable in your scenario.
Yann Trevin
I think it's the best idea. Now my question is reduced to 'how can I "merge" between vc9 and vc10 project files'. I might do this myself with a tool.
Samuel_xL
+2  A: 

I believe the is a command line option to migrate a VS2008 project file to VS2010. So an option would be to only maintain the VS2008, and regenerate the VS2010 projects. The downsides are

  • Not being able to enter VS2010 specific project options
  • Any changes to the VS2010 project will be overwritten and not merged back to VS20008.
Stephen Nutt
I thought about that, but i need to do 2010->2008 as well
Samuel_xL
+1  A: 

Visual Studio 2010 supports multi-targeting which will allow you to develop using VS2010 and downtarget the Platform tools to V9 so you can use the latest tools to maintain an older project. Why not just do that?

It comes with VS2010 and VS2008 for C++ out of the box, here is some info on settingup the VS2005 toolchain

http://weblogs.asp.net/israelio/archive/2009/10/20/enable-vs-2010-multi-targeting-also-for-vs2005-c.aspx

Jim Wallace
I believe the idea is not so much that a different compiler version can be used to compile the source files but that the different developers on the project can use whichever of the 2 IDEs they have (or prefer).
Michael Burr
In the past the IDE and the compiler version were tightly linked so to compile with VC8 you needed VS2k5, and to compile with VC9 you need VS2k8 (we have this exact problem at our office now). VS2010 will allow everyone to use VS2010 and still downtarget to VC9, or VC8 instead of VC10. What I'm saying is give everyone 2010 and let them downtarget rather than support multiple-IDEs :)
Jim Wallace
+1  A: 

I did precisely this back when VS 2008 came out and we were evaluating it while the rest of the team were using VS 2005. I didn't want to commit any of the new format project files in as that would break it for the rest of the team, so I wrote a small script in ruby that just searched for all .vcproj files and renamed them to _2008.vcproj . I did the same for the .sln files too, but also searched for the references to .vcproj in the sln files and renamed that to _2008.vcproj so that it references the new projects.

Next, just load the new solution files and let the migration wizard do its thing (I assume VS 2010 has one just like the older versions). This lets you run both versions side by side. If anyone else in the team makes any changes to the old project file then simply re-run your conversion and then the wizard should just migrate the project that changed.

There's a further tweak you may need to add to the script which is to change the OutputDirectory and IntermediateDirectory fields in the vcproj file so that you're building to different directories too. If you do that then it means that you should be able to build with either version of Visual Studio on the same source tree.

the_mandrill
A: 

You should treat the VS2010 copy as a Branch. Every couple days and upon any major change (Pending tests pass, of course), merge changes into the other Branch. This is a widely adopted and accepted practice in Enterprise software environments.

tsilb
Again, I dont get how you can do that, since you CANT merge between vc9 and vc10 projects
Samuel_xL
+3  A: 

At my company we had exactly the same problem and chose to use CMake.

At least try it on one of your projects, it is the ideal solution for your problem.

It allows to describe our projects with a simple syntax in text files and then CMake generates VS2005, VS2008 and VS2010 projects from the same files.
This way only the Cmake files are modified and all the projects are updated at the same time.

In short CMake is:
1. clean
2. descriptive
3. native
4. safe

Because:
1. All the options and configurations can be read in the files, not in many properties panels.
2. The CMake grammar and syntax is easy to read.
3. All the generated projects are complete and independant from CMake.
4. You can use a Source Control Manager on the CMake files.

We had some solutions of 50 projects or 20 projects and it was a lot of work, and one of the reason we used CMake was because we needed to work with Xcode on Mac on some libraries which projects are now common for VS and Xcode.
But it would have been worth it even for the different versions of VS only.

Winz