Using VS 2005 and VS 2008 simultaniously

Much has been written on the fact that Visual Studio 2008 can build .net 2.0 applications, and that they can be installed side-by-side on the same machine.  This is phenomenal as it allows organizations to upgrade developer tools without forcing clients to also upgrade .net framework versions.  Very nice.

However, what isn't as fully documented is using Visual Studio 2008 and Visual Studio 2005 together on a development team.  For example, Sally Slickster is an early adopter, downloaded the VS 2008 iso from MSDN 8 minutes after Scott Guthrie posted the RTM news.  She'd like to use it for all development work from now on.  Harry Hard-head, on the other hand, just figured out where all the settings are in VS 2005, and installed VS 2005 SP 1 under great duress.  No way will he use VS 2008 until at least SP 1.  They're both working on the same .net 2.0 project.

When converting a VS 2005 project to VS 2008, and leaving it to target .net 2.0, it only changes 2 sets of files: the solution file (*.sln) and the project file(s) (*.csproj).  Ok, technically, as VS 2008 developers do things, it'll replace some comments with new version information.  The header at the top of .designer.cs files now reads version 2.0.50727.1433 for example.  Since these files are rebuilt any time the designer sneezes, I'll ignore them.

The .sln files used by VS 2008 and VS 2005 are similar, but not compatible.  (So says my very un-scientific testing.)  Yes, get annoyed, get indignant, run the VS 2008 conversion wizard, leave the projects in .net 2.0 mode, then check in the second .sln file in source control.  I hate it too, but it could be worse.

The .csproj files are a different story.  During the VS 2008 conversion wizard, many new nodes and attributes are added to each project.  I didn't find anything removed, just new stuff added.  With these in place, VS 2005 pulls up a "This project has been modified outside the designer" security warning box the first time the project is re-opened.  UAC has trained me to ignore these dialogs and just push OK.  Closing and reopening VS 2005 seems to not bring up the security dialog a second time.

The major headache with the .csproj files is with Web Application Projects.  This line is changed:

<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v8.0\WebApplications\Microsoft.WebApplication.targets"
/>

it becomes:

<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets"
/>

Note the 'v8.0' becomes a 'v9.0'.

Well, now VS 2008 is happy, but VS 2005 users can't build because C:\Program Files\MSBuild\Microsoft\VisualStudio\v9.0 doesn't exist on their machines.

Adam Salvo suggests just copying this directory from a machine with VS 2008 on it to all the machines without it.  It's a whopping 900k, so who cares.  Perhaps a carefully named shortcut could do the job as well.

Steven Harman suggests replacing the offending line in the .csproj file with these lines:

<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v8.0\WebApplications\Microsoft.WebApplication.targets" Condition="'$(Solutions.VSVersion)' == '8.0'"/>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" Condition="'$(Solutions.VSVersion)' == '9.0'" />

Basically, tell it to use what ever works best.  Very nice.  Very clean.  Very self-contained.  Yes.

Perhaps in time, everyone will move to VS 2008 and this problem will just disappear.  In the mean time, now Sally and Harry are happy, and you know what happens when Harry met Sally...

Rob

posted @ Wednesday, December 12, 2007 2:59 AM

Print

Comments on this entry:

# re: Using VS 2005 and VS 2008 simultaniously

Left by Jon Davis at 12/21/2007 3:40 PM
Gravatar
Don't the project files go out of sync as soon as you add or delete any references, source files, build modes, or platform targets to/from any one project ??

# re: Using VS 2005 and VS 2008 simultaniously

Left by Rob at 12/21/2007 8:09 PM
Gravatar
Jon,

No, the project files are shared between both solution files. Consider the following:

Person A has VS 2008 and uses widget-2008.sln -- the 2008 solution
Person B has VS 2005 and uses widget-2005.sln -- the 2005 solution

Project C (proj-c.csproj) contains code for the widget:
- flange.cs
- cog.cs
- doohickey.img

Widget-2008.sln references proj-c.csproj
Widget-2005.sln references proj-c.csproj

Person A fires up widget-2008.sln, which loads proj-c.csproj
Person A adds code to cog.cs, adds whozit.cs to proj-c.csproj, and removes flange.cs
Person A then commits to source control

Person B updates his source from source control
Person B notes that proj-c.csproj has changed as has some code files
Person B fires up widget-2005.sln, which loads proj-c.csproj
Person B replaces doohickey.img, adds more code to cog.cs, and inserts default.js
Person B commits this to source control

Person A updates his source from source control
Person A notes that proj-c.csproj has changed as has some code files
Person A fires up widget-2008.sln, which loads proj-c.csproj

Proj-c is shared between widget-2008.sln and widget-2005.sln, thus Person A and Person B share it.


Now imagine that instead of only 1 .csproj file, both solutions share 5 or 8 .csproj files. The .csproj files are all common among both solutions. The only thing that could get out of sync is the .sln files.

Rob

Your comment:



 (will not be displayed)


 
 
 
Please add 2 and 5 and type the answer here:
 

Live Comment Preview: