Rick Strahl's Weblog  

Wind, waves, code and everything in between...
.NET • C# • Markdown • WPF • All Things Web
Contact   •   Articles   •   Products   •   Support   •   Advertise
Sponsored by:
West Wind WebSurge - Rest Client and Http Load Testing for Windows

Issue: Migrating Web Application Projects between VS 2005 and VS 2008


:P
On this page:

By and large making a Visual Studio 2008 project work in Visual Studio 2005 is nearly transparent - project files generally work in both versions and the only change required is on the Solution file where the file version needs to be changed:

VS 2005 (top of .sln file):

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005

VS 2008:

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008

And usually that's all it takes to move a VS 2008 project back to VS 2005.

Build Targets and Web Application Projects

However, if you're using any 'special' projects that include custom build targets you may find that although the project will open just fine on your machine it may fail on another machine that doesn't have VS 2005 or VS 2008 installed. The problem is that each version includes its own Build Targets for certain project types.

For example, Web Application Projects uses different build targets in VS 2005 and VS 2008 in the .csproj file:

VS 2005:

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

VS 2008:

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

If you now switch a VS 2008 project back to VS 2005 it will work just fine on your machine because you will have the v9.0 targets installed. However if you install on a machine that only has VS 2005 SP1 install the V9.0 targets are missing.

I suspect there are other cases where similar rules apply. If I remember correctly the same applies to the WCF service related targets.

This is unfortunate, because it's really hard to tell whether something works or not with VS 2005, unless you have a machine that only has VS 2005 installed.

If you're distributing source code/projects/solutions to customers who may be running either VS 2005 or VS 2008 it's probably best to ship the VS 2005 solution. When that project is opened in VS 2008 it will automatically up convert and things like these build target differences are automatically applied.

For my West Wind Web Store distribution I originally had a VS 2005 and VS 2008 solution file figuring that's all it would take, but the above actually prevents me from doing so because the WAP project file requires the above change. Even if the solution points at VS 2008 opening the solution still pops up the Upgrade Wizard and this way at least you get the correct behavior.

The bad part about this is trying to remember to fix the build target. It's not good enough to open the project in Visual Studio 2005 and make a change to the project settings - the build target doesn't change in this case and remains at the VS 2008 default.

Definitely a special case scenario, but something that I've unwittingly perpetrated on some of my customers not realizing the issue <g>...

Posted in ASP.NET  Visual Studio  

The Voices of Reason


 

Tyrone
January 22, 2008

# re: Issue: Migrating Web Application Projects between VS 2005 and VS 2008

Rick,

I think this article compliments yours.

http://stevenharman.net/blog/archive/2007/09/28/multi-targeting-vs2005-and-vs2008-web-application-projects-a-gotcha.aspx

It's explains how to get around the Build Targets issue when moving a web application project from VS 2005 to Vs 2008

Rick Strahl
January 22, 2008

# re: Issue: Migrating Web Application Projects between VS 2005 and VS 2008

@Tyrone - thanks for sharing the link here.

To summarize the fix that Steven is using is to conditionally pull in the 9.0 or 8.0 build targets as follows:

  <!-- Note: VS 2008 uses a different build target than VS 2005 so conditionally pull the right one -->
  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
  <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" 
          Condition="'$(Solutions.VSVersion)' == '9.0'" />
  <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v8.0\WebApplications\Microsoft.WebApplication.targets"
          Condition="'$(Solutions.VSVersion)' == '8.0'"/> 

Gaƫtan Voyer-Perrault
January 22, 2008

# re: Issue: Migrating Web Application Projects between VS 2005 and VS 2008

Hey Rick, I'm just stopping by to say thank you for all of these VS 2008 posts. I'm not "there" yet, but I know I'll be back here soon. So thanks for being on the ball.

Rick Strahl
February 13, 2008

# re: Issue: Migrating Web Application Projects between VS 2005 and VS 2008

Looks like the recent pre-SP1 hotfix also changed another thing: The environment string value for the build path.

VS 2005:
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />


VS 2008:
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />


This used to work without any changes prior to the hotfix, which is a bummer. Makes it much more involved to move files between VS 2008 and VS 2005.

Simmi
May 27, 2009

# re: Issue: Migrating Web Application Projects between VS 2005 and VS 2008

can you please tell me, is this code added to web.config aur some other file?
there is no .vbproj file in the converted application. i added this code to web.config but i'm getting around 200 errors.

cs
January 05, 2010

# re: Issue: Migrating Web Application Projects between VS 2005 and VS 2008


I had to convert a C++ project from VS2008 back to VS2005. This solution worked for me:

http://sourceforge.net/projects/vspc/

West Wind  © Rick Strahl, West Wind Technologies, 2005 - 2024