20.1 Creating setup.exe-Based Installations

 <  Day Day Up  >  

20.1 Creating setup.exe -Based Installations

You have an application coded as a VS.NET solution, and you want to create a basic setup program that will install the application to a target computer.


Technique

The usual technique involves adding a deployment project to the VS.NET solution that contains the projects to be deployed. Use the VS.NET menus in the usual way to add a new project, and select Setup Wizard as the type of project to create.

The wizard guides you through a couple of steps, including asking what type of application you want to create a setup project for. In this chapter, we work with a Windows application.

The wizard then asks what parts of the solution need to be deployed. To illustrate this, we created a solution that contained two projects called MyApplication and MyLibrary and added a setup project to this solution. Figure 20.1 shows how we indicate that both of these generated assemblies must be deployed. In general, to deploy the assemblies that are built from your solution, you select Primary Output for each of the projects in the solution (in other words, the emitted assembly for each project), as well as any localized resources associated with each project.

Figure 20.1. Choosing the files to be deployed.

graphics/20fig01.jpg

Depending on the nature of the application you need to redistribute, you might also want the setup program to install documentation files (autogenerated documentation), as well as the source files, content files, and debug symbols. In an additional step, the wizard asks you to specify any files that are not part of the solution but need to be installed.

The basic setup project is now complete, although you might want to change the product name as well as other basic information about the setup. You can do so by selecting the project in the VS.NET solution explorer. You then find that the Properties Window allows you to modify various information properties of the setup project, such as ProductName , Manufacturer , and ManufacturerUrl .

Note that building the solution normally builds all the projects except the setup project. To build the setup project, you need to specifically tell VS.NET to build that project. If you select the setup project in the solution explorer, you then see a separate Build Setup Project Name menu item under the Build menu in VS.NET. When the setup project is selected in the VS.NET solution explorer, you also see that the VS.NET main Project menu contains Install and Uninstall menu items, which run the setup program on the developer machine; selecting these items will cause the setup program to run, either installing or uninstalling the other projects in the same way that they would be on the end user 's machine.

Comments

For a Windows application, building the setup project generates three files, called setup.exe , setup.ini , and Setup Project Name .msi :

  • setup.exe is the file that is actually executed to perform an install or uninstall.

  • setup.ini contains some additional configuration information used by setup.exe in XML format.

  • Setup Project Name .msi is a Windows Installer database file that contains all the information required for the setup process. Embedded in this file are all the individual files that might need to be installed.

To redistribute your project, all that is required is to redistribute these three files (possibly on redistributable media such as CD-ROM) and instruct the end user to execute the setup.exe file.

In this chapter, although we work with Windows setup projects, most of the techniques are unchanged for the other types of setup projects. The other types of project you can create are

  • Web setup project ” Similar to a Windows setup project but aimed at installing ASP.NET code on a Web site. Running this project installs the files and also sets up IIS correctly to run the project.

  • Merge module ” Again similar to a Windows setup project, but this type produces a Windows installer file with the extension .msm , which you can include in other setup projects. You can almost think of it as the setup project's equivalent of a dynamic link library (DLL). Use a merge module to write an install program for components that need to be installed by many other setup programs.

  • Cab project ” This type is aimed at deploying files that are intended to be downloaded over the Internet or a network connection. The project produces a cabinet file with the extension .cab , which contains a number of other files packaged into one unit. Note that most of the techniques discussed in this chapter cannot be applied to Cab projects: Essentially, all you can do with a Cab project is select files to be installed and set some properties. This type of project does not generate any setup program ”merely a single cabinet file.

To create any of these projects, select the appropriate project type in the Setup Wizard.

The default project Windows Forms setup project generated by VS.NET presents a standard user interface. Running the compiled setup.exe from this project results in the user seeing the following dialog boxes:

  • A welcome dialog (see Figure 20.2). Note that the text in the title bar comes from the setup project name .

    Figure 20.2. The default setup project Welcome dialog.

    graphics/20fig02.jpg

  • A dialog asking which folder the user wants the project installed to (see Figure 20.3).

    Figure 20.3. The Installation Folder dialog.

    graphics/20fig03.jpg

  • A confirmation dialog to give the user a final chance to cancel before the installation actually happens (see Figure 20.4).

    Figure 20.4. The Confirm Installation dialog.

    graphics/20fig04.jpg

  • A progress dialog with a standard progress-bar control showing the installation progress (see Figure 20.5).

    Figure 20.5. The installation-progress dialog.

    graphics/20fig05.jpg

  • A final dialog to indicate install is complete (see Figure 20.6).

    Figure 20.6. The Finished dialog.

    graphics/20fig06.jpg

The setup program places all the assemblies and other files to be installed in the folder chosen by the user and adds the application to the list of installed applications so that it appears in the Control Panel's Add or Remove Programs dialog. Also, because the installation is controlled by Windows installer, Windows installer automatically repairs the application if, for example, someone accidentally removes installed files later.

 <  Day Day Up  >  


Microsoft Visual C# .Net 2003
Microsoft Visual C *. NET 2003 development skills Daquan
ISBN: 7508427505
EAN: 2147483647
Year: 2003
Pages: 440

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