Saturday, March 12, 2011 deployment

How to deploy an web application?

If you are working for the corporate America , you will typically have a development, testing and production phase for every application that you have built. Of the many ways of deploying web applications out there, I find one way for each of these phases, that seems more well suited than the others. Lets go ahead and look into those.

Development server
This is an area where developers enjoy relatively more privileges than the other areas. Assuming you have rights to write onto shared folders on that server,this is how you do it. Share the folder that virtual folder in the IIS points to. Give yourself write permissions to the shared folder. From Visual studio, do what is shown in the images below


2>Type in the shared location

3> Click publish. You are good to go!

Staging or Production Server

This is an area where developers don't have much direct deployment access to. If you could send a deployable to who ever controls that server, that would work out as very convenient. Lets look into on such method. What I will do here is, I will show you a way to create an msi file, which could be either sent directly or with a batch file (to add a little bit more features).

Creating an msi

What you will do here is you will add a new web setup project to your solution. I think images here would make it a lot more quicker to follow

1>Add a new project to your solution

2>Choose Web Setup Project

3>View File system of the web setup project

4>Add project output to web application folder of the web setup file system

5>Add primary output and content files of the web application project

Now just compile the web setup project. You will find the msi file in the debug or the release folder of your websetup project (based on whether your project is set to debug or release).

Using a batch file to force reinstall

To to this, first change the version number of the deployment project to a higher number. (Select the deployment project and hit the F4 key). After you raise the version number,when it prompts you change the product number, click yes. Now generate the msi and use the batch file below to execute it.

Copy paste the bolded text below into notepad and save this file with a .bat extension

@echo off            
myMSIName.msi REINSTALLMODE=amus      >Output.txt      

In the above text replace myMSIName with the actual name of your msi.

Place this .bat file in the same folder as your msi. Then run the .bat file. The bat file runs your msi and forces a reinstall if a version of your website already exists on the server you are deploying to. (It saves you the trouble of uninstalling it manually.)

Further Reading:

ClickOnce Security and Deployment:

ASP.NET Deployment

VS 2010 Web Deployment

No comments:

Post a Comment

Comments will appear once they have been approved by the moderator