Create installations with Visual Studio Installer

Introducing Visual StudioInstaller

VisualStudio Installer is a free tool from Microsoft for creating installations forWindows applications. Visual Studio Installer is available in two Englishversions: version 1.0 works on Windows 98 and version 1.1 works also on WindowsME and 2000/XP. You can download version 1.1 from here.

Before installing Visual Studio Installer (fromhere on just VSI) be sure that on your PC has been installed Visual StudioService Pack 3 or later. You can download Visual Basic Service Pack 5 from MSDNWeb site.

The on-line documentation and MSDN articlesshow the differences between VSI and the Installation Wizard accompanyingVisual Basic. VSI offers more features that will be shown in this article. Supposingyou have installed both Visual Studio Service Pack and VSI, you are ready to goforward.

WindowsInstaller

VSI is based on the Windows Installertechnology. Windows Installer is an engine using files with .MSI extension forinstalling applications. Every .MSI file is a kind of database and containssetup informations and compressed files. Windows Installer is part of theoperating system in Windows ME and later versions. If you have Windows 95/98you can download the latest version of Windows Installer at MSDNWeb site. Anyway, VSI Setup will also install Windows Installer on yourmachine if not found.

Asimple package

First of all you have to create a new setupproject. Visual Studio Installer can create three kind of projects:

1.   A new empty project;

2.   A so-called Merge Module;

3.   Visual Basic Installer;

 

A MergeModule (extension is .msm) is a file containing completeresources for installing shared components, for sharing setup among more users,or executing external files (i.e.: external executables, MDAC components). Whenbuilding packages, VSI uses some standard merge modules, containing systemcomponents and resources. Further informations about Merge Modules and aboutinstalling MDAC, can be found in the MSDN Library.

For Visual Basic programmers the most importantoption is the third one. Select this and specify an existing project.

If you select the first option in the nextdialog box:

theinstaller will run on any operating system in any language; otherwise,selecting the second option, the installer will only run on operating systemslike yours. The installer can run only with English dialog boxes.

 

VSIwill create a new project, read VB project dependencies adding them to the VSIproject, and create a list of files to be installed. This list will appear atthe right side of the screen, in a section called Files. You can get the best result from setup customizing thefollowing properties: User Interface,File System, Registry Entries, Associations.

 

Installation properties

 

Fromthe Project menu select the lastcommand, containing the project name and the word properties. The following dialog box will appear, where you canspecify or modify package properties:

 

 

thereare some properties to be configured:

1.    output type:debug or release version. The first one is useful to test your package, thesecond one (final) is the version youshould distribute;

2.    destination folder:you can leave it unchanged. It is the folder where the .MSI package will beplaced;

3.    build type:selecting Installer with Windows InstallerLoader, our package will install the Windows Installer engine on the finaluser machine if not present (suggested);

4.   compression:you can choose between standard Installer (suggested), cabinets (.cab) oruncompressed. You can also set the compression method, by speed or by size;

5.    destination folders foryour application: VSI suggests the Program Files Folder (something like C:Program Files on your machine) and the name of your applicationin a text box. The resulting folder will be C:ProgramFilesMyApp. Here you can modify the folder name as you like;

6.    product informations:specify your software properties: product name, version, GUID and upgrade GUID.These two codes are generated by VSI and can be changed manually;

7.    support informations: specify here your e-mailaddress, URL or phone number if you want to be contacted for help;

8.    summary:for additional informations about your product;

9.    merge module search pathand launch condition: these are foradvanced users and should be leaved unchanged. Read the on-line documentation formore information about these options.

 

The User Interface

 

Customizing the FileSystem item

 

Managingfiles is the hardest argument. Open the FileSystem item. In the central window you will see a list of folders. Eachfolder contains some files, or just some shortcuts.

 

 

TheWindows System Folder contains DLLlibraries or ActiveX components which have to be registered by the installer.This is the right location for other files that must be placed in WindowsSystem directory.

Toadd one or more Windows special folders (ie: Windows, Application Data etc.)right-click and select Add Special Folderthen select the special folder you need.

Executables,type libraries, text documents, images, and all files needed by yourapplication must reside in the ApplicationFolder. You can also create sub-folders and add new files there, with just amouse right-click.

BecauseVSI reads VB project dependencies, you do not need to add components or systemfiles in File System, except forthose files that VSI cannot read from the source project (like documents,databases, etc.).

Youcan add shortcuts in the User’s StartMenu and User’s Desktop folders,with a mouse right-click, just selecting CreateShortcut.

Selectthe shortcut destination from the file list. You can also specify some morefeatures, first of all the shortcut icon. This necessary since VSI gets iconsonly for executables, so for other file types you must specify an icon.

 

Inthe Description property you can addcomments, so that users can see a description when choosing the Property dialog box for an executable.  The vbShowCmdproperty is similar to the vbNormal,vbMinimized, vbMaximized VB costants, and sets windows size. In the Arguments property you can specify fixedparameters and arguments for your executable.

 

Creating Windows StartMenu shortcuts

 

Tocreate folders and shortcuts in the Windows StartMenu, right-click on File System onTarget Machine, and select AddSpecial Folder and then Custom.VSI will create a new sub-folder called NEWFOLDER. Renamethis folder in ProgramMenuFolder.Write folder name exactly as shown. This is a Windows Installer constant, usedto identify that particular folder. This new folder is the Program Files folder in the StartMenu.

Now,you can add a new sub-folder under ProgramMenuFolderand name it as you like, adding here shortcuts as shown before.

 

 

 

The Tasks List

 

Atthe bottom of the screen you can see the TaskList. Once completed the above operations, select the Build command from the Buildmenu. VSI will begin to create the installer. If nothing appears in the tasklist it means that the package has been created with no errors.

Thetask list can display simple warnings or critical errors. In the latter case,you will see the Failed message on the status bar.

 

Avery simple but frequent error is to add duplicate filenames in the File System.

Warningsare not often important, anyway you should verify the reason why they wereissued. The most frequent warning is about DLL versions. It is possible thatyour operating system contains DLLs with different version than those used byVSI for creating packages. Since VSI uses its own merge modules containingsystem and run-time libraries, it will just emit warnings about components withdifferent versions. You can leave things unchanged, since VSI will notoverwrite later versions of the same components.

 

Otherwarnings can be related to the lack of dependencies for type libraries, dynamiclink libraries or ActiveX components. If you have no dependencies file(particularly for your own type libraries), you should control the source code,if possible, and verify that each file required by your component is includedin the package.

Forexample, your application has a reference to a certain type library, but you haveno dependecies file for this component; in this case VSI shows a warningmessage, and you must be sure that all the required libraries are included inthe File System, (in this case VSIcannot rely on dependencies), because otherwise the application will not workon machines that don’t contain components required by the type library. Here’s asample task list:

 

 

Building the InstallerPackage

 

Youare now ready to build your own package. From the Build menu you have to select the Rebuild command. VSI will create a Windows Installer package; ifyou chose Installer with InstallerLoader from the Project Properties window, VSI will copy Windows Installerredistributables in the package output folder. From the Project menu, choose LaunchInstaller to test your package. Before distributing your installer,remember to set package configuration to Releasefrom the Project Properties window.

 

Conclusions

 

Themain purpouse of this article is not to be a guide to VSI, rather just astarting point, since it is quite hard to find documentation about VSI on theInternet.

Youcan also download the WindowsInstaller SDK from MSDN Web Site, very useful for C++ programmers,containing sample projects and documentation for Windows Installer programming.

 

Contact me at my e-mail address: [email protected]or visit my Italian home page at http://community.visual-basic.it/Alessandrofor more information.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

Recent Articles: