Module 10: Deploying Applications
Module 10: Deploying Applications
Module 10: Deploying Applications
Applications
Contents
Overview 1
Describing Assemblies 2
Choosing a Deployment Strategy 11
Deploying Applications 18
Lab 10.1: Packaging a Component
Assembly 20
Demonstration: Deploying a
Web-Based Application 30
Lab 10.2: Deploying a
Windows-Based Application 31
Review 35
Information in this document, including URL and other Internet Web site references, is subject to
change without notice. Unless otherwise noted, the example companies, organizations, products,
domain names, e-mail addresses, logos, people, places and events depicted herein are fictitious,
and no association with any real company, organization, product, domain name, e-mail address,
logo, person, place or event is intended or should be inferred. Complying with all applicable
copyright laws is the responsibility of the user. Without limiting the rights under copyright, no part
of this document may be reproduced, stored in or introduced into a retrieval system, or transmitted
in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or
for any purpose, without the express written permission of Microsoft Corporation.
Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual
property rights covering subject matter in this document. Except as expressly provided in any
written license agreement from Microsoft, the furnishing of this document does not give you any
license to these patents, trademarks, copyrights, or other intellectual property.
Microsoft, MS-DOS, Windows, Windows NT, ActiveX, BizTalk, FrontPage, IntelliSense, JScript,
Microsoft Press, Outlook, PowerPoint, Visio, Visual Basic, Visual C++, Visual C#, Visual
InterDev, Visual J#, Visual SourceSafe, Visual Studio, and Windows Media are either registered
trademarks or trademarks of Microsoft Corporation in the U.S.A. and/or other countries.
The names of actual companies and products mentioned herein may be the trademarks of their
respective owners.
Module 10: Deploying Applications iii
Instructor Notes
Presentation: This module provides students with the skills necessary to deploy Microsoft®
75 Minutes Visual Basic® .NET applications. They will learn what deployment choices are
available to them and how to use the various deployment project templates to
Labs: successfully deploy any type of application
45 Minutes
After completing this module, students will be able to:
Describe an assembly.
List the different types of application deployment.
Deploy a component assembly.
Deploy an application based on Microsoft Windows®.
Deploy a Web-based application.
Required Materials
To teach this module, you need the following materials:
Microsoft PowerPoint® file 2373B_10.ppt
Module 10, “Deploying Applications”
Lab 10.1, Packaging a Component Assembly
Lab 10.2, Deploying a Windows-Based Application
Preparation Tasks
To prepare for this module, you should:
Read all of the materials for this module.
Read the instructor notes and the margin notes for the module.
Practice the demonstration.
Complete the labs.
iv Module 10: Deploying Applications
Demonstration
This section provides demonstration procedures that do not fit in the margin
notes or are not appropriate for the student notes.
Property CARGOCHECK
Folder [ProgramsFilesFolder]
FileName Cargo.mdf
Depth 3
Condition CARGOCHECK
Message Cargo database is not installed
Module Strategy
Use the following strategy to present this module:
Describing Assemblies
In this lesson, explain what assemblies are, how to create strong names, and
how to version assemblies. You have discussed assemblies at various points
throughout this course. Use this lesson to clarify any questions that have
been raised throughout the previous modules.
Students will have an opportunity to create a strong-named assembly in
Lab10.1 later in this module.
Selecting a Deployment Strategy
In this lesson, explain to students the advantages gained by deploying
applications in Visual Studio .NET. You will review the methods of
deployment, from using XCOPY to creating a Windows Installer
application. Be sure to stress that while XCOPY can simplify deployment, it
cannot be used when registration of components is necessary. The Windows
Installer is the best choice when deploying complex applications.
Deploying Applications
This lesson covers how to deploy both Windows-based and Web-based
applications. Although these two types are quite disparate, the steps for
deployment are actually very similar. You will review how to use the editor
windows to customize your deployment, and you will show students how to
use both the File System and Launch Conditions editors in the
demonstration.
Both of the labs for this module occur during this lesson. In the first one,
students will package a component within a merge module, and in the
second, they will include that in a setup project for a Windows-based
application.
You will also show the students how to deploy a Web-based application in
the demonstration.
Module 10: Deploying Applications 1
Overview
Topic Objective
To provide an overview of
the module topics and
objectives. Describing Assemblies
Lead-in Choosing a Deployment Strategy
In this module, you will learn
about the options available Deploying Applications
to you when deploying
Visual Basic .NET–based
applications.
Describing Assemblies
Topic Objective
To provide an overview of
the topics covered in this
lesson. Assemblies Overview
Lead-in Benefits of Strong-Named Assemblies
This lesson examines
assemblies and the specific Creating Strong-Named Assemblies
requirements for creating
components. Versioning Strong-Named Assemblies
Using the Global Assembly Cache
Assemblies Overview
Topic Objective
To explain the function of
assemblies.
Lead-in Contains code, resources, and metadata
An assemblies is the Provides security, type, and reference scope
building block of a .NET-
compatible application. Forms a deployment unit
Versionable
Side-by-side execution allows multiple installed
versions
Global assembly cache allows assembly sharing
An assembly can be grouped into a single portable executable (PE) file, such as
an .exe or .dll file, or it can be made up of multiple PE files and external
resource files, such as a bitmap.
4 Module 10: Deploying Applications
Note The .NET Framework assemblies are installed into the global assembly
cache.
6 Module 10: Deploying Applications
Delivery Tip
Guaranteed Uniqueness
You may need to elaborate Strong names guarantee that an assembly name is unique and cannot be used by
on public and private key anyone else. You generate strong names through the use of public and private
pairs. key pairs when the assembly is compiled.
<Assembly:
<Assembly: AssemblyKeyFile("KeyFile.snk")>
AssemblyKeyFile("KeyFile.snk")>
You can use a publisher policy file to redirect a binding request to a newer
instance of a component. The following example shows a publisher policy file.
Note the publicKeyToken attribute, a hexadecimal value, which is used to
identify the strong name of the assembly. This value can be obtained by using
sn.exe with the –T switch, or from the Assembly Cache listing in the .NET
Framework Configuration snap-in in the Microsoft Management Console.
<configuration>
<runtime>
<assemblyBinding>
<dependentAssembly>
<assemblyIdentity name="myasm"
publicKeyToken="e9b4c4996039ede8"
culture="en-us"/>
<bindingRedirect
oldVersion="1.0.0.0"
newVersion="1.0.1.0"/>
<codeBase version="1.0.1.0"
href="http://www.Microsoft.com/Test.dll"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
You can compile this XML file into a publisher policy assembly, to be shipped
with the new component, using the Assembly Generation tool (Al.exe). This
signs the assembly with the strong name originally used.
10 Module 10: Deploying Applications
Performance
If the component is stored in the cache, the strong name does not need to be
verified each time the component is loaded. This method also guarantees that
only one instance of the component is loaded in memory, reducing the overhead
on the target computer.
Shared Location
You can use the computer configuration file to redirect all bindings to the
global assembly cache, providing simpler administration of assemblies.
File Security
Only users with administrative privileges can delete files from the cache.
Side-by-Side Versioning
You can install multiple copies of the same component, with different version
information, into the cache.
Module 10: Deploying Applications 11
Deployment Overview
Topic Objective
To discuss the advantages
that Visual Studio .NET
deployment offers over No-impact applications
deployment in earlier
versions. Private components
Lead-in Side-by-side versioning
The new deployment
options in XCOPY deployment
Visual Studio .NET offer
distinct advantages over the On-the-fly updates
options in the Package and
Deployment Wizard in Global assembly cache
Visual Basic 6.
No-impact applications All applications are isolated, which results in fewer .dll
conflicts.
Private components By default, components are installed into the application
directory. Therefore, you can only use it in that
application.
Side-by-side versioning You can have more than one copy of a component on a
computer, which can prevent versioning problems.
XCOPY deployment Self-describing components can just be copied to the target
computer.
On-the-fly updates .dlls are not locked when in use and can be updated by an
administrator without stopping the application.
Global assembly cache You can share assemblies between applications by
installing them into the global assembly cache. This can
also increase performance because only one copy of the
assembly is loaded.
Module 10: Deploying Applications 13
Copying Projects
Topic Objective
To discuss the simplest
method of distributing an
application. Copying a project
Lead-in There is an extra menu command for Web applications
Distributing applications can
be as simple as using the You can copy a project directly to a Web server
MS-DOS XCOPY
command. However, this Using the XCOPY command
method does have certain
restrictions. Use the DOS command
You can use it for any type of application
Copying a Project
When you are working with a Web application, you have an extra menu item
available, Copy Project, which allows you to copy the project directly to a
Web server. You can specify the access method, for example with Microsoft
FrontPage® Server extensions, and whether to copy just the necessary
application files, the entire project, or all files in the project directory.
Consider the following facts when using the Copy Project command:
Assemblies are not registered for unmanaged client access.
The locations of assemblies are not verified.
Deploying Projects
Topic Objective
To provide an overview of
the deployment options
available. Windows Installer
Lead-in Is used for Windows-based and Web-based deployment
The Windows Installer
contains many features that Copies all required files and registers components
enhance the deployment of
your applications. Configures IIS for Web-based applications
Merge modules
Are used for reusable components
Are included in an .msi file
Windows Installer
You can use the Windows Installer to package all your data and installation
instructions in one file, an .msi file, for easy distribution. Using the Windows
Installer provides the following advantages:
Support for the Zero Administration initiative for Windows
This helps overcome the problems of overwriting shared components.
Safe uninstall options
Windows Installer provides an uninstall program that detects shared
components and does not remove them.
Rollback
If the install fails before it is complete, for example, if the connection to the
network share containing the source files is lost, then the Windows Installer
will return the computer to its original state.
You can use the Windows Installer to package both Windows-based and Web-
based applications.
Module 10: Deploying Applications 15
Merge Modules
You can use merge module projects to package shared components that will be
used by more than one application on the target computer. You can then
incorporate these modules into .msi packages whenever that component is used
in a solution. Using merge modules has the following advantages:
Eliminates versioning problems
Captures the dependencies of the component
Creates reusable setup code
16 Module 10: Deploying Applications
Cab Project Use this to create compressed CAB files for downloading
from a Web server.
Merge Module Project Use this to create a setup for a shared component.
Setup Project Use this to create a setup for a Windows-based
application.
Setup Wizard Use this to initiate the Setup Wizard that leads you
through the steps of creating one of the four main
deployment projects.
Web Setup Project Use this to create a setup for a Web-based application.
Module 10: Deploying Applications 17
Deploying Applications
Topic Objective
To provide an overview of
the topics covered in this
lesson. Creating a Merge Module Project
Lead-in Creating a Setup Project
Deploying Windows-based
and Web-based applications Using the Editors
is actually a very similar
process. Creating Installation Components
Deploying the Application
Prerequisites
Before working on this lab, you must have:
Knowledge of the merge module project template.
Knowledge of the deployment editors.
Knowledge of the setup project template for Windows-based applications.
Scenario
In this lab, you will create a merge module project to package a component
assembly.
Exercise 1
Packaging the Component Assembly
In this exercise, you will create a strong name for a component assembly and
then package the component in a merge module project that is ready for
deployment with the client application.
Both project types start in the File System Editor window, which you use to
specify where to install the included files on the target computer. You can
allocate files, folders, shortcuts, and components to these folders. For example,
you can include a ReadMe.htm or a merge module project containing a shared
component in these folders. In addition to using the default folders, you can
also use a predetermined set of special folders (for example the Windows
folder), and you can also create your own subfolders.
Web Application Folder Use this to place files in the default folder for the Web
application. By default this will be
http://ComputerName/ProductName
Module 10: Deploying Applications 25
Registry
This gives you access to the commonly used registry hives and keys, such as
HKEY_CURRENT_USER\Software and HKEY_LOCAL_MACHINE\
Software. These vary according to whether your application is a Windows-
based or Web-based application. In this editor, you can define your own keys
and write their default values during the installation process.
26 Module 10: Deploying Applications
File Types
This editor allows you to define new file types to be configured on the target
computer and the actions associated with those types.
User Interface
This editor lists the windows in the Installation Wizard that the user sees and
allows you to customize the messages and images displayed in them. You can
customize both the standard and administrative installation programs.
You can also add extra dialog boxes to the installation process. For example,
you can request user preferences with text boxes and option buttons, request
user information for registration purposes, or display license agreements.
Custom Actions
This allows you to include custom actions within your main setup program.
These can be actions performed at install, commit, rollback or uninstall time.
They can include running any executable file, .dll, or script file; adding users to
or removing users from a database; or adding a support contact to the address
book in Microsoft Outlook®.
Launch Conditions
This editor allows you to define conditions for installing the application or
performing custom actions. For example, if a database is not present on the
server, you will not want to add users to it and may not want to install the
application. You can check for files, registry keys, and Windows Installer
installations. You can also customize the message given to the user if the
condition is not satisfied.
Module 10: Deploying Applications 27
The Visual Studio .NET installation process allows you to create these
components on the target computer as part of your application installation
process. You accomplish this by using installation components.
You can set the properties of any component. These properties include elements
such as the name of an existing message queue or name of the log. When you
want to deploy your application, you can create ProjectInstaller files that copy
all the settings for your component and re-create it on the target computer at
installation time.
Module 10: Deploying Applications 29
Delivery Tip
Ensure that students
understand that this is a
simple application created
for demonstration purposes.
It is the solution to Lab 7.1
of Course 2373B,
Programming with Microsoft
Visual Basic .NET.
Module 10: Deploying Applications 31
Prerequisites
Before working on this lab, you must have:
Completed Lab 10.1.
Knowledge of the deployment editors.
Knowledge of the setup project template for Windows-based applications.
Scenario
In this lab, you will deploy a Windows-based application. You will begin by
creating a Windows Installer package that includes the merge module that you
created in the previous lab and the client application. Then, you will deploy the
application and ensure that it installs all sections successfully.
Exercise 1
Creating a Windows Installer Project
In this exercise, you will create a Windows Installer project for a client
application. This will include the merge module that you created in the previous
lab. You will create shortcuts for the application on the desktop and All
Programs menu and include a ReadMe file in the distribution.
Exercise 2
Running the Installation
In this exercise, you will run the Windows Installer project that you created in
the previous exercise and verify that it installs correctly.
Review
Topic Objective
To reinforce module
objectives by reviewing key
points. Describing Assemblies
Lead-in Choosing a Deployment Strategy
The review questions cover
some of the key concepts Deploying Applications
taught in the module.