Title: Deploying a VB 'NET Application
1Chapter 14
- Deploying a VB .NET Application
2Objectives
- Understand deployment with Visual Studio .NET
- Create a setup project with a wizard
- Learn how to deploy to different media
- Add a Deployment project to a solution
- Deploy support files with an application
- Add file associations
- Create Custom Installer dialog boxes
- Install the .NET Framework
3Computers used in the Deployment Process
- Two computers are used in the deployment process
- The development computer is where you create the
deployment project and build a program called an
installer - The user then runs the installer on the target
computer - In this chapter, your computer will fulfill both
roles - The deployment process is essential because a
.NET program cannot run without the .NET
Framework installed
4Steps to Deploy a Project
- Open an existing solution containing one or more
projects - Create a Deployment project within the solution
- Here you can see one purpose of the solution file
- Configure the Deployment project
- Specify the files that you want to deploy
- Specify the items that you want added to the
Start menu on the target computer - Build the Deployment project thus creating the
Setup.exe file and related files - Distribute the Setup.exe file and related files
5Creating a Setup Project with a Wizard
- The Setup Project Wizard contains 5 dialog boxes
- The first is a Welcome dialog box
- In the second dialog box, you specify the type of
project to deploy - In the third dialog box, you specify the program
outputs - In the fourth dialog box, you select any
additional support files - The final dialog box displays a summary report
6Specifying a Deployment Configuration (1)
- VB .NET supplies two default configurations for
compiling an application - The Debug configuration allows a project to be
debugged from within Visual Studio .NET - The Release configuration removes debugging code
- Use the project's Property Pages to select the
configuration
7Specifying a Deployment Configuration (2)
Active configuration
8Adding a Deployment Project
Select Setup and Deployment Projects
Setup Wizard selected
9Choosing a Project Type
Create a Deployment project for a Windows
application
10The Difference Between Debug and Release
Configurations
- The Debug configuration builds a project such
that the debugging tools can be used to examine
the values of variables and perform other
debugging tasks - In the Release configuration, the debugging
information is stripped out - Use the Configuration Manager to select the
current configuration - Right-click the project in the Solution Explorer,
and then select Configuration Manager
11The Configuration Manager
Release version
Check to build projects
12Deploying to Different Media (1)
- Projects can be deployed to different types of
media - Floppy disks
- CD-ROM
- The Internet
- Use the Property Pages for the Setup Project to
select the media type
13Deploying to Different Media (2)
Possible Package options
14Types of Deployment Projects
- Merge Module projects are used to deploy a Class
Library - A Setup Project is used to deploy a typical
Windows Application Project - A Web Setup Project builds an installer for an
ASP.NET application - A Cab Project is used to add a cabinet file for
older Web browsers that cannot install software
directly
15Deployment Project Properties
- Set using the Properties window just as you would
with any other property - Author and Manufacturer properties contain the
name of the company that developed the
application - Description property contains a textual
description - DetectNewerInstalledVersion property will prompt
the user if a newer version of the application is
already installed - RemovePreviousVersions property allows the
installer to remove old software versions - Version property assigns a version number to the
installer. This is the version of the installer
not the application
16Deployment Project Editors (Introduction)
- Use the Deployment Project Editors to manually
configure the Deployment project - File System Editor is used to define which files
will be deployed and where on the target computer
those files will be deployed - The Registry Editor allows you to define an
installer that will add or update entries to the
Registry on the target computer - The File Types Editor creates file associations
- The User Interface Editor allows you to add
custom dialog boxes to the installer - The Custom Actions Editor allows you to further
customize the installation process - The Launch Conditions Editor will check that
specific components are installed on the target
computer
17The Role of the File System Editor
- The File System Editor provides three services
- You specify the files that you want to deploy to
the target computer - Files may include executable files and any
additional support files - You specify any items that will be added to the
Start menu on the target computer - You specify any shortcuts that will be added to
the desktop on the target computer
18File System Editor (Illustration)
19File System Editor (Folders)
- Three Folders appear in the File System Editor
- The Application Folder controls the destination
folder where files will be stored - User's Desktop defines any desktop icons that
will appear on the target computer - User's Programs Menu is used to define any items
that will appear on the Start menu - Note that new folders can be added to the Start
menu too
20Defining the Files for Deployment
- Adding a Folder causes the installer to create a
new folder on the target computer - Multiple folders and sub folders can be added
- You typically add executable files or other
support files to these folders - Every solution produces one or more outputs
(executable files) - Select Project Output to add an executable file
- The File section allows you to select additional
files - The Assembly option allows you to add additional
assemblies
21Adding a Project Output
Select project
Select output
Select the Release configuration
22Deployment Project (Files)
- You build the Deployment project just as you must
build any other project. The build produces the
following files - Setup1.msi contains the installer
- InstMsiA.Exe and InstMsiW.exe are support files
used in conjunction with Setup1.msi - InstMsiA.Exe is the ASCII version
- InstMsiW.Exe is the Unicode (wide) version
- The user runs the file Setup.Exe
- Setup.ini contains initialization information
23Testing the Installer
- You can test the installer by
- Running the Setup.Exe program from Windows
Explorer - Right clicking the Deployment project in the
Solution Explorer, and then clicking Install - This will deploy the project as if it were being
deployed on the target computer
24Deploying Support Files
- You may want to deploy support files in addition
to any executable files - Support files may be deployed to any folder that
you specify - Support files may include
- Database files
- Text files
- Help files
- Other data files
25Adding Folders to a Target
- If deploying a large number of files, organizing
those files into different folders will reduce
clutter - In the File System Editor, add folders to the
Application Folder - Note that folders may also have sub folders
- Then add files to those newly created folders
26Adding Folders to a Target (Illustration)
Sub folders
27Adding Data Files to a Target
- Use the File System Editor again
- Steps to add a data file
- Select the desired folder in the File System
Editor - Right-click the folder
- Click Add, and then click File from the popup
menu - Select the desired file from the dialog box
28Adding File Associations
- File associations allow the user to double-click
a file to run the associated application - Use the File Types Editor to add a file
association - Multiple file extensions may be associated with
the same project - Be careful not to use well-known well-defined
file associations such as .doc, .xls, or .mdb
29File Associations (Properties)
- The Command property specifies the executable
file that will be launched - The Description property contents appears in the
File Types column of Windows Explorer - Using the Extensions property you define the file
extensions - Multiple files extensions are separated by a
semicolon - The Icon property defines the icon that will
appear in Windows Explorer
30Creating a File Association (Steps)
- Activate the File Types Editor for the Deployment
project - Right-click File Types on Target Machine, and
then click Add File - Rename the File type
- Set the Command property using the Properties
window - Set the Description property using the properties
window - Set the Extensions property to the desired file
extension or file extensions - Separate multiple files extensions with a
semicolon
31File Types Editor (Illustration)
32The Command Function
- Use the Command function to get command line
arguments - The command function belongs to the
Microsoft.VisualBasic namespace - When the user double-clicks a file, the file is
passed as a command line argument - Command line arguments are stored in a string
- Call the Split method of the System.String class
to break up the string if necessary
33The Command Function (Example)
- Call the command function storing the arguments
in the variable named pstrCommandArgs
Dim pstrCommandArgs As String pstrCommandArgs
Microsoft.VisualBasic.Command()
34Default Installer Dialog Boxes
- When the user runs the installer the following
dialog boxes appear by default - Welcome dialog box displays a welcome message
- Installation Folder allows the user to override
the default installation folder - Confirm Installation dialog box allows the user
to confirm or abort the installation - Progress dialog box displays the relative
progress of the installation - Finished dialog box displays an installation
summary - You can customize the installer by adding
additional dialog boxes
35Custom Installer Dialog Boxes (Introduction)
- RadioButtons Dialog box containing two or more
radio buttons - Checkboxes Dialog box containing one or more
check boxes - Customer Information Used to supply a customer
name and organization - Textboxes contains one or more text boxes
- License Agreement Requires that the user accept
a license agreement - Read Me An introductory read me dialog box
- Register Forces the user to register your
software - Splash Screen An introductory screen
36Adding a Custom Dialog Box (Steps)
- Activate the User Interface Editor
- On the VB .NET menu bar, click Action, and then
click Add Dialog to activate the Add Dialog box - Select the dialog that you want to add
- Move the dialog box to the desired position
- Typically a splash screen appears first
37Add Dialog Box (Illustration)
38User Interface Editor (Illustration)
Installation dialogs
39Introduction to Conditional Deployment
- You can configure the installer so that the user
can elect to deploy or not deploy specific files - Use a Checkboxes dialog so that the user can make
the selection - Radiobutton dialogs will work too
- There are two ways to perform a conditional
deployment - Use the Condition property
- Build a launch condition
40Creating a Checkboxes Dialog
- A Checkboxes dialog contains one or more check
boxes - Create by adding a custom dialog just as you
added a splash screen - Configure the dialog using the Properties window
41Custom Checkboxes Dialog (Properties)
- BannerBitmap property defines the picture that
appears in the banner area - BannerText property defines any text that appears
in the banner area - For the following properties, n indicates which
check box. Value ranges between 1 and 4 (4
checkboxes) - CheckBoxnLabel defines the text that appears
- CheckBoxnProperty works like the Name property of
a control instance - CheckBoxnValue property defines whether the check
box is checked or not - CheckBoxnVisible controls whether the check box
is visible or not
42Using the Condition Property
- Use the File System Editor to define the
condition for a file, executable, or Start menu
item - Steps
- In the File System Editor, select the desired
file, and then activate the Properties window - Set the Condition property using the name of the
Check box - For example
- CHKTUTORIALS1
43Launch Conditions
- Launch conditions allow you to require that a
particular piece of software is already installed
or that the software version is at some minimum
level - For example
- The Version9X property is used to determine
whether Windows 95, Windows 98 or Windows ME is
running - VersionNT is used for Windows NT, Windows 2000,
or Windows XP - The PhysicalMemory property returns the amount of
ram on the target computer
44Operating System Version Numbers
- Version9X
- 400 for Windows 95
- 410 for Windows 98
- 490 for Windows ME
- VersionNT
- 400 for Windows NT
- 500 for Windows 2000
- 501 for Windows XP
45Creating a Launch Condition (Steps)
- Activate the Launch Conditions Editor
- Using the popup menu, add a launch condition
- Set the Name and Message properties as desired
- Set the Condition property to set for Windows
2000 or Windows XP as in - VersionNT501 OR VersionNT500
46Launch Condition Editor (Illustration)
47Launch Condition Properties
- FileName contains the name of the file for which
you are searching - For example Internet Explorer is IExplore.exe
- MaxDate and MinDate contains maximum and minimum
file dates respectively - Folder property contains folder where the
installer will search for the FileName - Depth property contains number of sub directories
that will be searched - MinVersion and MaxVersion properties contain
minimum and maximum version numbers
48Defining a Launch Condition (Steps)
- Activate the Launch Condition Editor
- Right-click Requirements on Target Machine and
then click Add File Launch Condition - Set the Name property to a descriptive name
- Set the Filename property to the desired file
- Set the Folder property to ProgramFilesFolder,
and then set the Condition property
49Installing the .NET Framework (Introduction)
- To run any .NET application, the .NET Framework
must be installed - The file name is DotNetfx.exe
- File size is about 20 megabytes
- Run the executable file as you would run any
installer - This file can be downloaded from Microsoft and
installed by the user - This is not the best alternative as many users
will not know what the .NET Framework is
50Installing the .NET Framework from a Deployment
project
- Create an installer called a bootstrapper
- The bootstrapper installs the .NET Framework and
then runs your installer - Download a version of the bootstrapper from
Microsoft - Note that the bootstrapper must be configured
51Configuring the Bootstrapper
- Edit the settings.ini file and set the MSI key to
the name of your installer - Msi.\DataFileSetup.msi
- Set the FsInstallerPath key to the name of the
Framework file (DotNetfx.exe) - FsInstallerPath.\dotnetfx.exe
52Data Access Requirements
- Applications that access data require that the
Microsoft Data Access Components version 2.6 or
later are installed