Visual Basic 2005 Guest Lecture

Download Report

Transcript Visual Basic 2005 Guest Lecture

Visual Basic 2005
Guest Lecture
ClickOnce Deployment
Objectives
•
•
•
•
•
•
•
•
•
Three ways to deploy a Windows application
How to use ClickOnce?
How to publish an application?
How to select the files that are published?
How to select the prerequisites?
How to set and update options?
How to set the publish options?
How to install an application?
How to update an application?
Three ways to deploy a Windows
application
• XCopy – the oldest way.
• Installs the application by copying the
directories to the user’s hard drive.
• Lets the user start the application by
double-clicking on the .exe file.
• You can do this with DOS XCopy
command or using Windows Explorer.
XCopy Disadvantages
• It doesn’t create a shortcut in the Start
Menu.
• It doesn’t provide a way to automatically
install prerequisite files (such as the .NET
Framework 2.0).
• It doesn’t provide an automatic way to
update the application.
• It doesn’t provide a standard way to
uninstall the application.
When to use XCopy?
• When you prepared copies of application
files on the users system.
• And also, you are prepared to update or
delete these files as necessary.
• Could be applied for simple applications
with just a few users.
How a Setup program works?
• Using Microsoft Software Installer (MSI) the second way to deploy an application.
• It creates a Setup program for the
application.
• Then you run Setup program from each of
the user’s computers to install the
application.
Setup program disadvantages
• Creating a Setup program requires a
significant work.
• It doesn’t have the automatic updating
features that’s available from ClickOnce.
Setup program: When to use?
• When ClickOnce isn’t adequate for your
project.
• Examples:
– If you need to install shared components in
the global assembly cache (GAS)
– If you want to modify the registry on the user’s
computer.
The global assembly cache
• Each computer where the common
language runtime is installed has a
machine-wide code cache called the
global assembly cache.
• The global assembly cache stores
assemblies specifically designated to be
shared by several applications on the
computer.
Setup Program
• Lets users specify the installation directory.
• Creates a shortcut for the application in the Start menu.
• Lets the user uninstall the application using the Add or
Remove Programs window from the Control Panel.
• Provides a way to automatically check for and install any
files needed by the application.
• Can be used to install shared components in the global
assembly cache (GAC).
• Can be used to modify the registry to install COM
components.
• Commonly used for commercial software that’s installed
from a CD.
• Is adequate for all but the most complex applications.
How ClickOnce works?
• The third way to deploy an application.
• Is new with Visual Studio 2005.
• ClickOnce creates self-updating Windows
applications (ClickOnce applications) that
can be installed and run with minimal user
interaction.
ClickOnce
• ClickOnce deployment overcomes three
major issues inherent in deployment.
Overcomes three major issues
• Difficulties in updating applications. With MSI,
whenever an application is updated, the user must
reinstall the entire application; with ClickOnce automatically.
• Impact to the user's computer. With MSI, applications
often rely on shared components, with the potential for
versioning conflicts; with ClickOnce, each application is
self-contained and cannot interfere with other
applications.
• Security permissions. Windows Installer requires
administrative permissions; ClickOnce allows nonadministrative users to install and grants only those
Code Access Security permissions necessary for the
application.
ClickOnce Advantages
• It creates a shortcut for the application in the
Start menu.
• It lets Add or Remove Programs window to
uninstall the application.
• It lets automatically update the application with
new versions.
• It provides a way to automatically check for and
install any files needed by the application.
• It provides the way to automatically distribute the
updates.
Feature
ClickOnce
Windows Installer
Automatic update
Yes
Yes
Update from Web
Yes
No
Does not affect shared
components or other
applications
Yes
No
Security permissions granted
Grants only permissions
necessary for the
application (more safe)
Grants Full Trust by default
(less safe)
Security permissions required
Internet or Intranet Zone (Full
Trust for CD-ROM
installation)
Administrator
Installation of shared files
No
Yes
Installation of drivers
No
Yes (with custom actions)
Installation to Global Assembly
Cache
No
Yes
Installation for multiple users
No
Yes
Add application to Start menu
Yes
Yes
Add application to Startup
group
No
Yes
Register file types
No
Yes
How to use ClickOnce
• Because ClickOnce is flexible and easy to
use, you can use it to deploy most of the
applications you develop.
• Before publishing, you can set a variety of
options that control how the application is
deployed (Publish page options).
Specifying Location
• You can publish your application:
– To a directory on a network server.
– To a Web site on a remote computer:
• You enter the location or click the ellipses button.
• To work with a remote web site, FrontPage Server Extensions
must be installed on the web server.
– To a directory on your hard disk or to a directory on an
FTP server.
• Then, users can install the application using a web
page that’s created when the application is
deployed.
Install Mode and Setting section
• By default, the application is available
offline meaning:
– It will be also installed on the user’s hard drive
– A shortcut will be added to the Start menu
– The application can be uninstalled using the
Add or Remove Programs window from the
Control Panel.
Online Option
• You can create an application that is only
available online, meaning:
– The user runs the application from the server
where it’s published.
– The user must be able to establish a
connection to the server.
– Because the application is downloaded from
the server each time it’s run, it will start more
slowly than offline.
To publish an application:
• Double-click My Project in the Solution
Explorer to display the Project Designer
and then display the Publish page.
• Enter the location.
• Set other options.
• Click the Publish Now button.
Project Designer
Publish Page
The version of an application
• By default, the version is incremented
automatically each time you publish it,
initial is set to 1.0.0.0.
• Or you can set the version manually in the
Publish Version section and remove the
check mark from the Automatically
Increment Version option.
More options: Publish Wizard
• You can also use the Publish Wizard to
publish an application.
• This Wizard lets you specify where the
application will be published and whether
the application will be available offline.
Publish Wizard
Right-click on the project in the Solution Explorer
window and select Publish
Publish Now
• The Publish Now button publishes the
application.
• A web page is created for installing the
application.
• So you can install and test the application
on your own computer.
How to select the files that are
published
• The Application Files dialog box will list the
output files and indicates which ones will
be published.
• By default, only the .exe file will be
published.
• If you want to publish the .pdb and .xml
files as well, you can select the Include
option from the Publish Status drop-down
list.
Application Files dialog box
How to select the prerequisites
• The Prerequisites dialog selects the
components that must be installed for the
application to work correctly.
• To run any Visual Basic 2005 application,
for example, the .NET Framework 2.0
must be installed on the user’s computer.
• Because of that, .NET Framework 2.0 is
selected by default.
Prerequisites dialog
How to select the prerequisites
• In some cases, additional components will
be required.
• By default, the components you select are
downloaded from the vendor’s web site
and then installed by ClickOnce.
• For example, if SQL Server Express is
needed, it’s downloaded from Microsoft’s
web site.
How to select the prerequisites
• If you select the second option in the
Prerequisites dialog box, the components
will be downloaded from the same location
as the application.
• If you make the components available
from another location, you can also use
the third option to specify that location.
How to set the update options
• To set how an application is updated, you
use the Application Updates dialog box.
• To display this dialog box, you click the
Updates button.
Application Updates dialog box
How to set the update options
• By default, an application checks for updates
each time the user runs it. But you can also have
it check at the interval of days.
• Then, if an update is available, a dialog box is
displayed that lets the user install the update.
• If you don’t want an application to check for
updates, you can remove the check mark from
the check box at the top of the Application
Updates dialog box, although that’s not likely.
How to set the update options
• You can also use the Application Updates
dialog box to specify the lowest version
number that must be installed.
• Then, when the user runs the application,
if that version or a higher version hasn’t
been installed, it’s installed automatically.
How to set the update options
• Finally, the Application Updates dialog box
lets you specify where application updates
are located.
• In most cases, you’ll publish the updates
to the same location as the application, so
you can leave this option blank.
How to set the publish options
• The Publish Options dialog box, which is
displayed when you click the Options
button lets you set a variety of options.
• In most cases, you’ll specify at least a
publisher name and the product name.
• Then, the values you specify determine
how the application appears in the user’s
Start menu.
Publish Options
How to set the Publish Options
• If you include a support URL, an online
support item that displays the specified
web page is added to the Start menu.
• This option will appear in the Support Info
dialog box in the Add or Remove
Programs window.
How to set the Publish Options
• Next option affects the web page that’s
generated when you publish an application.
• By default, this page is named Publish.htm, but
you can change the name (not the extension).
• You can also specify whether this page is
generated each time the application is published
and whether it’s displayed after the application is
published.
How to install an application
• In most case, you’ll leave the remaining
options in the Publish Options dialog box
as their default settings.
• Once you publish an application, users
can install it simply clicking the Install
button in the generated web page.
How to install an application
• When the user installs or runs the
application, a Launching Application dialog
box is displayed.
• Then, if the application doesn’t come from
a trusted source, a dialog box with a
security warning is displayed.
• Before you publish the final release, you’ll
want to eliminate the warning by installing
a valid certificate for the publisher of the
application.
How install an application
How to update an application
• The dialog box displayed when a user runs an
application and an update is available.
• The user can click the OK button to install the
update or the Skip button to skip the installation.
• If the update options specify a minimum required
version and the user doesn’t have that version
installed, the Update Available dialog isn’t
displayed.
• Instead, the update is installed automatically.
How to configure Required
Permissions
• You can configure additional ClickOnce
permissions on the security tab of the
project properties page.
• You can either manually select
permissions, or can calculate them and
configure the application to request those
permissions.
Security Tab
To calculate permissions:
1. On the Security properties page, select
the check box Enable ClickOnce Security
Settings.
2. Choose the radio button This Is A Partial
Trust Application.
3. Click the button Calculate Permissions.
4. The permissions are added to the
permissions that will be requested by
your application upon install.
To manually configure permissions:
1. On the Security properties page, select the
check box Enable ClickOnce Security Settings.
2. Choose the radio button This Is A Partial Trust
Application.
3. In the Permissions Required By The
Application table, find the permission of
interest.
4. In the Setting column, choose Include to
include the permission as required or Exclude
to not required the permission.
User Approval
• Any permissions not included in the Zone
permission set under which the application
is installed must be approved by the user
before installation is completed.
Question
• To what location can you publish a
ClickOnce application?
• Answer: to a file path, a network share, an
HTTP address, or FTP address.
Question
•
Which of the following are required to
install an application that has been
published to a sever for distribution by
using ClickOnce technology?
a. You must manually configure permissions.
b. You must click the setup project.
c. You must specify how frequently to check for
updates.
d. You must configure the install mode.
Question
• What is the default security mode that a
ClickOnce application run from an Internet
Web page will run under?
a. Full trust
b. Intranet Zone
c. Internet Zone
d. Custom Zone
Summary
• ClickOnce is a powerful new deployment
technology that enables developers to
quickly and reliably publish application to
Web sites, file shares, or FTP sites.
• ClickOnce applications can be configured
to automatically find and install updates.
• You can configure an application to look
for updates every time it is run or at a
predetermined interval.
Summary
• By default, ClickOnce applications are run under
the Internet security zone if downloaded from the
Web or under intranet security zone if
downloaded from a file share.
• If additional permissions are required they can
be set by the developer, either manually or by
calculating the required permission set, and they
can than be approved or denied by the installer.
• Installing a ClickOnce application is a simple as
clicking the Setup file or the Install button on a
Web page and following the installations.