.netCoders Contact Us
Search:

Setup Programs

One of the ways to deploy your web application is by using a Web Setup Program. This is a special project in Visual Studio.NET that will package your application into an installer executable. A user can run the executable to install the web application on their machine and have the necessary IIS virtual directories created. Then, using the Control Panel's Add/Remove Programs option, the user can later uninstall the application.

Creating a Setup Project

Launch Visual Studio.NET and open the web project that you want to deploy. Select Add Project->New Project... from the File menu. Click on the item "Setup and Deployment Projects" under Project Types, and then select Web Setup Project in the right pane.

VS.NET will create an empty setup project for you. At this point, you have the choice of adding files, directories, and assemblies individually, or capturing the output of an existing Web Project. We'll do the latter since VS.NET will take care of the details for us. In the Solution Explorer pane, right click on the Setup Project and select Add->Project Output. This will open a dialog box where you can add a Project's output to the installation. The screenshot below shows that the dialog lists other projects in the solution, as well as options for what you would like to include in the build. For our example, we want the Web Project's primary output (which is the assembly) as well as the content files (eg. .aspx) built according to the release configuration.

At this point, you can build your application. Right click the Setup Project and select Build. By default, a setup project is not included in a solution-wide build. In the build output pane, you should see messages like the following:

------ Starting pre-build validation for project 'SetupProject' ------
------ Pre-build validation for project 'SetupProject' completed ------
------ Build started: Project: SetupProject, Configuration: Release ------

Building file 'E:\TestProjects\SetupProject\Release\SetupProject.msi'...
WARNING: This setup does not contain the .NET Framework which must be installed on the target machine by running dotnetfx.exe before this setup will install. You can find dotnetfx.exe on the Visual Studio .NET 'Windows Components Update' media. Dotnetfx.exe can be redistributed with your setup.
Packaging file 'Setup.Exe'...
Packaging file 'InstMsiA.Exe'...
Packaging file 'default.aspx'...
Packaging file 'Global.asax'...
Packaging file 'WebForm1.aspx'...
Packaging file 'Web.config'...
Packaging file 'InstMsiW.Exe'...
Packaging file 'WorldPhilosophers.dll'...

If you now open the directory where you placed the setup project, and navigate into the release directory, you'll find the setup files necessary to install your web application.

If you double click the setup.exe, you will start the installer wizard where you can indicate the virtual directory and port number of the installed site. Once this installer is complete, you can verify that it worked by opening the IIS MMC.\

   

If you open up the Add/Remove Programs dialog from the Control Panel, you will see the application listed. From here, you can uninstall the application. As you can see, Web Setup Projects are a convenient way for your users to install your application and have the ability to later uninstall it as well.