Lesson 3: Creating an Installation Program

Lesson 3: Creating an Installation Program

If you re installing a Web application on multiple servers or if the servers are located on secure networks that do not allow you to deploy the application using Visual Studio s upload tools, you ll have to create an installation program for your application.

In this lesson, you ll learn how to create an installation program for a Web application that runs from the Web or from a CD-ROM. You ll also learn how to add shared components to that installation program through merge modules.

After this lesson, you will be able to

  • Create a Setup and Deployment project for a Web application

  • Add multiple IIS application folders to a project

  • Create an installation program for use over the Web

  • Create an installation program for use from a CD-ROM

  • Add shared components to a Setup and Deployment project

Estimated lesson time: 30 minutes

Creating a Setup and Deployment Project

The easiest way to create an installation program for a Web application is to use the Setup And Deployment Projects Setup Wizard template. To create a new Setup And Deployment project for a Web application, follow these steps:

  1. Open the solution containing your Web application in Visual Studio.

  2. From the File menu, point to Add Project, and then choose New Project. Visual Studio displays the Add New Project dialog box, as shown in Figure 9-11.

    figure 9-11 the add new project dialog box

    Figure 9-11. The Add New Project dialog box

  3. Select Setup And Deployment Projects in the Project Types list, and select Setup Wizard from the Templates list. Type the name of the setup project to create, and click OK to begin the wizard. Visual Studio uses the project name as the name of the root virtual folder to create on the server.

  4. Click Next on the wizard s Welcome page, select Create A Setup For A Web Application on the Choose A Project Type page, and click Next. Visual Studio displays the Choose Project Outputs To Include page, as shown in Figure 9-12.

    figure 9-12 the setup wizard choose project outputs to include page

    Figure 9-12. The Setup Wizard Choose Project Outputs To Include page

  5. Select the project output that you want to install on the server. For a Web application, you must select at least the primary output and content files for your project. Primary output refers to the application s assembly; content files refers to the project s Web forms, HTML pages, user controls, configuration files, and other content used by a Web application. Click Next; Visual Studio displays the Choose Files To Include page, as shown in Figure 9-13.

    figure 9-13 the setup wizard choose files to include page

    Figure 9-13. The Setup Wizard Choose Files To Include page

  6. Click Add to open the Add Files dialog box, and select the files that are used by the Web application but are not included as part of the Web application project, such as Microsoft Access database files, text files, and so on. After adding the necessary files, click Next; Visual Studio displays the Create Project page, as shown in Figure 9-14.

    figure 9-14 the setup wizard create project page

    Figure 9-14. The Setup Wizard Create Project page

  7. Click Finish to create the setup project and add it to the current solution. When complete, the setup project appears as shown in Figure 9-15.

    figure 9-15 the completed setup project

    Figure 9-15. The completed setup project

By default, the Setup Wizard creates a project for installation from removable media, such as a CD-ROM. When built, this project writes the Windows Installer (Setup.exe), an initialization file (Setup.ini), and a content file (projectname.msi) to the /debug or /release folder of the setup project s folder.

In most cases, you ll need to take the following additional steps before building and deploying the setup project:

  1. Change the setup project options to support Web deployment:

  2. Review the setup project output and add needed files.

  3. Rename the root virtual folder where your application will be installed.

  4. Add virtual folders to create additional IIS application starting points on the target server.

  5. Include shared .NET components to install in the server s GAC or shared COM components to install and register with the server s system registration database.

The following sections describe how to perform these steps.

Modifying the Setup Project for Web Deployment

The Visual Studio setup projects generate an installation program that uses the Windows Installer bootstrap executable (Setup.exe). This executable checks whether the target machine has the Windows Installer, prompts the user to download the Installer if it is not installed, and starts the Installer once it is available. By default, the Setup Wizard uses a bootstrap executable configured for local access to the setup resources, as when distributing the software on a CD-ROM.

To create a setup project that can be installed from an Internet address, follow these steps:

  1. Select the setup project in Solution Explorer, and choose Properties from the Project menu. Visual Studio displays the setup project Property Pages dialog box, as shown in Figure 9-16.

    figure 9-16 setup project properties

    Figure 9-16. Setup project properties

  2. Select Web Bootstrapper from the Bootstrapper drop-down list. Visual Studio displays the Web Boostrapper Settings dialog box, as shown in Figure 9-17.

    figure 9-17 web bootstrapper settings

    Figure 9-17. Web Bootstrapper settings

  3. In the Setup Folder box, type the Web address where you will deploy the installation program and click OK. Then click OK to close the Property Pages dialog box.

  4. Build the setup project, and copy the Setup.exe and projectname.msi files to the Web address specified in step 3.

  5. Add a Web page with a link to the Setup.exe file specified in step 3. For example, the following link installs the Web application from the WebApps\Install folder:

    <a href="http://www.contoso.com/WebApps/Install/Setup.exe">Install Web Applicaton</a>

Reviewing the Setup Project s Contents and Adding Files

As mentioned, Web application setup projects must include at least the primary project output (the assembly) and the content files (Web forms and so on). Setup automatically creates the /bin folder and any subordinate folders for content files based on the source project s content.

To review the content before building a setup project, perform the following task:

  • Right-click the output item in the setup project s File System window, and select Output from the shortcut menu. Visual Studio displays the content items, as shown in Figure 9-18.

    figure 9-18 viewing content output

    Figure 9-18. Viewing content output

The Outputs dialog box displays the source and destination locations of each item to install. Sometimes items in the source project don t appear in the Outputs list as you might expect. In those cases, select the item in the source project and verify that its Build Action property is set to Content.

Other times, you might want to include files in the setup project that aren t part of the source project. For example, you might want to install a Microsoft Access database in a data folder along with the rest of your Web application.

To add files to the setup project other than source files, follow these steps:

  1. Right-click in the setup project s File System window, point to Add, and select File from the shortcut menu. Visual Studio displays the Add Files dialog box.

  2. Select the files to add, and click OK to add them to the setup project s File System window.

Renaming and Adding Virtual Folders

The Setup Wizard creates one virtual folder to be installed as an application folder in IIS. This folder appears on the right side of the File System editor and is named Web Application Folder. The Setup Wizard gives this virtual folder the setup project s name. This will be the Web application s root folder when installed on the server, so you ll probably want to rename it.

To change the name of the root virtual folder to install, follow these steps:

  1. Select the Web Application Folder in the File System editor.

  2. In the Properties window, set the VirtualDirectory property.

Some Web applications include multiple application starting points within their folder structure. In Visual Studio, you create a new application starting point by adding a new Web application project. Each Web application project has its own root virtual folder containing Web.config and Global.asax files. To get Setup to create IIS application folders for these projects, you must add a custom Web folder to the setup project.

To add a custom Web folder to a setup project, follow these steps:

  1. Right-click the File System On Target Machine item in the File System editor, point to Add Special Folder, and then select Web Custom Folder from the shortcut menu. Enter a name for the new folder.

  2. Set the VirtualDirectory property of the Web folder to reflect the structure of your application. Use the relative address to create the folder within another application s domain. For example, MainApp/Restricted creates the folder Restricted within the MainApp virtual folder.

  3. Add project output to the new Web folder as you did in the preceding section, Reviewing the Setup Project s Contents and Adding Files.

Adding Shared Components

Components used by more than one application should have their own, separate setup projects called merge modules. Merge modules allow the server to manage the installation of shared components so that they re not unnecessarily overwritten and so that they can be safely removed when no longer used. Unlike regular setup projects, merge modules can t be installed by themselves they can be installed only as part of an application installation.

To create a merge module, follow these steps:

  1. From the Visual Studio File menu, point to New, select Project, and then select the Merge Module Project in the New Project dialog box.

  2. In the setup File System editor, add the components to install. You can add special folders to the File System editor to add components to the server s System folder, GAC, or other shared locations.

  3. Build the project. Visual Studio generates a merge module (projectname.msm) once the merge module is built.

To add a merge module to a setup project, follow these steps:

  1. Open the setup project in Visual Studio.

  2. From the Project menu, point to Add, and choose Merge Module. Visual Studio displays the Add Modules dialog box.

  3. Select the merge module to add, and click OK.



MCAD(s)MCSD Self-Paced Training Kit(c) Developing Web Applications With Microsoft Visual Basic. Net and Microsoft V[.  .. ]0-315
MCAD(s)MCSD Self-Paced Training Kit(c) Developing Web Applications With Microsoft Visual Basic. Net and Microsoft V[. .. ]0-315
ISBN: N/A
EAN: N/A
Year: 2003
Pages: 118

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net