In earlier post, I have explained the motives behind converting web site (WSP) to web application (WAP). In this post I will detail the steps of conversion.
Before talking about steps, it is important to mention that, steps listed below are for a web site that is located in Team Foundation Server (TFS) 2010 repository. So, when converting, we need to make sure, the source history is also carried out.
Preparation on current WSP:
- Make a conversion plan and Inform your team members.
- Clean-Up: Remove all garbage stuff in WSP, if any.
- Services: Add service references from service location.
Steps for conversion:
- Create a branch from the team project your WSP located in. I named it ‘TP2’ here for reference purposes.
- Create a web project and solution named. I named it ‘WAP.Web’ for reference purposes.
- Add a new class library project called WAP.Web.Library.
- Add a new folder called "Assemblies" into root level, then add a new folder called "3rdParties" here. Add all 3rd party references into 3rdParties folder, all other dll referenced by the project here.
- Run tfs command, "tf move $/TP2/Old_WebSiteCode/* $/TP2/WAP.Web/WAP.Web to move files into new project along with their history.
- Run tfs command, "tf move $/TP2/WAP.Web/WAP.Web/App_Code/* $/TP2/WAP.Web/WAP.Web.Library" to move files into new project along with their history. It is a good practice to place all the files located in App_Code folder in WSP into a class library project.
- Build WAP.Web.Library
1- Include all folders into the project.
2- Add references from dlls in Assemblies and/or 3rdParties folders.
3- Add web references by giving service locations for each service used in the application.
4- start fixing error one by one till built succeeded.
8- Build WAP.Web:
1- Include all folders into the project.
2- Add references from dlls in Assemblies and/or 3rdParties folders. Build it, make sure you have errors only related to "missing …designer.cs files".
3- Run "Convert to Web Application" from VS 2010
4- Start fixing error one by one till built succeeded.
Once, it is all good, you may strengthen more your project structure by adding namespaces in CodeBehind files.
Conclusion
The most common issues in converting web site to web applications are missing assembly references, missing namespaces, incorrect @CodeBehind directives on .aspx and .ascx files.
References