DESKTOP

Visual Basic 2010 : Setup & Deployment Projects for Windows Installer (part 2) - Configuring the Setup Project

1/6/2013 6:13:05 PM

3. Configuring the Setup Project

There are different ways for configuring your Windows Installer package through the setup project. The first way is setting the package’s properties, which you accomplish by first clicking on the project name in Solution Explorer and then switching to the Properties window. All the available properties affect layout, messages, and target folders when launching the installer. Figure 5 shows an example of how you can set properties.

Figure 5. Setting project properties that affect the installer package.


Properties are self-explanatory, but you can click on each of them to get a description at the bottom of the window. Focus on the Manufacturer property that determines the destination folder for the application on the target machine, although the installer lets you modify the destination.

Solution Explorer Toolbar

When you create setup projects, Solution Explorer shows an extended toolbar that now provides buttons for accessing editors for specific package properties, such as the Registry editor and the file types’ editor. In the next sections we often refer to these buttons, so take a look at Solution Explorer to locate them.


Editing the File System

You can manage files to be installed with your package in the File System editor, which can be enabled with the appropriate button from Solution Explorer. Figure 6 shows how it looks when the new project is created.

Figure 6. The file system editor.

You can select a folder to add other files in the right side of the window or add shortcuts to your executable as well. For example, you can add shortcuts for the user’s desktop and Programs menu by selecting the appropriate folders in the left side of the window and then right-clicking the right side of the window; then choose Create New Shortcut. Finally you will be required to specify the executable to be linked via a dialog window. You can specify additional folders and Windows special folders; for this, it is worth mentioning that you can add assemblies to the Global Assembly Cache. This is one of the reasons why you should choose Windows Installer for deploying your applications. To specify assemblies that must be installed to the GAC, right-click File System on Target Machine; then select Add Special Folder, Global Assembly Cache Folder. This creates a reference to the GAC in the file system editor. Now right-click the Global Assembly Cache Folder item and select Add, Assembly.

Figure 7. Specifying assemblies to be installed to the GAC.

You can select one or more assemblies via a dialog window. Notice that Visual Studio can determine all assemblies’ dependencies and can automatically add related assemblies to the project.

 

Editing Registry Values

One of the biggest benefits in deploying applications with Windows Installer is that you can add keys and values to the Windows Registry on the target machine. You create keys, subkeys, and values by selecting the Registry Editor in Solution Explorer and then right-clicking the desired root key; finally add the required key or value. Figure 8 shows how to accomplish this.

Figure 8. Adding a new key in the Registry editor.

Values are then visible on the right side of the editor. You have complete control over the Registry and that Visual Studio prepares a Registry key for your own application under HKEY_LOCAL_MACHINE\Software.

Customizing Dialogs

Windows Installer dialogs are customizable, meaning that you can replace default text messages and title bitmaps, but you can also add your own dialogs. To edit dialogs, select the Dialog Editor in Solution Explorer and then select the desired dialog. Changes are performed via the Properties window. Figure 9 shows an example.

Figure 9. Customizing the installer dialogs.

Each dialog offers a BannerBitmap property that you can replace with your own bitmap image. Other properties depend exclusively on the specific dialog. For example the Welcome dialog has CopyrightWarning and WelcomeText properties that contain text that you can replace with your own.

Creating File Types

There are situations in which you need to associate a custom file extension to your executable. Visual Studio enables putting this information into Windows Installer packages in a convenient way. You provide custom extensions to be associated to the executable and actions to be executed over the extension via the File Types editor. You add an extension by right-clicking the File Types on Target Machine item and then selecting Add File Type. When the new file type is added to the editor, you customize its properties via the Properties window. Figure 10 shows an example of this kind of customization.

Figure 10. Adding and customizing a new file type.

Providing Custom Actions

A custom action enables specifying that an external file or that an instance of the Installer class must be executed at the specified installation time. A typical example is when you need to include in your installation package the redistributables of a particular runtime or components (for example the MDAC components) used by your application that need to be installed before the application itself. To add a custom action, select the Custom Actions editor from Solution Explorer; then right-click the installation phase that is appropriate for you and select Add Custom Action, as shown in Figure 11.

Figure 11. Adding a custom action.

At this point you will be asked to specify the executable to be run at the established moment, via a dialog window. You can pick up the executable from the list of files available in the current package; if the required executable is not part of the file system yet, add it to the package, and then re-add the custom action.

Managed Custom Actions

It is worth mentioning that you could create a class library with Visual Basic and implement it as a custom action during the installation. This provides great granularity on custom functionalities, such as asking for a product key or downloading updates and so on.


Specifying Launch Conditions

Launch conditions enable specifying minimum system requirements needed for continuing the installations. You add launch conditions via the Launch Conditions editor that you can start with the appropriate button in Solution Explorer. There are two launch conditions types; the first type enables searching for the specified file or component on the target system, whereas the second type enables specifying custom conditions such as hardware requirements. When the editor is ready, simply right-click the desired condition type and then click Add Launch Condition. Figure 12 shows a sample launch condition that checks for the machine’s physical memory.

Figure 12. Adding a custom launch condition.

The Condition property contains the condition that must be True for the installation to begin. The Message property contains a localizable text that will be shown whether the condition is evaluated as False. The full list of available conditions can be found in the MSDN Library at http://msdn.microsoft.com/en-us/library/cz6k1z02(VS.100).aspx.

Package Configuration and Prerequisites

You can configure additional properties for your setup package by right-clicking the project name and selecting Properties. This shows the project Property Page represented in Figure 13, where you can specify the output name, how the installer will be packaged (for example, Msi or Cab format), or the compression type.

Figure 13. The project’s property page.

Notice that by clicking the Configuration Manager button you can edit existing configurations (that is, Debug and Release) or add new ones to affect your output packages. This is also the place where you can set up your package to target 64-bit machines. Another important task is setting up prerequisites. Click the Prerequisites button to launch the dialog shown in Figure 14.

Figure 14. Checking and selecting prerequisites.

Prerequisites are those packages or runtime components that must be installed together with the application so that it can work correctly. After you set up all properties shown in this section, you can build and distribute your package.

4. Building and Deploying the Windows Installer Package

To create your Windows Installer distributable package, right-click the setup project name in Solution Explorer and select Build. As an alternative, you can choose the appropriate Build command from the Build menu. This generates a bootstrapper named Setup.exe and the Windows Installer package with an .Msi extension, which in our case is named SetupExample.Msi. The output will be available in the project subfolder related to the current configuration (Bin\Debug or Bin\Release). These are the files that you need to distribute to your customers for installing your application. They simply run the Setup.exe bootstrapper that correctly starts the Windows Installer package.

Other  
 
Top 10
Review : Sigma 24mm f/1.4 DG HSM Art
Review : Canon EF11-24mm f/4L USM
Review : Creative Sound Blaster Roar 2
Review : Philips Fidelio M2L
Review : Alienware 17 - Dell's Alienware laptops
Review Smartwatch : Wellograph
Review : Xiaomi Redmi 2
Extending LINQ to Objects : Writing a Single Element Operator (part 2) - Building the RandomElement Operator
Extending LINQ to Objects : Writing a Single Element Operator (part 1) - Building Our Own Last Operator
3 Tips for Maintaining Your Cell Phone Battery (part 2) - Discharge Smart, Use Smart
REVIEW
- First look: Apple Watch

- 3 Tips for Maintaining Your Cell Phone Battery (part 1)

- 3 Tips for Maintaining Your Cell Phone Battery (part 2)
VIDEO TUTORIAL
- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 1)

- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 2)

- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 3)
Popular Tags
Video Tutorail Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Exchange Server Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 Adobe Flash Professional Dreamweaver Adobe Illustrator Adobe Photoshop CorelDRAW X5 CorelDraw 10 windows Phone 7 windows Phone 8 Iphone