Introduction:
In this article I will explain how to create setup file in visual studio 2008/2010 to deploy web application file directly in IIS or in client machine or how to place web application folder in c:\\inetpub\wwwroot folder by running setup file using asp.net.
If we want to deploy application in IIS we need prepare separate published files folder and create virtual path in IIS, point to our folder and need to change some properties to make it work through our IIS by doing all these things we will waste a lot of time.
Instead of doing all these things if we prepare one setup file and make it everything for us like prepare published folder, create virtual directory, set properties and create website in IIS just by simple install how is it? Nice right.
It is very useful for us many situations like suppose if we do one application for client we need to deploy that application in client machine instead of giving all the files and instructions to deploy it in his machine we just give one simple setup file and once he run that will deployed all files in IIS and site will create automatically with all properties in system.
To create Setup file for our application follow below steps.
Step1: First Open visual studio ---> Create new Project (File ---> New ---> Project)
After that open Default.aspx page and write some code like this
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Sample Page to Create Setup Files</title> </head> <body> <form id="form1" runat="server"> <div> <table width="50%"> <tr> <td> <p> <img alt="Aspdotnet-Suresh" src="https://lh5.googleusercontent.com/_B28NJpJ61hA/TdgnS7lh7mI/AAAAAAAAAi4/oLTicIRgEIw/FinalLogo.png"> </p> <p> Aspdotnet-Suresh offers Asp.net,C#.net,SQL Server,Web Services,WCF,WPF,MVC,Crystal Reports,AJAX,XML,JavaScript,JQuery,Gridview articles, samples and tutorials,code examples of asp.net 2.0,3.0,3.5,4.0 and Articles,examples of .net technologies </p> </td> </tr> </table> </div> </form> </body> </html> |
Now run application output would be like this
Step 2: Our Project is ready with sample page Now Add new Setup project for our project for that
Go to File ---> Add ---> New Project
Step3: Whenever we click on New Project another window will open in that
Select Other Project Types ---> Setup and Deployment ---> Web Setup Project ---> Once we select Web Setup project give a name and click OK
Setp4: Now setup project has added to our application that would be like this
Step5: After add setup project open Solution Explorer ---> Right click on Setup project ---> Add ---> Project Output
Step6: Once we click on Project Output it will open another window to select required output files in that window select Primary Output, Content Files and click OK
Here we selected two options one is Primary Output and another one is Content Files because if we add Primary Output it will add only files which are in bin folder and if we select Content Files option also then it will add .aspx files and web.config file to setup project.
After Add Primary Output and Content Files to our Setup project that would be like this
Now you should rebuild your solution file and setup file once you rebuild it go to your project folder and check setup project folder you will find setup file you can run your setup file directly from that folder or right click on your setup project in visual studio and select Install
Once you click on Install it will display welcome wizard in some cases may be you have a chance to get error like “The installer was interrupted before application could be installed. You need to restart installer to try again” to solve this problem check this post the install was interrupted before application could be installed.
Now click next in next screen we will see options Site, Virtual Directory and Application Pool fill these options and click Next button
In next screen it will display Confirm Installation you need to click Next
Whenever we click on Next button that will start installation process in next screen like this
Once installation process completed then that will display installation completed successfully window
Now open your IIS by type “inetmgr” in Run and check your IIS if that contain our installed application or not
Now your site is ready you can browse from IIS that will display output will like this
Here we can uninstall this application easily for that Go to Setup project in visual studio Right click on it and you will find option Uninstall
Second way Go to Control Panel ---> programs --->Uninstall Program ---> Add or Remove Programs ---> select your installed sample right click on it and select uninstall
13 comments :
hi suresh this is ok so how the database will be install along with set up please urgent .........
please suresh this urgent requirement for me that database also should be install along with setup
PLEASE IAM WAITING 4 U R REPLAY SURESH GARU
i has proceeded as directed. click on Project Output it will opens another window to select required output files in that window only Content Files ia available (Primary Output is not seen) what will be the reason.
i was trying to create web setup for my asp.net+vb web. and i don't want to copy source code (.vb file)
hi suresh,
in websetup deployment i am not able to find primary output files, only content files are coming, plz help how to solve this problem
-hasini
hi suresh,
in websetup deployment i am not able to find primary output files, only content files are coming, plz help how to solve this problem
hi suresh,
in websetup deployment i am not able to find primary output files, only content files are coming, plz help how to solve this problem
baijuep@gmail.com
Baiju EP you might be created a website instead of web-application..In case of website you can't find primaryOutput because it isn't compiled..try again by creating web-application as Mr.Suresh instructed in this article..
hello sir,
I am fresher working on vb.net and sql server, I have created website in vb.net now i want to create exe of that and run it on another machine , i followed your given steps and created setup but its unable to run on other machin. what will i need to do?
please guide
Nikita.ghag18@gmail.com
Hi,
This is good but i need in visual studio 2012
hi
HI Suresh,
You have given very useful document here.but i have would like automatically popup main form after completion of successfully run the set up .
Please help if any idea about that.
Thanks
Rajkumar Chavan