Upgrading an existing solution

It's always nice to start a new project and if you've been working with legacy code for a while there's no better feeling! Unfortunately that feeling is often all too rare and we spend most of our time dealing with existing code with a long history.

All that legacy code is probably what's keeping you employed, so what you really want is to be able to open up that existing code in your shiny new copy of Visual Studio 2012 and bring the power of Visual Studio 2012 to bear on it, making life just that little bit easier for yourself.

One of the big changes in Visual Studio 2012 is that projects opened in Visual Studio 2012 are also backwards compatible with Visual Studio 2010 Service Pack 1 and we will see how that works. This process is called round tripping.

The good news for teams is that round tripping means they can gradually move from Visual Studio 2010 to Visual Studio 2012 as and when they are ready. They won't have the problems of the past where one team member checks in an upgraded solution file to source control, thus forcing the rest of the team to upgrade simply to continue working.

Getting ready

If you don't have any existing code you want to use you can use the sample Visual Studio 2010 solution we've prepared for you.

Note

The solution we will be using throughout this chapter is called VS2010_Web and can be found at Chapter 1/VS2010_Web.

If you are going to use some of your existing code, ensure that the current code is in source control or that you have backed up the code.

In order to see the backwards compatibility in action you will need Visual Studio 2010 with Service Pack 1 installed on your machine.

How to do it...

  1. Using either the Open Project link on the Visual Studio start page or the File | Open | Project/Solution menu select the VS2010_Web solution to start the conversion process.
  2. Visual Studio will automatically migrate the solution and all the projects within it. When the process is complete you will be shown a migration report.
    How to do it...
  3. Close the report when you have finished looking at it.
  4. From Solution Explorer open the Default.aspx file in the VS2010_Web project and change the Welcome to ASP.NET! text on the page to Welcome to Visual Studio 2012!.
  5. Build and run the project to see that the application is working as expected.
  6. Close Visual Studio 2012 and open Visual Studio 2010 with Service Pack 1.
  7. Open the VS2010_Web solution and run the application.
  8. You should see the web application appear, showing the updated message from Visual Studio 2012.

How it works...

The Visual Studio team worked with the various language and development product teams to ensure that project file formats would work consistently between Visual Studio 2010 and Visual Studio 2012. The first stage of these changes rolled out publicly with the release of Service Pack 1 for Visual Studio 2010, allowing Visual Studio 2010 to understand the new project formats.

When Visual Studio 2012 opens a Visual Studio 2010 project it will automatically upgrade the project format unless those changes will affect the ability to open the project in Visual Studio 2010. Any compatibility breaking changes will cause a dialog to be shown describing the changes and you can decide what action to take.

Note

Visual Studio 2012 will also upgrade projects created in Visual Studio 2008 and Visual Studio 2005, however round tripping of those projects is not supported. Likewise, the opening of a Visual Studio 2012 upgraded project in Visual Studio 2010 without Service Pack 1 is not supported.

There's more...

Not all project types will work with round tripping.

Visual Studio database projects

Visual Studio database projects aren't supported for round tripping. Visual Studio 2012 obsoleted Visual Studio database projects and replaced them with the new SQL Server Data Tools (SSDT) projects. When you open an old database project in Visual Studio 2012 you can upgrade it to an SSDT project. This project format also supports round tripping. However, if you wish to open an SSDT project in Visual Studio 2010 you will need to install the SQL Server Data Tools separately. You can download the tools from http://msdn.microsoft.com/en-us/data/hh297027.

ASP.NET MVC 2 projects

Visual Studio 2012 ships with support for both ASP.NET MVC 3 and ASP.NET MVC 4 projects. ASP.NET MVC 2 projects are not supported for round tripping in Visual Studio 2012 and therefore you will need to upgrade your MVC 2 projects to MVC 3 projects before opening them in Visual Studio 2012.

To help with the upgrade process you can use the ASP.NET MVC 3 Application Upgrader available from the ASP.NET Codeplex site at http://aspnet.codeplex.com/releases/view/59008.

Silverlight 3 and earlier

In a similar manner to ASP.NET MVC 2 projects, Silverlight 3 projects and prior will not be supported for round tripping with Visual Studio 2012. You will need to upgrade these projects to a later version of Silverlight first.

Visual Studio 2012 supports both Silverlight 4 and Silverlight 5 projects and you will be prompted for the version of Silverlight to use when you create a new project.

See also

  • The Using the new SQL Server Data Tools recipe in Appendix,Visual Studio Pot Pourri
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.47.144