Wednesday, September 17, 2014

Migrating a Visual Studio 2003 ASP.NET Project to Visual Studio 2013 and IIS Express

Recently I had to migrate a Visual Studio 2003 ASP.Net project to Visual Studio 2013. I know, so many questions… why hadn’t this project ever been migrated in the past, how did a project survive so long without getting migrated, how is this guy still employed, etc. All great questions. The simple answer is that I had some old projects on an old XP machine that gave up the ghost. I therefore had to migrate the projects to another machine where I had Visual Studio 2013 using IIS Express installed.

Like any good developer, I did not research what issues I might face in making such a leap forward. I just went ahead and tried to open the old project in Visual Studio 2013, hoping that the Microsoft engineers who designed Visual Studio would have had the forethought to imagine that someone would try something so ridiculous. However, after 20 seconds of Visual Studio contemplating what to do with my request, it responded with an error messagebox stating the following:


The operation could not be completed. The system cannot find the path 
specified.

Not very helpful. Fortunately, after clicking OK on the above message, the Migration Report (updatelog.htm) opened automatically and provided me with the following error that was a little more useful:

MyProjectName.csproj: Could not find the server 'http://localhost/MyProjectName/MyProjectName.csproj' on the local machine. Creating a virtual directory is only supported on the local IIS server.


Kind of made sense. I was moving from a development environment that used IIS 6 to one that used IIS Express. A Google search of that error yielded many results, but none that were specific to migrating a project and pertinent to my situation. So instead I rooted around my project's files to figure out where it was picking up the virtual directory information and quickly found the project’s .webinfo file (i.e., MyProjectName.csproj.webinfo). The .webinfo file (something I never really paid attention to before) is a developer specific file that keeps track of the project’s virtual root location. It's contents look like this:

<VisualStudioUNCWeb>
    <Web URLPath = "http://localhost/MyProjectName/MyProjectName.csproj" />
</VisualStudioUNCWeb>

So I threw caution to the wind and experimented. I renamed the .webinfo file (e.g. @ MyProjectName.csproj.webinfo) and tried to open the .csproj file again. This time Visual Studio 2013 quickly responded with the following informative messagebox:

You have completed the first step in converting your Visual Studio .NET 2003 
web project. To complete the conversion, please select your project in the 
Solution Explorer and choose the 'Convert to Web Application' context menu 
item.

The Migration Report that followed additionally gave a few warnings regarding making “non-functional changes without impacting project behavior”. But everything seemed to work fine when I attempted to run it and, as it turned out, there was no need to convert the project to a web application.

However, when running the project, the pages were running from the root of localhost rather than in a virtual directory like I was used to seeing in the VS2003 development environment. As an optional step, this simply required editing the Project URL (e.g. adding MyProjectName to the URL) from the project's properties Web tab (i.e. right-click the project, select Properties and then the Web tab) and clicking the Create Virtual Directory button.

Next stop for my migrated project: refactoring EVERYTHING.

3 comments:

  1. Good information about converting visual studio 2003 to visual studio 2013.
    Useful information.

    ASP to ASP.Net Migration

    ReplyDelete
    Replies
    1. Glad that you found it useful... thanks for commenting!

      Delete
  2. Thanks! This helped me a lot.

    ReplyDelete