London Calling

Ramblings of a software architect in London.

Using VS.NET web application projects with both VS.NET 2008 and 2010 RTM

What a palaver. Prior to RTM you could use VS.NET 2008 and 2010 web application projects alongside each other with no issues (after having 2010 upgrade them). With RTM, you get horrible issues with the line:

<Import Project="$(MSBuildExtensionsPath32)MicrosoftVisualStudio
    v10.0WebApplicationsMicrosoft.WebApplication.targets" />

Added to the bottom of your .csproj files. After much soul searching I’ve found a solution with a bit of MSBuild cleverness. Turns out you can conditioanlly include MSBuild targets depending on the version of Visual Studio being used.

So, for each web application project in your solution:

  1. a) Have VS.NET 2010 upgrade your projects to the newer version.
  2. b) Replace the above line with:
<Import Project="$(MSBuildExtensionsPath32)MicrosoftVisualStudio
    v9.0WebApplicationsMicrosoft.WebApplication.targets" 
    Condition="'$(Solutions.VSVersion)' == '9.0'" /> <Import Project="$(MSBuildExtensionsPath32)MicrosoftVisualStudio     v10.0WebApplicationsMicrosoft.WebApplication.targets"
    Condition="'$(Solutions.VSVersion)' == '10.0'" />
  1. c) Blank out <FileUpgradeFlags></FileUpgradeFlags> which VS.NET 2010 has probably put “4.0” in, this will trip 2008 up otherwise.
  2. d) Blank out <UpgradeBackupLocation></UpgradeBackupLocation> in the same manner.

As long as you can then live with working with a seperate solution file for VS.NET 2010, you should be away and can stop annoying anyone else working on your files!

2 comments for “Using VS.NET web application projects with both VS.NET 2008 and 2010 RTM

  1. May 18, 2010 at 1:55 pm

    After doing this when I reloaded my project VS2010 again upgraded the project and changed the V9.0 path to V10.0 path.

    To avoid VS2010 from overwriting the changes, include the 10.0 path line before the v9.0 path like below:

    • May 18, 2010 at 1:56 pm

      Sorry the angle brackets did not appear ..

Leave a Reply to Zuhaib Cancel reply

Your email address will not be published. Required fields are marked *