ASP.NET 2.0 Deployment - Deployment Options and choosing the right one for your need

Update : February 27, 2008

Mentioned the location where the MSI File gets created in case of Websetup Deployment owing to a lot of queries on the same in the comments.

Update: February 21, 2008

Posted a Video version of this article

http://geekswithblogs.net/ranganh/archive/2008/02/21/aspnet-2.0-msi-deployment-video.aspx

http://geekswithblogs.net/ranganh/archive/2008/02/21/asp.net-2.0-publish-website-deployment.aspx

http://geekswithblogs.net/ranganh/archive/2008/02/21/asp.net-2.0-precompilation-utility-for-deployment.aspx

Well, you developed a web application.  You need to deploy it.  With ASP.NET (1.x versions), Visual Studio .NET provided simple way to create setup files for your web applications to make it install as if it were a stand alone application.  The whole process was simplified when using Visual Studio .NET 2003's Setup and Deployment Wizard.  So with ASP.NET 2.0 and Visual Studio 2005, what is new and what are the different Deployment Models available?  Let us explore them one by one.

Web Setup Deployment - Creating an installer file

This option hasnt changed a lot when compared with Visual Studio .NET.  Let us explore the steps.

1. Open your website in Visual Studio 2005

2. Right Click on the Solution Name (Solution 'Your solution') and select "Add - New Project".  The "Add New Project" dialog appears.  Select "Other Project Types" and expand the same.  Select "Setup and Deployment" and in the available Templates select "Web Setup Project" and provide a name ex. "WebSetup1"  to create the project in the location of your choice

3. Right Click on the "WebSetup1" created above and choose "Add - Project Output"  You would be able to see it lists out the available project in the "Project" dropdown.  The only option you would find here is "Content Files".  Here is where you find the difference.  In Visual Studio .NET and ASP.NET 1.x verions you would need to add "Primary Output" option which is the assembly created for your Website.  Here in ASP.NET 2.0 there is no default Website Assembly (in other words DLL File and BIN Folder) unless you explicitly create a BIN folder.  Hence you just need to select "Content Files" which will bundle up ASPX, Codebehind, Resource Files, Images, Folders etc.,  Thereafter you can choose to add a "ReadMe.txt" or something that you require by again choosing "Add" but I leave it you as it is completely optional. 

Once you are done with adding the required Project Output, Right Click on the "WebSetup1" project and "Build" it.  It would create the installer file (MSI File) that can be used for installing your application on different machines.

Make sure you select "Release" Mode in Visual Studio 2005 before creating the Web Setup since that would optimize the binaries for performance.

A lot of people get back to me saying that they couldnt find the MSI File Created.  There are two reasons why your MSI file creation was unsuccessful.

1. You chose File - New Project - Setup and Deployment instead of File - Add New - Project - Setup and Deployment.  The former one creates a new project with just a websetup.  The latter creates the web setup project under the same solution and allows you to add the website output to the web setup

2. The MSI File typically C:\Documents and Settings\<username>My Documents\Visual Studio 2005\Projects\<your Web Project folder>  This is even if you had created the website in c:\inetpub\wwwroot because the Solution File typically gets created in the C:\Documents and Settings\<username>My Documents\Visual Studio 2005\Projects\ path unless you modify it.  A lot of us could just over see it when creating the project/solution and generally we dont need the solution file so dont bother to look for it.  In the case of deployment the MSI File also sits in the same location where the solution file is created and hence this step would help you identify the same.

Website Publish Wizard Deployment

Visual Studio 2005 also provides you with a  new "Web Publish Wizard" option where you can publish your websites files to a different machine / directory to a HTTP / FTP or a file share of your choice.  Exploring the steps

1. Right Click on your Web Project and select "Publish Web Site".  It will prompt you with a "Publish Web Site" dialog where you can specify the path to be published.  You can do a variety of options like "Allow this precompiled site to be updatable".  What it means is that, the website is precompiled and the codebehind source get into a BIN directory that is created. 

2. The ASPX pages, Images etc., and other markup files are copied to the location specified AS IS.

3. You would also find a PreCompiledApp.Config file.

This option is pretty handy if you keep updating the site to a Staging Server on a regular basis since it wouldnt be feasible to create an MSI installer everyday / everytime you want to deploy your files.

Copy Website Deployment

The Copy Website provides you an option to simply copy the source files to a destination folder which can either be on your local machine or an FTP / HTTP Location.  The difference in this case is that, the Website is not precompiled.  Your Website is copied AS IS and all the files include the code behind files are copied to the destination.  However, the Copy Website Deployment does more than merely copying them.  When you use Copy Website option it shows the status of the files in the Source and Destination location and you can synchronize them using the "Synchronize" option that would help you maintain similar versions in different locations.  Steps herebelow

1. Select your Website Project, Right Click and select "Copy Website"

2. It provides with you an interface listing the "Source" in the left and provides you the option to "Connect" using the "Connect" option to specify the destination.  However, it can also be vice versa since you can select "Source" to be your destination location and do a copy back to your local folder as well. 

3. The "Synchronize" button helps you to keep the files synchronized.  There is also a Log that is created which can be viewed from this interface.  In simple terms Copy Website Deployment is deploying the files as is with source/destination file synchronization.

PreCompiled Web Deployment

With all of these options above, you also can manually precompile the whole application using the PreCompilation tool installed with ASP.NET 2.0.  Steps herebelow:-

1. Type "cmd" from Run command to open the Command Prompt

2. Navigate (Change Directory - cd) to %windir%\Microsoft.NET\Framework\v2.0.50727

3. Type aspnet_compiler -v /"Your Website Name" -p "Physical Path to your site"  "Physical Path to Deployment Location"

4. An ideal example of above would be aspnet_compiler -v /Website1 -p "D:\Projects\Website1" "D:\PreComiled Website1"

5. There are multiple switches which you can try in the above command.  You can verify all the options by typing aspnet_compiler -? from %windir%\Microsoft.NET\Framework\v2.0.50727\

Once you run the above command you would notice that in the Deployed location, all the files including ASPX, ASCX are precompiled and dont contain any markup.  If you try opening an ASPX Page, you will only find the text "This is a marker file generated by the precompilation tool, and should not be deleted!"  and it doesnt contain any HTML markup.  This way the site is totally precompiled and can also prevent any one from viewing the source code.  You need to specify the "-u" keyword in the above command before the target directory specification, to make this site updatabale. 

When to choose what?

Ok, we saw a variety of options on how we can deploy ASP.NET 2.0 applications and a variety always brings in question on when to use what.

While it is absolutely specific to your customer needs or personal preference, an informal thumb rule I would suggest is as follows.

1. Web Setup Installer for major releases which are not frequently updated.

2. Publish Website for day to day update and staging servers where you want source code (code behind / App Code) contents to be concealed by precompiling.

3. Copy Website where you want to do day to day update and synchronization with staging servers where you dont worry about source code being able to be viewed.  In other words a simple X Copy with synchronization features.

4. Precompilation using the aspnet_compiler command utility when you want to precompile both the source as well as markup files seeking high performance, security features.

In this article we saw various options for deploying ASP.NET 2.0 Applications.  I hope you found it beneficial.  If you have queries please post in comments.

The following articles also provide more information on customizing the ASP.NET 2.0 MSI Deployment Model

http://lakshmik.blogspot.com/2006/05/aspnet-20-deployment-installer-for.html

http://lakshmik.blogspot.com/2006/06/aspnet-20-deployment-installer-for.html

http://lakshmik.blogspot.com/2006/09/aspnet-maintaining-versions-in-web.html

Cheers !!!

posted @ Tuesday, July 31, 2007 11:20 PM

Print

Comments on this entry:

# re: ASP.NET 2.0 Deployment - Deployment Options and choosing the right one for your need

Left by rob at 9/3/2007 1:33 PM
Gravatar
Hi Harish, I followed your instructions "Web Setup Deployment - Creating an installer file" but no .msi file is being created (that I can find). Any ideas what I might be doing wrong?

# re: ASP.NET 2.0 Deployment - Deployment Options and choosing the right one for your need

Left by rob at 9/3/2007 6:03 PM
Gravatar
Thanks Harish - turned out to be that I needed to enter a licence key value for a redistributable library. Thanks for your response.

# re: ASP.NET 2.0 Deployment - Deployment Options and choosing the right one for your need

Left by sunil at 9/15/2007 12:14 AM
Gravatar
i am not finding any .msi file in realese folder..........wnt can i do now?

# re: ASP.NET 2.0 Deployment - Deployment Options and choosing the right one for your need

Left by SOMASEKHAR at 12/19/2007 7:10 PM
Gravatar
hi harish

i am very thank ful to u .

i follow ur instructions but i dont find any .msi file

whats the problem i cant understand

pls help me

# re: ASP.NET 2.0 Deployment - Deployment Options and choosing the right one for your need

Left by SOMASEKHAR at 12/19/2007 7:24 PM
Gravatar
hi harish

i am very thank ful to u .

i but i dont find any .msi file

whats the problem i cant understand

pls help me

# re: ASP.NET 2.0 Deployment - Deployment Options and choosing the right one for your need

Left by chetan at 1/14/2008 12:03 AM
Gravatar
I want the steps for creating setup and deplyment of web project.
all the required information like adding the folders eq. global assembly folder etc

all the information
please

# re: ASP.NET 2.0 Deployment - Deployment Options and choosing the right one for your need

Left by Viswak Parthiban O K at 2/13/2008 2:47 AM
Gravatar
Hi Harish,
I am using "Web Setup Deployment - Creating an installer file", everything is working fine.
Even MSI is created successfully and installing is also successful.
But only one issue is that all code behind files are also present in installed folders.
How can i avoid it or is there any other way to do it.
Please help me.

Thanks in advance.

Regards,
Viswak Parthiban O K

# re: ASP.NET 2.0 Deployment - Deployment Options and choosing the right one for your need

Left by tarique merajul haque at 2/26/2008 11:26 PM
Gravatar
hi,
Thanks a lot to give the step. but i didn't get the .msi file.please help me how will i create the setup and how will i do the testing.

# websetup deployement-creating an Installer File

Left by mihika at 3/2/2008 10:30 PM
Gravatar
I have choosen the method of installer file,
and successfully installed the package but the problem here is .. i am trying to run the application on the intranet but during this i got two errors ..
1.con.open (when i choose the custom error="off")//ie. in opening the connection with the sqlserver 2000 and
2. if custom error ="on/remote only" then in web.confin file i got ..
custom error mode ="remote only"
if someone can sought it out plz tell me the right way
thank you

# re: ASP.NET 2.0 Deployment - Deployment Options and choosing the right one for your need

Left by Arun at 5/1/2008 5:58 AM
Gravatar
Hi
I am using "Web Setup Deployment - Creating an installer file", everything is working fine.
Even MSI is created successfully and installing is also successful.
But only one issue is that all code behind files are also present in installed folders.
How can i avoid it or is there any other way to do it.
Please help me.

Thanks in advance.

Regards,
Arun

# re: ASP.NET 2.0 Deployment - Deployment Options and choosing the right one for your need

Left by Asaad Mamoun at 5/20/2008 12:52 AM
Gravatar
Hi there

It's a very good article and you expalined almost everthing Thanks.

I finished developping a website and i used Copy Website method . When i upload them to the website using ftp it always shows me the Error

"Compiler Error Message: CS0246: The type or namespace name 'PrtClass' could not be found (are you missing a using directive or an assembly reference?)"

now i lost about 2 days trying to figure out what to do and how to fix this error .

some details:
1- when i want to add new class it force me to add it under app_code and i obey :).

2- i put all of the project under one namespace .

3- the classes that i'm using it's a simple .cs clasees with no dll files to refference.

now what should i do ? Thank you very much

www.dalelkonline.com/aa/names.aspx

this is a dummy site i created to test this problem .

Asaad Mamoun

# re: ASP.NET 2.0 Deployment - Deployment Options and choosing the right one for your need

Left by Tarun Jain at 5/20/2008 11:57 PM
Gravatar
I am creating a MSI file using websetup project in vs2005. I am also using the Web Deployment project to create a single assembly.
It is taking a lot of time while packaging files into MSI file. I do not know why it is happening.
Can you please help me out ?

# How do I make a website live?

Left by Robert at 6/12/2008 9:23 AM
Gravatar
By live, I mean where it can be accessed on the internet.

I am an old Windows Application developer. When I started my current job as a windows application developer, I inherited an existing website. Over the past five years I have worked on my this website. I have no problem building web applications for this website.

My problem is, the site had already been set up before I got here. My predissesors left no notes or instructions on what they did. I would like to know how it’s done. How does it go from the web server out to where it is accessed on the internet? Is it something I need to by a book for?

I would like to move my website from our old server to the new one. I would also like to upgrade it from .net 2002 to .net 2005, but those are other topics.

Robert

# re: ASP.NET 2.0 Deployment - Deployment Options and choosing the right one for your need

Left by Dotneter at 7/21/2008 8:23 AM
Gravatar
Hi All,
Any one Please explain me how to publish single aspx page. I have published and deployed my website it is working fine, i got some feed back from my client to change couple of aspx files.
Now i have fixed
In this situation how do i publish that particular error fixed pages.

thanks
Prabu

# re: ASP.NET 2.0 Deployment - Deployment Options and choosing the right one for your need

Left by Swami at 8/2/2008 2:29 AM
Gravatar
Very Good One.

Thanks,
Swami.L

# re: ASP.NET 2.0 Deployment - Deployment Options and choosing the right one for your need

Left by Omer at 9/1/2008 1:44 PM
Gravatar
Hello,

I am new to asp.net. I am working on Visual Studio 2005; I have made a simple page with a Access Data Source and a Data Grid with bound columns. Everything is working well. Now I want to test it by running it via IIS; I have made a Virtual Directory and also have shared the folder where I have placed my published project; but when I browse the page from IIS it gives an error that the directory doesn't exist or is not created ?

Any suggestions would be encouraging.

Thanks In Advance

Omer

# re: ASP.NET 2.0 Deployment - Deployment Options and choosing the right one for your need

Left by Arpitha at 9/22/2008 4:32 PM
Gravatar
Hi all..Very Gud article..i have created the setup file..everything is working fine..But that websetup includes all Source code files..How to do Websetup wihtout source code files..

Thanks

# re: ASP.NET 2.0 Deployment - Deployment Options and choosing the right one for your need

Left by Ashley Fonseca at 10/8/2008 9:59 AM
Gravatar
Hi, I have build my msi file. But my problem is wehn i execute msi file, the default name of Virtual Director is "WebAppDeployment". How can i change this Virtual Director name from installer so that it says name of product?

Thanks

# re: ASP.NET 2.0 Deployment - Deployment Options and choosing the right one for your need

Left by Wamiq Mustafa at 10/15/2008 4:28 PM
Gravatar
itz gonna b rockin' ....

# re: ASP.NET 2.0 Deployment - Deployment Options and choosing the right one for your need

Left by RR at 10/24/2008 2:38 PM
Gravatar
I copied the msi files on to the serevr. Now how can i run my application...

# re: ASP.NET 2.0 Deployment - Deployment Options and choosing the right one for your need

Left by COMtns at 1/6/2009 9:47 PM
Gravatar
Thanks much for the info. I am wondering if there is a way to rebuild/publish only the dlls that should change based on which codebehind files have changed? I have chosen the "single page assemblies" option while publishing the web site since we wanted multiple dlls. The problem is that each time I rebuild/publish it creates/overwrites ALL dlls, even for the pages that didn't change.

# re: ASP.NET 2.0 Deployment - Deployment Options and choosing the right one for your need

Left by veera raju at 2/3/2009 1:04 PM
Gravatar
i get something , it is very nice

# re: ASP.NET 2.0 Deployment - Deployment Options and choosing the right one for your need

Left by pshah at 4/2/2009 4:37 PM
Gravatar
Thnks very nice article .. :)

# re: ASP.NET 2.0 Deployment - Deployment Options and choosing the right one for your need

Left by Shanmugam K at 4/3/2009 1:41 PM
Gravatar
Very Nice and usful article. Thanks a lot.

# re: ASP.NET 2.0 Deployment - Deployment Options and choosing the right one for your need

Left by vivek at 6/22/2009 2:03 AM
Gravatar
i get this error every time i run page from iis.. plz help
A name was started with an invalid character. Error processing resource 'file:///C:/Documents and Settings/hay/Desktop/vive...

<%@ page language="C#" autoeventwireup="true" inherits="_Default, App_Web_zdqkg_h_" %>
-^

# re: ASP.NET 2.0 Deployment - Deployment Options and choosing the right one for your need

Left by rchi at 9/10/2009 1:22 AM
Gravatar
Hi there,

i have created a webset up successfully ,
i am writing the webconfig file while installing for that i am accepting the database name from user through textbox(A) even this works fine but my problem is
even if i leave the textbox(a) blank it prcess then fail
i want to make validation for this textbox(a) that is if this textbox is blank then it shuld not process further or pop up with message asking user to fill the textbox

please help
thanx

Your comment:



 (will not be displayed)


 
 
 
 
 

Live Comment Preview:

 
«November»
SunMonTueWedThuFriSat
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345