How to use solutions and projects between Visual Studio 2005 and 2008


In this blog post, I’ll explain the possibilities and limitations of using solutions and projects between Visual Studio 2005 and 2008.  Read on!


The upcoming release of Visual Studio 2008 introduces a great new feature called ”.NET Framework Multi-targeting” that allows you to target multiple versions of the .NET framework using Visual Studio 2008. (Check out Luke Hoban’s blog and Scott Guthrie’s blog for additional information)  Multi-targeting opens up a new world of possibilities, in addition to its fair share of questions.  One particular question that we’ve been hearing often over the past few months is: “How can I work with solutions and projects between Visual Studio 2005 and Visual Studio 2008?”


The short answer to this question is:



  1. Solutions created in Visual Studio 2008 cannot be opened in Visual Studio 2005

  2. Projects created in Visual Studio 2008 can be opened in Visual Studio 2005

  3. Solutions and projects created in Visual Studio 2005 can be opened in Visual Studio 2008

As with all things, there are some subtle details with these statements that I’d like to take some time to explore with you. 


Solutions created in VS2008 cannot be opened in VS2005


As you work with multi-targeting, you or your team may have a need to share solutions between Visual Studio 2005 and Visual Studio 2008.  One common scenario would be opening a solution created in Visual Studio 2008 and targeting .NET Framework 2.0 in Visual Studio 2005.  You’ll find that opening this solution in Visual Studio 2005 will give you the following error dialog.


clip_image001


      Diagram 1: Error message when opening VS2008 solution in VS2005


This dialog demonstrates an important point: Opening Visual Studio 2008 solutions in Visual Studio 2005 is not supported at the solution levelThis is triggered by the fact that the version number in the .sln file of any solution created in or upgraded to Visual Studio 2008 has been updated to 10.00 (see Diagram 2).  This was a tough decision that we had to take during the design of Visual Studio 2008 and was due to the enormous complexity and cost of supporting the resulting compatibility scenarios.  This is an area that we will be actively investigating to improve for our next release.









Visual Studio 2005 Visual Studio 2008

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


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


       Diagram 2: Comparison of .sln files between VS2005 and VS2008


Are there any workarounds?


If you’re daring, there are a few things that you can do to work around this restriction.  Given that these scenarios are not supported, going down these routes may cause your project items to become corrupt, designer elements to break, etc. so please keep these risks in mind. 




  1. The first workaround is a rather obvious one that you may have already tried.  It involves modifying the version of the Visual Studio 2008 .sln file to 9.00.  You’ll find that in most cases, this will do the trick and allow Visual Studio 2005 to open the solution.  However, if the solution contains any projects and/or settings that are new to Visual Studio 2008 (i.e. usage of new language constructs, designer interfaces, etc.), the solution can fall apart. I would encourage you to not use this workaround, especially for solutions that contain several projects.



  2. The second work around involves adding projects created in Visual Studio 2008 directly into an existing Visual Studio 2005 solution.  The important point to note here is that Visual Studio 2008 projects are not explicitly blocked from being opened/added to Visual Studio 2005 solutions. The motivation behind this decision was to ensure that Visual Studio would remain performant by avoiding the performance hit of checking the versioning of every single project in a solution on startup.  This workaround has similar risks as the first workaround, but given that it forces you to make a targeted decision as to which project to use in the Visual Studio 2005 solution, it may be a viable workaround for you.


A note about the ToolsVersion attribute


For both of the workarounds above, you can update the project files (.csproj, .vbproj, etc.) to control the version of the build tools that will be used. This is done through the ToolsVersion attribute on the Project element. Diagram 3 describes the change that needs to be made in order for a project created in Visual Studio 2008 to invoke the 2.0 version of the build tools.









Original .csproj Modified .csproj

<Project ToolsVersion=”3.5” DefaultTargets=”Build” xmlns= “http://schemas.microsoft.com/
developer/msbuild/2003
“>


<Project ToolsVersion=”2.0” DefaultTargets=”Build” xmlns= “http://schemas.microsoft.com/
developer/msbuild/2003
“>

                     Diagram 3: How to update the build toolset


Solutions and projects created in VS2005 can be opened in VS2008


It’s worth mentioning that when opening a Visual Studio 2005 solution or project in Visual Studio 2008, you will see a dialog that will guide you through the upgrade process.  The important thing to keep in mind is that this process will update the version number in the .sln file to 10.00, which will prevent this solution from being opened again in Visual Studio 2005.  Note that all of the points discussed in this post apply to these upgraded solutions and projects as well. 


Closing Thoughts


As always, I’d love to hear your feedback and questions.  I expect there to be some confusion on this topic so feel free to add your comments.  Also, if you happen to run into any issues while trying out different scenarios involving solution/project inter-operability between Visual Studio 2005 and 2008, file a bug on the Connect website.


Comments (42)

  1. I thought I’d get away with maintaining both a vs2005 solution file and a vs2008 solution file and sharing projects but I found a few more problems:

    Sharing a VS Test project between a PC with only VS2005 and a PC with only VS2008 will mean changing the QualityTools.UnitTestFramework reference regularly. Similarly with sharing Web App and DBPro projects between these machines.

    We’ve decided that for anything more than simple Win Forms + Class Library solutions we will just make sure everyone on the team is using VS2008.

  2. With VS 2008 being released on Monday , let the project conversions begin! While I wish we could have

  3. graye says:

    I’ve just completed a utility that will allow you to convert between VS2005 and VS2008 projects.  (It just edits the solution and project files… no other conversion is done).

    I’d consider it an "advanced beta", but folks are welcome to take a look at the VB2008 source code.

    http://home.hot.rr.com/graye/Temp/ProjectConverter.zip

  4. I guess you guys had no choice, but to upgrade an enterprize team of 40 onshore and 100+ offshore members is NOT easy. Not many managers give the members enough time to settle down and upgrade IDEs when they should be writing code. There has to be a solution to the problem of sharing .sln and .proj files between IDEs. Let me know if you have any ideas. The alternatives of manually changing version nos. in sln files are too risky to try.

    Thanks,

    Rupak Ganguly

    Solution Architect, Hewlett Packard

  5. Terry Tsay says:

    A lot of us in this organization are still using VS2005 to create and edit solutions and projects. However, that means, given that once we convert we cannot go back without changing solution file, we cannot edit VS2005 solutions and projects in VS2008 and check it back to souce safe.

    So it turns out that it is pointless to try to use VS2008 over VS2005 as we do not plan to upgrade to 3.0 or 3.5 any time soon.

    I was hoping that since I heard that I can edit .net 2.0 in VS2008, i can just use a newer, fancier and possibly better IDE for .net 2.0 Projects.

    I am pretty disappointed when I see the dialog popping up asking me to upgrade solution and warns me that it is not possible to use the solution in VS2005 unless I do some hacks with high risk

  6. Wayne says:

    This is great stuff!  Thanks for the info!

  7. .Net LIfe says:

    DJPark has written a great article on transferring and sharing Visual Studio projects between 2005 and

  8. I have to totally agree with Terry. I am in the same boat. By the way, the article above claims:

    "Projects created in Visual Studio 2008 can be opened in Visual Studio 2005 "

    but when I tried to open a test project created in VS2008 targeting .NET 2.0 in VS 2005, I got the following error:

    Unable to read the project file ‘ClassLibrary1.csproj’. D:ProjectsClassLibrary1’ClassLibrary1.csproj(42,11):The imported project "D:Microsoft.CSharp.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

    Is this something that only I am seeing or is that another hack that we need to do to get VS2008 projects open in VS2005?

    Any answer/help will be greatly appreciated.

    PS: By the way, can MS include a Copy button on these error dialogs or enable selecting of text.

    Thanks,

    Rupak Ganguly

    Solution Architect, Hewlett Packard

  9. Ok, now here is what I found further:

    1. If the project is created in VS2005, upgraded with VS2008 (it seems the upgrade report shows that no changes have been made to the project) – then this project can be opened in VS2005 back again without any errors as mentioned in my previous post.

    2. If the project is created in VS2008 and then opened in VS2005, the error mentioned above is seen.

    Thanks,

    Rupak Ganguly

    Solution Architect, Hewlett Packard

  10. On further investigation:

    VS2008 DOES change the project file when upgrading the VS2005 project.

    Here are the changes:

    1. Old: <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003&quot;>”>http://schemas.microsoft.com/developer/msbuild/2003&quot;>

    New: <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003&quot; ToolsVersion="3.5">

    This ToolsVersion controls the version for the build tools that are invoked.

    2. Old: Not present

    New:

       <FileUpgradeFlags>

       </FileUpgradeFlags>

       <OldToolsVersion>2.0</OldToolsVersion>

       <UpgradeBackupLocation>

       </UpgradeBackupLocation>

    Note: I guess left over from the upgrade process. But, notice the OldToolsVersion.

    3. Old: <Import Project="$(MSBuildExtensionsPath)MicrosoftVisualStudiov8.0WebApplicationsMicrosoft.WebApplication.targets" />

    New:   <Import Project="$(MSBuildExtensionsPath)MicrosoftVisualStudiov9.0WebApplicationsMicrosoft.WebApplication.targets" Condition="" />

    Note the version no. change.

    Thanks,

    Rupak Ganguly

    Solution Architect, Hewlett Packard

  11. Christopher Piggott says:

    Can you please confirm my understanding about something: It seems that it should be possible to have two different .sln files (one for VS2005 and one for VS2008) that share the .csproj files, and use one .sln if opening from VS2005 and the other from VS2008.  The only thing is, if you change the .sln in one (e.g. add a new CSPROJ) you would have to add it to the other yourself.  But, if the .csproj files are compatible, then for example adding a reference to a .csproj would mean it got seen by the other solution.  Correct?

  12. Bhavin says:

    Hey this sounds really helpful…let met try these options and see which one works out best… I have a vs2008  solution having 10 projects needed to be converted in vs2005… i have team of 30 people who are waiting for some easier way to migrate…so it would be great if any of these options works….

  13. Ken says:

    Rupak,

    Control-C will typically copy the text of an alert box to your clipboard, even when you’re unable to select the text.

  14. Mark Rodrigues says:

    Great article. Exactly what I was looking for although not happy with the answer (as I understand it).

    Can I paraphrase what I think the situation is:

    If I have a team of people working on a solution in VS2005 I can’t have a someone working on the same solution in VS2008.

    If I do then everyone working on 2005 will need to do a hack whenever someone using 2008 checks in their changes.

    It also means that as I add new members to my team I have to buy 2005 licenses unless I want to take the hit and upgrade the whole team to 2008.

    Have I got it right?

    Thanks again

    Mark

  15. Tulga says:

    Thank you guys, I had big problem on this.

  16. leem says:

    why ms do not provide a compatible mode for vs2005,that the vs2005 and vs2008 can smoke the calumet together.

    hope the next hot-fix can resolve this problem.

  17. Alexander Gnauck says:

    Thanks for this great article.

    This problem is very annoying. I hope Microsoft will fox this with an update and not change the format with the next VS version again.

  18. During the Heroes Happen Here events, I received a fair amount of questions regarding the combine use

  19. ASP.NET 2.0 Guest Book – VS 2008 on Vista

  20. Wayne John says:

    How to use solutions and projects across VS 2005 and 2008

  21. Notes on upgrading to Visual Studio 2008 from VS2005

  22. Konovalov says:

    I have same same troubles so, afetr below change in csproj file my VS2008 project can be compiled in VS2005

    So, here we are

    before my change:

     <Import Project="$(MSBuildBinPath)Microsoft.CSharp.targets" />

    after my change:

     <Import Project="$(MSBuildBinPath).Microsoft.CSharp.targets" />

    and it works.

    thx

  23. SkinFeature is a custom skinning implementation library and GUI design tool available as DLL and .NET components. It allows you easily to create skins . this skin creator supports MS Visual C ++MFC(5.0, 6.0, vs2002, vs2003, vs2005, vs2008), MS Visual Basic, Delphi, Windows Forms (.NET), WTL, ATL, ,and all Win32 languages that support COM objects. The SkinFeature GUI design tool offers flexible controls customization for all Windows elements.

    This IS Visual Skin Builder Tool

    skin preview:

    SkinFeature developer library improves the visual appearance of your applications by adding originality and uniqueness.

    SkinFeature developer library is a powerful library that changes the visual appearance of windows or dialogs, providing developers with full-featured support for ‘application skins’, or ‘application look and feel’. Skinfeature makes it easy to create programs with visually stunning, fully interactive user interfaces.

    When it comes to impressing your clients and your software users, nothing is more helpful than SkinFeature skin creator software. With innovative features and superior simplicity of use, you’ll agree that no other GUI design tool comes close.

    features:

    With SkinFeature you could make your program look exactly like it was from another OS, or create your own user WinAmp-like "skinned" interfaces, or just give it a different, distinctive look.

    ¦ support all Windows standard control

    ¦ support Windows 98/NT4/2000/XP/2003

    ¦ support MFC/WTL/SDK/VB/DELPHI/.NET/WIN32COM

    ¦ support MDI/SDI/Dialog/Shape style window

    ¦ support Windows’s common dialog

    ¦ support custom control

    ¦ support UNICODE

    ¦ WYSWYG skin editor

    ¦ include all source

    WEBSite:  http://www.skinui.com

  24. jamespaterson says:

    FYI this does not work for C++ projects – Bah.

    "The following error has occurred during XML parsing:

    File: C:OxscanProductionMatrixLibrary_TestMatrixLibrary_Test.vcproj

    Line: 10

    Column: 2

    Error Message:

    ‘9.00’ violates enumeration constraint of ‘7.00 7,00 7.10 7,10 8.00 8,00’.

    The attribute ‘Version’ with value ‘9.00’ failed to parse."

    I code in visual C++ which frankly has seen appalling support in visual studio over the last few years. The lack of backwards compatibility is clearly a transparent attempt to get us to spend money on upgrades. Sigh.

  25. TWS says:

    FYI on C++ projects:

    The schema can be found in

    c:Program FilesMicrosoft Visual Studio 9.0VCvcpackagesVCProjectEngine.dll as a resource.

    Search for <xs:enumeration value="7.00" /> in plain text (not unicode)

    If you want to force opening the new projects, edit the schema with a resource editor.

  26. Ingo Bleile says:

    Does anyone know whether or not it is necessary to change the references version numbers in the cproj-File after converting a project from 2005 to 2008? Currently, my references looks like that:

    <Reference Include="Microsoft.SqlServer.Smo, Version=9.0.242.0 …>

    and I still get an "This SQL Server Version (10.0) is not supported." error when trying to connect to an SQL Server 2008 database. Is the .cproj-entry "ToolsVersion="3.5"" enough to distinguish .net 2.0 and 3.5 components or is it necessary to do manual corrections?

  27. poorani says:

    Web deployment to the local IIS server is no longer supported. The Web Deployment build tool has been removed from your project settings.

    This application has been updated to include settings related to the User Account Control (UAC) feature of Windows Vista. By default, when run on Windows Vista with UAC enabled, this application is marked to run with the same privileges as the process that launched it. This marking also disables the application from running with virtualization. You can change UAC related settings from the Property Pages of the project.

  28. poorani says:

    Hi, i got this error while importing  vc.net project from vs2005 to vs2008:::

    Web deployment to the local IIS server is no longer supported. The Web Deployment build tool has been removed from your project settings.

    This application has been updated to include settings related to the User Account Control (UAC) feature of Windows Vista. By default, when run on Windows Vista with UAC enabled, this application is marked to run with the same privileges as the process that launched it. This marking also disables the application from running with virtualization. You can change UAC related settings from the Property Pages of the project.

  29. aruna says:

    Hi

    This is great article. I had a problem to open VS 2008 project in VS 2005, it was showing me "Unable to read the project file ‘ClassLibrary1.csproj’. D:ProjectsClassLibrary1’ClassLibrary1.csproj(42,11): The imported project "D:Microsoft.CSharp.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk."

    I changed my project properties file with the following attributes:

    1. Change <Project ToolsVersion="3.5" to <Project   ToolsVersion="2.0"

    2. Change

    <Import Project="$(MSBuildExtensionsPath)MicrosoftVisualStudiov9.0WebApplicationsMicrosoft.WebApplication.targets" />

    to

    <Import Project="$(MSBuildExtensionsPath)MicrosoftVisualStudiov8.0WebApplicationsMicrosoft.WebApplication.targets" />

    Now I can open my project with VS2005

  30. A small tool to allow you to covert your projects…

    I added it as a post build event to my vs2008 project

    using System;

    using System.Collections.Generic;

    using System.Text;

    using System.IO;

    using System.Xml;

    namespace VS2008ToVS2005

    {

       class Program

       {

           static void Main(string[] args)

           {

               if (args.Length == 2)

               {

                   if (File.Exists(args[0]))

                   {

                       XmlNamespaceManager nameSpaceManager = null;

                       XmlDocument doc = new XmlDocument();

                       doc.Load(args[0]);

                       nameSpaceManager = new XmlNamespaceManager(doc.NameTable);

                       nameSpaceManager.AddNamespace("msb", @"http://schemas.microsoft.com/developer/msbuild/2003&quot;);

                       //<Project ToolsVersion="3.5"

                       XmlElement el = doc.SelectSingleNode(@"//msb:ProductVersion",nameSpaceManager) as XmlElement;

                       if (el != null && el.InnerText == @"9.0.30729")

                       {

                           el.InnerText = @"8.0.50727";

                       }

                       el = doc.SelectSingleNode(@"//msb:Project", nameSpaceManager) as XmlElement;

                       if (el != null && el.Attributes["ToolsVersion"] != null)

                       {

                           el.Attributes.Remove(el.Attributes["ToolsVersion"]);

                       }

                       el = doc.SelectSingleNode(@"//msb:Import", nameSpaceManager) as XmlElement;

                       if(el != null && el.Attributes[@"Project"] != null)

                       {

                           el.Attributes["Project"].InnerText = @"$(MSBuildBinPath)Microsoft.CSharp.targets";

                       }

                       if (File.Exists(args[1]))

                       {

                           File.Delete(args[1]);

                       }

                       doc.Save(args[1]);

                       return;

                   }

               }

               Console.WriteLine("Usage :");

               Console.WriteLine("VS2008ToVS2005 <srcFile> <destFile>");

               Console.WriteLine("eg. ");

               Console.WriteLine("    VS2008ToVS2005 stuff_2k8.csproj stuff_2k5.csproj ");

           }

       }

    }

  31. catherine.sea@hotmail.com says:

    Thanks for the info.

    Catherine Sea

    http://www.dynamsoft.com

    http://www.scmsoftwareconfigurationmanagement.com

  32. Scott Evans says:

    I’m SSSSOOOOOOooooo TIRED of Microsoft compatibility issues. No wonder Gates is one of the richest people in the world.  What a piece of SH!!!!T.

  33. Absher Rashid says:

    Also dont forget to modify the following in .csproj file:

     <Import Project="$(MSBuildToolsPath)Microsoft.CSharp.targets" />

    TO

     <Import Project="$(MSBuildBinPath)Microsoft.CSharp.targets" />

  34. Dayananda says:

    Hi,

    I’m getting following warning after converting from Visual studio 2005 to 2008:

    Conversion Issues – setup.vcproj:

    Web deployment to the local IIS server is no longer supported. The Web Deployment build tool has been removed from your project settings.

    Project upgraded successfully.

    This application has been updated to include settings related to the User Account Control (UAC) feature of Windows Vista. By default, when run on Windows Vista with UAC enabled, this application is marked to run with the same privileges as the process that launched it. This marking also disables the application from running with virtualization. You can change UAC related settings from the Property Pages of the project.

    Please let me know is this breaks anything.

    Thanks for your reply.

    Daya

  35. Siddhesh Kumar says:

    We have a VS 2008 Sharepoint project, including use of workflows. I need to "migrate" this to VS2005, since my customer doesnt have 2008 🙁

    Can you please provide some urgent pointers on whether this will work, and what I can do to make it work?

  36. cs says:

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

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

  37. AndreaSA says:

    Thanks for the post!!! It helped me a lot!! I almost had a headache!

  38. dimi says:

    Thank, for the Good and detailed explanation,

    i’ve tested and it works

    Regards

  39. There was a relatively simpler solution while opening 2008 solution in 2005. Just rename current whatver.vcproj to whatever.vcprok.vc2008.old and there will be a whatever.vcproj.8.00.old in the same directory. Rename that to whatever.vcproj.

    That's it! Then open up the solution, say ok ok ok  if any errors pop up and finally your soution explorer will appear with your projects all grayed out. Right click each project and reload each one manually. Simple enuf!

  40. a says:

    some another stuff:

    austincodecamp08.googlecode.com/…/Visual%20Studio%202005%20and%202008%20coexistence

    looks like writing project conventer was not something impossible, microsoft could do it..