Due to the different approach of creating a new web project in VS 2005, some tricks should be made to create a Sitecore project.
Firstly, you need to download and install
Visual Studio 2005 Web Application Projects (Beta V2 Preview)
Then you need to perform the following steps in order to get a similar functionality for working with Web Project like it was in VS 2003:
1. Start VS 2005 and create ASPNET Web Application:
Visual Studio creates solution and project only in subfolder now: /Test5203/Test5203/
2. Close project
3. Move project files (*.csproj.user and *.csproj,
Properties folder) to the Sitecore distributive root
4. Open the project (*.csproj file ) from the Sitecore distributive root.
5. Exclude the
default.aspx page from the project.
Now you can add necessary assemblies, include some layouts and sublayouts in project as it was before:
5. Make sure that Project Properties -> Ouput Type is
Class Library like it is shown
here.
6. In order to work with code behind class you should resort to some trick.
- Create a layout in Sitecore. Do not include one in the VS project
- Create WebForm in VS with the same name and overwrite the existing layout:
- Add missing directives at the top of the layout: <%@ OutputCache VaryByParam="none" Duration="100" %>
<%@ register TagPrefix="sc" Namespace="Sitecore.Web.UI.WebControls" Assembly="Sitecore.Kernel" %>
- If you want to work with code-behind class, you should replace the CodeBehind page attribute with the CodeFile attribute:
<%@ Page language="c#" Inherits="Viewstate.layouts.Main_Layout" Codepage="65001"
CodeFile="Main Layout.aspx.cs"%>
Well, that’s all. Now you can work in VS 2005 like it was in VS 2003 - compile, attach to ASPNET process, debug code etc.
Related reading:
- http://webproject.scottgu.com/
- http://webproject.scottgu.com/CSharp/Default.aspx
- http://webproject.scottgu.com/CSharp/HelloWorld/Helloworld.aspx
P.S. Great thanks to Alexander Tsvirchkov for the complete step-by-step instructions.
3 comments:
Quite a clear story :).
I guess the main problem with ASP.NET 2.0 is actually the new project structure. However the scottgu's initiative is a good one, I hope the Visual Studio Team will also come with a solution for Web-projects.
Alex: I heard that Microsoft is going to fully support Scott Guthrie's web app project as soon as its released - good comeback, at least.
We could not get it to work with the example provided for codebehind.
But if we changed
"Viewstate.layouts.Main_Layout"
to
namespace.class_name
then it works fine.
Post a Comment