Transcript deployment

Chapter 21
Deploying a Desktop
Application
Key Deployment Terms (1)


The process of distributing an application is
called deployment
Deploy an application by creating another
type of projected called an installer


The installer produces a Setup.exe file that is
run by the user
The Setup.exe file relies on other support files
containing the actual program to install
Key Deployment Terms (2)

The players


The development computer is the computer
where the Deployment project is built
The target computer is the end user’s
computer where the Deployment project will be
run
Steps in the Deployment
Process






Configure a Windows Application project for release
distribution
Create a Deployment project within an existing
solution
Set global properties for the Deployment project
Configure the Deployment project using the visual
editors
Compile the Deployment project and test the installer
Distribute the installer
Configuring a Project for
Deployment

Visual Studio .NET supports two default
configurations



Debug configuration is used for debugging
 Program Debug Database (.pdb) file is created for
debugging
 Program is not optimized
Release configuration is used for distribution
 DEBUG constant is not defined
 Debug information is not generated
 Program is optimized for performance
Custom configurations are also possible
Configuring an Application

The Configuration Manager lists all of the
projects in a solution and is used to configure
them


Configuration column is used to specify the
desired configuration
Check the item in the Build column to build the
project
Configuration Manager
(Illustration)
Types of Deployment
Projects

Setup Project creates an installer for removable
media




CD or DVD for example
Web Setup Project builds an installer for Webbased deployment
Merge Module Projects are used to deploy Class
Library projects
Cab Project used to create cabinet files


Cabinet files are similar to Zip files
They are not used much anymore
Add New Project Dialog box
Setup project
Multi-project Solutions


Until now, a solution has had a single project
Here we work with a Setup project and
Windows application project in the same
solution
Multi-project Solutions
(Illustration)

The Solution
Explorer
displays
all projects
Characteristics of
Deployment Projects




Deployment projects do not contain
namespace references
Deployment projects do not contain forms
Deployment projects do not contain code
Deployment projects are created and
configured using different visual editors

It's just about all WYSIWYG
Properties of a
Deployment Project

Many properties are set using the Project’s
Property pages. Others are set using the
Properties window



Output file name contains the name of the
installer
Package files list box defines how files will be
deployed
Compression list box defines whether the
installer is optimized for speed or size
Deployment Project
(Property Pages)
General Deployment Project
Properties (1)





Author and Manufacturer properties contain a
company name
Description contains a free form description
DetectNewerInstalledVersion, if True causes
the installer to prompt the user if a newer version is
already installed
Localization creates custom installers for
different languages
ManufacturerUrl property contains the company’s
URI
General Deployment Project
Properties (2)



ProductName appears as the component
description in the Add/Remove programs
dialog box
RemovePreviousVersions property
controls whether older versions will be
removed
Version contains the version number of the
installer

This is the version of the installer itself rather
than the version of the deployed project
General Deployment Properties
(Illustration)
Configuring a
Deployment Project
(Introduction)


Six Deployment Project Editors configure a
Deployment project
In general, you need not write any code
Deployment Editors






File System Editor defines which files are installed
on the target computer
File Types Editor associates files extensions with an
application
User Interface Editor configures the dialog boxes
the user sees when they run the installer
Launch Conditions Editor specifies target system
requirements
Custom Actions Editor allows custom dialogs to be
created
Registry Editor allows the installer to read and
write Registry values
The File System Editor (Purpose)

It is used to define the layout file system
layout on the target computer


Define the items that will appear on the Start
menu


Application Folder represents the files copied to
the target computer
User’s Programs Menu folder
Add items to the target computer’s desktop

User’s Desktop folder
The File System Editor
(Illustration)
Adding Items to the
Target File System

The Application folder contains four types of project
items




Folders represent folders that will be created on the
target computer
Project Outputs represents the distributable executable
application(s) that will be copied to folders
Files are just other files to be deployed with the
application
 Data files, tutorial files, etc.
Assembly items is used to specify additional assembles
needed by the application
Adding a Project Output

Five primary types of project outputs

Primary output – the .exe and .dll files produced a
result of compiling a project






It is possible to deploy multiple primary outputs
Localized resources – Satellite assemblies for localized
resource files
Debug Symbols – Deploys the debugging information
Content Files – Help files, data files, tutorial files, etc.
Source Files – Deploys the source code for the
application
We won't discuss documentation files and XML
Serialization Assemblies
Add Project Output
Group Dialog Box
Configuring the
Start Menu and Desktop

Add items to the User’s Programs Menu folder
in the File System Editor to configure the
Start menu


It is possible to create sub folders and deploy
items to those sub folders
Add items to the User’s Desktop folder to add
outputs to the users desktop
Deploying Support Files

Using the File System Editor, create folders
and sub folders

Add files to those sub folders
Creating File Associations

File associations bind file extensions to
applications


An application may have multiple file
associations


Double-click a file in Windows Explorer and the
application loads
Two or more file extensions may be associated
with the same application
Use care not to overwrite existing file
associations (.doc, .xls, etc.)
Creating File Associations (Steps)


Use the File Types Editor to associate a file
type with an executable file
Optionally, associate the file type with an icon


Icon appears in Windows Explorer
Modify the application, as necessary, to read
to read and process the file when the
application starts
The File Types Editor


Use to create file associations
A File Type (extension) has the following properties




Command property specifies the executable file that will
be launched when the action is invoked
Description property value appears in Windows Explorer
Extensions property contains the file extension
 Separate multiple file extensions with a semicolon (;)
Icon property contains the associated icon
File Types Editor
Reading Command Line
Arguments (1)

The Microsoft.VisualBasic.Command function
gets command line arguments


Arguments are returned as a string
Remove the quotation marks surrounding the string, if
necessary
pstrCommandArgs = Microsoft.VisualBasic.Command()
pstrCommandArgs = pstrCommandArgs.Remove(0, 1)
pstrCommandArgs = pstrCommandArgs.Remove( _
pstrCommandArgs.Length – 1, 1)
Reading Command Line
Arguments (2)


In C#, we read command line arguments:
http://msdn.microsoft.com/enus/library/cb20e19t(v=VS.80).aspx
Custom Installer Dialog Boxes


An installer consists of multiple dialog boxes
filled out by the user
The User Interface Editor is used to configure
the dialog boxes when the user runs the
installer


Add existing predefined dialog boxes to the
installer
Configure the order in which those dialog boxes
appear
Default Dialog boxes

By default, the User Interface Editor includes five
dialog boxes





Welcome dialog box displays a welcome message
Installation Folder lets the user select the installation
folder
Confirm Installation is the final chance to continue or
abort the installation
Progress dialog box displays the relative completion
Finished dialog box indicates that the installation is
complete
Custom Dialog Boxes (1)

Three RadioButtons dialog boxes





One contains 2 buttons, another 3, and another 4
Three CheckBoxes dialog boxes display between 1
and 4 check boxes
Customer Information gets customer name and
organization
Three TextBoxes dialog boxes display between 1
and 4 text boxes
License Agreement dialog box displays a license
agreement
Custom Dialog Boxes (2)



Read Me dialog box displays a multiline text
box containing an informational message
Register dialog box allows the user to
register online
Splash dialog box displays an introductory
splash screen
The User Interface Editor
Adding a Dialog
License Agreement Dialog Box

License agreement is an RTF file


RTF file containing the license file must be
added to the Deployment project
In the Properties window for the License
agreement, select the project item containing
the license file
Checkboxes Dialog Box






BannerBitmap contains the image appearing in the banner
section
BannerText contains the text appearing in the banner area
CheckBox1Value indicates whether the checkbox is checked
or not
CheckBox1Visible indicates whether the check box is visible
CheckBox1Property contains the name to be tested in a
condition
Additional properties of the same name but different number
are used to set the remaining three check boxes
Conditional Deployment
(Introduction)

There are two ways to conditionally deploy files


In the Properties window of the File System Editor,
deployable elements have a property named Condition
 Use it to build a condition. If the condition is true, the
file or other element will be deployed to the target
computer. If the condition is False, the file will not be
deployed
Launch conditions provide the means to test for the
existence of a file for the installation to succeed

Test for Internet Explorer or a particular operating system
version, for example
Creating a Launch Condition

Launch Conditions test the following types of
conditions before deployment can succeed




Test whether a file or program exists and
optionally, the version of that program
Test the version of the operating system
Test whether the .NET Framework is installed
Test the amount of physical memory installed
on the computer
Launch Condition Properties




MsiNetAssemblySupport – Used to determine if
.NET is installed on the target computer
Version9X – Used to determine if the OS version on
the target is Windows 95, 98 or Windows ME
VersionNT – Used to determine if the OS version on
the target is Windows NT, Windows 2000 or
Windows XP
PhysicalMemory returns the amount of physical
memory installed in the target computer
Launch Condition Editor
File Launch Conditions





FileName contains the name of a file that must be
installed on the target computer
MinDate and MaxDate control the minimum and
maximum file dates
Folder property controls where the installer searches
for file names
Depth project controls number of directory levels to
search
MinVersion and MaxVersion controls minimum
and maximum version number for files
Compiling the Installer


Compile the same way as any project would
be compiled
Output files differ however




.msi file contains the deployment files
InstMsiA.exe and InstMsiW.exe read and
process the .msi file
Setup.Exe program runs the installer
Setup.Ini file is read by the Setup.Exe
program
Testing the Installer

There are Two ways to test the installer

From inside of Visual Studio .NET



Use to install or uninstall the software
Run Setup.Exe directly
The project will be installed just as the user
will see it