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 !!!

Print | posted on Tuesday, July 31, 2007 11:20 PM

Comments on this post

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

Requesting 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?
Left by rob on Sep 03, 2007 1:33 PM

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

Requesting Gravatar...
Thanks Harish - turned out to be that I needed to enter a licence key value for a redistributable library. Thanks for your response.
Left by rob on Sep 03, 2007 6:03 PM

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

Requesting Gravatar...
i am not finding any .msi file in realese folder..........wnt can i do now?
Left by sunil on Sep 15, 2007 12:14 AM

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

Requesting 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
Left by SOMASEKHAR on Dec 19, 2007 7:10 PM

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

Requesting 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
Left by SOMASEKHAR on Dec 19, 2007 7:24 PM

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

Requesting 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
Left by chetan on Jan 14, 2008 12:03 AM

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

Requesting 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
Left by Viswak Parthiban O K on Feb 13, 2008 2:47 AM

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

Requesting 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.
Left by tarique merajul haque on Feb 26, 2008 11:26 PM

# websetup deployement-creating an Installer File

Requesting 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
Left by mihika on Mar 02, 2008 10:30 PM

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

Requesting 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
Left by Arun on May 01, 2008 5:58 AM

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

Requesting 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
Left by Asaad Mamoun on May 20, 2008 12:52 AM

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

Requesting 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 ?
Left by Tarun Jain on May 20, 2008 11:57 PM

# How do I make a website live?

Requesting 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
Left by Robert on Jun 12, 2008 9:23 AM

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

Requesting 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
Left by Dotneter on Jul 21, 2008 8:23 AM

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

Requesting Gravatar...
Very Good One.

Thanks,
Swami.L
Left by Swami on Aug 02, 2008 2:29 AM

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

Requesting 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
Left by Omer on Sep 01, 2008 1:44 PM

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

Requesting 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
Left by Arpitha on Sep 22, 2008 4:32 PM

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

Requesting 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
Left by Ashley Fonseca on Oct 08, 2008 9:59 AM

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

Requesting Gravatar...
itz gonna b rockin' ....
Left by Wamiq Mustafa on Oct 15, 2008 4:28 PM

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

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

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

Requesting 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.
Left by COMtns on Jan 06, 2009 9:47 PM

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

Requesting Gravatar...
i get something , it is very nice
Left by veera raju on Feb 03, 2009 1:04 PM

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

Requesting Gravatar...
Thnks very nice article .. :)
Left by pshah on Apr 02, 2009 4:37 PM

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

Requesting Gravatar...
Very Nice and usful article. Thanks a lot.
Left by Shanmugam K on Apr 03, 2009 1:41 PM

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

Requesting 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_" %>
-^
Left by vivek on Jun 22, 2009 2:03 AM

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

Requesting 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
Left by rchi on Sep 10, 2009 1:22 AM

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

Requesting Gravatar...
THE BEST EWAY TO DEPLOY A ASP.NET SITE.MANY MANY......THANKS
Left by swastik on Feb 16, 2010 11:18 PM

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

Requesting Gravatar...
veryy goodd
Left by meksika biberi zayıflama hapı on May 31, 2010 11:58 PM

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

Requesting Gravatar...
SETUP & DEPLOYMENT WIZARD

How do we use it?

First of all, we have to select the ‘Other Project Types’ option from the New Project. Then, we get some options:

1)Setup Project: Creates a Windows Installer project to which files can be added. This project type is the most general of all.

2)Web Setup Project: The deployment tools in Visual Studio .NET also support deployment to a Web server. Using deployment to install files on a Web server provides an advantage over simply copying files, in that deployment handles any issues with registration and configuration automatically.

3)Merge Module Project: Most commonly, merge modules are used for files that are installed to a common location (such as the System folders) and/or shared by multiple applications. For example, many ActiveX and .NET controls that are sold by third-party tool vendors come with their own merge modules so that the developer can simply merge the installation logic of the control into their setup without worrying about having to manually specify the file’s information and setup logic.

4)Setup Wizard: Creates a Windows Installer project with the aid of a wizard.

5)Cab Project: The CAB project is a Setup and Deployment project, which is used to create a .cab file containing a set of files in a compressed archive. This .cab file is used to package ActiveX controls that can be downloaded from a Web server. The CAB project reduces the size of a distribution package. Using CAB project, developers can implement Authenticode signing and specify the display name, version, level of compression, and location of dependent files.

You can have a look at the Video Tutorial @

http://visiontechno.net/studymats/?cat=6

to see that how do we use Setup And Deployment Wizard.


Left by Akhil Gupta on Dec 28, 2010 4:11 PM

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

Requesting Gravatar...
I am working on web application which uses Fingerprint scanner to authenticate user.

I am using third party dll in my solution.

i want to copy these dll into client machine.

Which deployment option do i need to use in my solution?

Can you help me.
Left by Mohammed Abdul Kareem on Jul 19, 2011 1:19 PM

Your comment:

 (will show your gravatar)