CHAN - Bloat free ASP.Net
Introduction | About | Roadmap | Changelog | Licensing | Reference | Download | Guides: Windows , Linux/Mono , Building
Building
This article outlines how to build with Visual Studio Express, but it's worth remembering that Chan is compatible with the ASP.Net 2.0 /App_Code/ folder, so you may not need to compile at all. The old guide on how to build using the .Net 2.0 SDK is archived here, but is no longer supported (the old builds used to come with batch files to facilitate this).
To start with download and install Visual Studio Express from here:http://www.microsoft.com/express/Downloads/. You can download any version or edition as the steps are all essentially the same but we recommend the 2010/C# edition, and this assumes you are using that. It needs registering, but Microsoft will give you a registration key for free in exchange for your email address, it only takes a minute. Download the latest Chan_Clean site from here and follow the Installation Guide to get it running.
For this tutorial we are going to build a DLL rather than use the /App_Code/ folder, we're going to assume everything is still under c:\inetpub\wwwroot\Chan_Clean\ but you can use any application dir you want. Chan's controls do not have Visual Studio design mode support, but may do in the future. To build a Chan site you instead hand craft your ASPX and ASCX markup and then reference page classes in the DLL (or /App_Code/ folder). This allows you to retain complete control of the HTML with the added benefit of making it easy to have multiple pages reference the same codebehind page class.
First rename the /App_Code/ folder to /_Solution/ so that IIS does not try to dynamically compile the contents on the fly. Start Visual Studio Express and create a new "Class Library" project in this directory. This part is more complicated than it needs to be, unfortunately. First create the project, we suggest you name it the same as your Application Dir and Namespace, here the project name is "Chan_Clean" - it wont ask you where to save it all on disk yet.
As soon as it's finished creating the project go to "File > Close Solution", it will popup a message box asking if you want to save or discard. Click "Save". The next dialog will allow you to choose where to save, so navigate to c:\inetpub\wwwroot\Chan_Clean\_Solution\, untick the "Create directory for solution" checkbox and hit "Save".
Your woes still arent over as it will have still created at least one /Chan_Clean/ subdir under the /_Solution/ folder so navigate into there with windows explorer and move everything under c:\inetpub\wwwroot\Chan_Clean\_Solution\Chan_Clean\ into the parent dir, then finally delete the /Chan_Clean/ subdir and double click the .sln to reopen it in Visual Studio. The directory structure should look like the following:
Back in Visual Studio Express open the solution explorer (View > Other Windows > Solution Explorer) then select and delete the Class1.cs file. Right-click on the "Chan_Clean" project node and select "Add > Existing Item". Browse to and select Basic_Page.cs. Then right-click on the References node, select "Add Reference", on the popup window click .Net and select and add "System.Web" from the list. Right-click to add another reference, this time click browse then navigate up a dir into the c:\inetpub\wwwroot\Chan_Clean\bin directory and add Chan.dll. Finall right-click on the Chan reference and select "properties". Next select and delete the following four references: "Microsoft.CSharp", "System.Core", "System.Data.DataSetExtensions" and "System.Xml.Linq". You should be looking at something like this:
We need to change some build properties now so open "Project > Chan_Clean Properties" from the main Visual Studio menu, on the Application page there is a "Target Framework" drop down, change this to ".Net Framework 2.0". It will pop up a message with a warning, just click "Yes", wait, then reopen the project properties. Next you can create a post-build step to automatically copy the built DLL alongside the Chan DLL in the web application's /bin/ folder. Navigate to the "Build Events" page then click the "Edit Post-build .." button. In the popup window enter the following:
copy $(TargetPath) c:\inetpub\wwwroot\Chan_Clean\bin\
OK the dialog and close the project properties. Then press F6 to build, open windows explorer and you should see a shiney new Chan_Clean.dll in c:\inetpub\wwwroot\Chan_Clean\bin\. Open a web browser and load the localhost app to view the default page.
To prove to ourselves that this has really worked open Basic_Page.cs and enter a simple Page_Load function:
using System;
using Chan;
namespace Chan_Clean
{
public class Basic_Page : Chan.Page
{
protected override void Page_Load()
{
Response.Output.Write(DateTime.Now.ToString());
}
}
}
Press F6 to build, switch to your web browser and hit F5 and the current date and time should appear. All done!