Monday, May 15, 2006

ASP.NET 2.0 Deployment : Installer for updating Web.Config settings during Setup - Part I

Many of us are aware of ASP.NET deployment using Web Setup Projects. There are many articles that describe this.
Web.config forms a crucial part in any web application. When a Web Application is deployed in a client's place it becomes a brilliant idea to provide a UI for updating the Web.config settings.

In ASP.NET 1.1 this was quite straight forward, where you can directly use the assembly of the Web project and create Custom Actions in Web Setup. However, in ASP.NET 2.0 this is quite tricky. This is because of the compilation model of ASP.NET 2.0. By default the compilation model does not give any single dll that can be added to the Custom Actions of Web Setup.

For this reason, Microsoft has released a new Add-On called the Visual Studio 2005 Web Deployment Projects. Click here for more details and a free download.
Let us check how this Add-on can be help in our deployment, in a step by step fashion.

1. The First step is to install the Add-on from the link above.
2. Once you install the Add-on, right click on your Web Project. You will notice a new menu called Add Web Deployment Project.



3. On clicking this you will be prompted to give a name and location for this project. Give a proper name and location and click OK.The new Web Deployment gets added to your Solution.
4. Right click the new project and then click Property Pages.
5. In the Configuration Properties treeview, click Output Assemblies.

6. Select the Merge all outputs to a single assembly option, and give an assembly name, say MyAssembly.
7. Also check the Treat as library component checkbox and then click OK.
8. Build the Web Deployment project.
9. Now browse to the location of the Web Deployment project you added from Windows Explorer.
10. You will find that your asp.net pages along with Web.config are added to this folder. Also, there is a Debug\bin folder that contains the single assembly dll for your Web Application.

This is similar to the ASP.NET 1.1 compilation model. This makes the deployment of our ASP.NET 2.0 easy.
In Part II of this article, let us see how this can be integrated to update Web.Config during deployment.

6 comments:

tom said...

Good article - when will part two come out?

Biju S Melayil said...

This is really a Useful Blog. Thanks for this useful information which was really hard to find.. Thxs Laxmi.. Keep Blogging

Regards
Biju S Melayil

Vivek said...

Laxmi,

To create Web Setup Project in Asp.NET 2005, We need to add Web Deployment Project or not..

The problem is that at the time of creating a Web SetUp Project for Asp.NET 2.0, didn't found dll of the project and so Primary OutFile option in add project Output Group.

Edmundo said...

Thank you for your efforts in this article on web deployment. As you mentioned, deployment in 2.0 is tricky.

I followed your instructions and everything worked like a charm.

Again, thank you.

Param said...

Thanks,

Nice blog and it makes deployment easier.

Cheers,
Param

HAJASHAIK said...

I got while installation after i create web setup baser on this article

error is " Exception occured while intialiing the installation:System.argumentexception file userid=ss does not exist.If this parameter is used as an installer option,the format must be /key=[value] "