Title: Smart Client: RealWorld ClickOnce
1Smart Client Real-World ClickOnce
- Adam Cogan (AdamCogan_at_ssw.com.au)
2About Adam Cogan
Adam Cogan is the Chief Architect at SSW, a
Microsoft Certified Partner specializing in
Office and .NET Solutions.
- At SSW, Adam has been developing custom solutions
for businesses across a range of industries such
as Government, banking, insurance and
manufacturing since 1990 for clients such as
Microsoft, Quicken, and the Fisheries Research
and Development Corporation.
3Agenda 1
- ClickOnce The best of both worlds
- ClickOnce History Feel the pain
- Demo SSW Diagnostics
- Scenario with Mr Northwind
- ClickOnce
- Prerequisites
- Deployment
- Update
- Security
- Demo Click Once application
- Advanced
- Test Pleasestaging Custom Rollouts
- Adding Custom Prerequisites
- Scalability
- Cache and Size
- Localization
4Agenda 2
- Bugs
- Proxy Servers on Client Machines
- Publish Version sync issues
- Warnings
- ClickOnce and non-IE Browsers
- File Patching and Rebuilds
- Manifest Overwriting
- File Compression
- Suggestions Missing Features
- Things to do now Moving your Application to
ClickOnce - Limitations Overview
5ClickOnceThe Best of both Worlds
Click Once
Windows Forms
Web Forms
Rich UserExperience
NetworkDependency
Tough ToDeploy
Easy To Update
Offline Capable
Tough To Update
Limited UserExperience
Easy To Deploy
High User Productivity
Easy To Manage
Fragile DLL Hell
Responsive Flexible
Complex To Develop
6History
- Remember the good old Windows Installer?
- Lets compare it to ClickOnce
7History Feel the pain Windows Installer vs
ClickOnce
8History Feel the pain.Net 1.x HREFing .EXEs
- The.NET Framework must be already installed
- Your application will run on the client as
partially trusted code only. - Bad performance as the executable will try to
load several DLLs with localization resources - No way to guarantee that all your files are
indeed downloaded your client may be stuck with
a "half updated" application. - Only available offline if you are Working
Offline - Your application won't have a shortcut in the
desktop or the Start menu.
9History Feel the painUpdater Application Block
- You must change your application substantially in
order to use it - It runs as a fully trusted local application, so
it pretty much ignores code access security - It's not supported by Microsoft.
- Since it uses BITS to download the application
pieces, it does not run under Windows 98/ME. - However, Jamie Cool has a work around .NET
Application Updater Component http//www.windowsf
orms.net/articles/appupdater.aspx
10Demo
11DemoScenario with Mr Northwind
- Mr Northwind wants
- SQL Server is an application prerequisite
- Users to be able to rollback to a previous
version - Only allow users to have 3 versions back
- Users have dial-ups, run updates in the
background - Publish to a unix machine via FTP
12ClickOnce DeploymentHow it works?
- Architecture based on two XML manifest
- files
- Application manifest
- Describes the application itself, assemblies, the
dependencies and files that make up the
application, the required permissions, and the
location where updates will be available. - Deployment manifest
- Describes how the application is deployed,
including the location of the application
manifest, and the version of the application that
clients should run
13ClickOnce DeploymentStrategies
- Install from the Web or a Network Share
- (Default Strategy) (a Setup.exe)
Install from a CD (a Setup.exe)
Run the Application from the Web or a Network
Share (like a Link not really)
14ClickOnce DeploymentHow it works?
- Users download either
- 1. Setup.exe (500kb) checks pre-requisites
(Recommended) - 2. .Application manifest (small, does not check
prerequisites) - Q\ Which way?
- A\ Depends on pre-requisites
- Q\ What if the only pre-requisite is .NET 2?
- A\ Request.Browser.ClrVersion
15ClickOnce Deployment Prerequisites
- Before installing an application on a client
computer, ClickOnce will examine the client to
ensure that it has certain requirements specified
in the application manifest. - These include
- The minimum required version of the CLR
- The minimum required version of the Windows OS
- The minimum version of any and all assemblies
that must be preinstalled in the GAC
Note 1 If you specify an alternate prerequisite
location, the packages must exist there these
errors are not handled with ClickOnce Note 2
While selecting your prerequisites, keep in mind
that prerequisites might need administrator
privileges to be installed.
16ClickOnce Deployment Prerequisites
- Missing prerequisites must be installed using
separate redistributable packages. - The deployment tools in Visual Studio let you
install the .NET Framework and other
redistributables as a part of your installation
(bootstrapping). - Note Prerequisites can be downloaded
- beforehand into a network location
- to avoid redundant prerequisite
- downloads on networks
17ClickOnce Deployment Strategies Compared
Eg. Pass the Registration
18ClickOnce DeploymentSetup Interface
19ClickOnce DeploymentSetup Options Interface
20ClickOnce UpdateHow it works?
- ClickOnce uses the file version information
specified in an application's deployment manifest
to decide whether to update the application's
files. - After an update begins, ClickOnce uses a
technique called file patching to avoid redundant
downloading of application files. - File patching (has it been changed?)
- Compares the hash signatures of the files
specified in the application manifest for the
current application against the signatures in the
manifest for the new version.
Note 1 If you use Visual Studio to compile your
application, it will generate new hash signatures
for all files whenever you rebuild the entire
project. Note 2 File patching does not work for
files that are marked as data and stored in the
data directory C\Documents and
Settings\AdamCogan\Local Settings\Apps\2.0
21ClickOnce UpdateStrategies
- Checking for Updates after Application Startup
- background thread will run to locate and read the
deployment manifest - best for low-bandwidth network connections or for
larger applications - Specifying Update Intervals
22ClickOnce UpdateStrategies
- Checking for Updates before Application Startup
23ClickOnce UpdateStrategies
24ClickOnce UpdateBlocking
- Want more control over the update?
- You may block update checking altogether and
provide UI for updates using Deployment API in
your application
25ClickOnce UpdateOptional and Required Updates
- For optional updates, the user can either accept
or skip the update.
This dialog will not appear when an update is
required. To make an update required in Visual
Studio 2005, you need to set the Minimum Required
Version field in the Updates dialog box to match
the version of the application youre currently
publishing We recommend just 4 prior versions
26 27AdvancedRolling back updates
- The latest 2 versions of the application are
stored, the rest are removed. - Clients may restore 1 application update.
28ClickOnce Security
29ClickOnce SecurityPartial Trust Permission
Settings
- Custom Permission settings can be set for the
following
30Demo
- Considering Mr Northwinds Scenario, we will
- Configure in VS.NET
- Install the application
- Update to a new version
- Rollback to a previous version MAN
31Test Please
- To do a test please, you must change
- Publication Versions
- Publication URL
- Installation URL (if changed)
- Updates URL (if changed)
32- SCREEN CAPTURE
- - FROG
- - www.ssw.com.au
33AdvancedStaging Custom Rollouts
- Other Options
- Option 2
- Use the System.Deployment APIs, you could build
your own custom logic for determining when an
application should update use the APIs to
instruct ClickOnce to do an update at the
appropriate time. - Option 3
- Have server side logic that dynamically decides
which version of an application a user should
have returns an appropriate deployment manifest
for that user user.
34AdvancedAdding Custom Prerequisites
SharePoint 2007 (Beta2) hopelessly shows this
message for its prerequisite Windows Workflow
Foundation Beta 2 We need to do better!
- To create your own package, you must have/create
- 1. redistributable component in the form of an
EXE or MSI file - 2. Product manifest, product.xml
- 3. Package manifest(s), package.xml
- All prerequisite packages are stored inProgram
Files\Microsoft Visual Studio 8\sdk\v2.0\BootStrap
per\Packages\ - Typical Directory Structure
- Reference http//blogs.msdn.com/harsh/archive/2006
/05/31/611133.aspx
35AdvancedAdding Custom Prerequisites Product.xml
- Sample
- ltProductxmlns"http//schemas.microsoft.com/devel
oper/2004/01/bootstrapperProductCode"SSW.NewPrer
equisite.1.0"gt - ltRelatedProductsgt
- ltDependsOnProduct Code"Microsoft.Net.Fram
ework.2.0" /gt - lt/RelatedProductsgt
- ltPackageFilesgt
- ltPackageFile NameSSWNewPrerequisiteChk.e
xe"/gt - lt/PackageFilesgt
- ltInstallChecksgt
- ltExternalCheck Property"SSWNewPrerequisit
eInstalled" PackageFile"SSWNewPrerequisiteChk.exe
"/gt - lt/InstallChecksgt
- lt/Productgt
36AdvancedAdding Custom Prerequisites Product.xml
- ltProductgt
- ltRelatedProductsgt Lists products that depend
upon or are included in the
current product - ltDependsOnProductgt Dependant products not
included - ltIncludesProductgt Dependant products included
in this package - ltPackageFilesgt
- ltPackageFilegt A file in the package. Specifies
Name, Path, Remote location and public key - ltInstallChecksgt
- ltAssemblyCheckgt Checks that an assembly exists
in GAC - ltExternalCheckgt Executes external program and
check exit code - ltFileCheckgt Checks file exists, and returns
version number - ltMsiProductCheckgt Check msi installation is
complete - ltRegistryCheckgt Check registry key value
- ltRegistryFileCheckgt check file version in
registry
37AdvancedAdding Custom Prerequisites Package.xml
- ltPackagegt
- ltPackageFilesgt
- ltPackageFilegt A file in the package. Specifies
Name, Path, Remote location and public key - ltCommandsgt
- ltCommandgt Run/install a package.
- ltInstallConditionsgt Conditions for
bypassing, installing and failing - ltBypassIfgt
- ltInstallIfgt
- ltFailIfgt
- ltExitCodesgt Logic for response to exit
codes - ltStringsgt String array containing all possible
string messages - ltStringgt
- ltSchedulesgt
- ltSchedulegt Defines when certain commands are to
run - ltBuildListgt Execute immediately after
bootstrapper starts - ltBeforePackagegt Execute before the
specified package is installed
38AdvancedScalability
- Server Processing is fineNormal activation of a
ClickOnce application is very inexpensive for
the server network - Bandwidth is an issueConsider network bandwidth
needed for initial application deployment
application updates - However, the standard methods techniques used
to scale web or file servers can be used for
ClickOnce applications (e.g server farms, etc)
39AdvancedCache
- Location for ClickOnce applications
- On XP userprofile\Local Settings\Apps
- On VISTA userprofile\AppData\Local\Apps
- Cache quota is 250MB.
- Data files do not count toward this limit
- Modify by changing Registry key
- HKEY_CURRENT_USER\Software\Classes\Software\Micros
oft\Windows\CurrentVersion\Deployment\OnlineAppQuo
taInKB
Note The value in the OnlineAppQuoteInKB
registry key is a DWORD that expresses the cache
size in kilobytes
40AdvancedLocalization
- There are 3 ways to approach this
- Generate one deployment for each culture, with a
single satellite assembly included in each. - Drawback You must be careful to publish to a
different Web server directory or file share
directory each time - Include all satellite assemblies in a single
deployment. - Benefit creates a single deployment
- Drawback Downloads all assemblies
- Download satellite assemblies on demand.
- Drawback must be online
But, what is a satellite Assembly? Its an An
assembly containing localized resources for
another assembly
41BUGSProxy Servers on Client Machines
- Issue
- Clients accessing the internet through proxy
servers will get the error when launching the
application - The remote server returned an error (407) Proxy
Authentication Required - Default credentials to the proxy are not passed
through, ClickOnce attempts to download the files
without going through the proxy. - Workaround
- A hot fix is available from Microsoft to replace
the System.Deployment.dll or wait until the next
service pack comes out for .Net 2. You must
contact Microsoft for it. - http//support.microsoft.com/kb/917952
42BUGS Publish Version sync issues
- Issue
- The problem is that (rarely) the publish revision
number that Visual Studio has in memory sometime
gets out of sync with the publish revision number
that is stored is the user project file
(.xxproj.user). - Users would get the following
- Error 68 Publish failed with the following error
Could not find a part of the path - Workaround
- The easiest work around, which is to manually up
the publish revision number and choose File -gt
Save All.
43Warnings ClickOnce and non-IE Browsers
- Issue
- ClickOnce doesnt work on non-IE browsers (by
default). - ClickOnce provides IE with a mime handler
interface for the mime type application/x-ms-appli
cation which is associated with .application
files on servers hosting ClickOnce application. - So what happens in firefox?
- .application file is downloaded.
- If manifest contains relative paths, it will
fall over. - If it contains full paths, it will fail due to
security checks (in place by ClickOnce team). - Workaround
- Firefox There is an official Add-on
https//addons.mozilla.org/firefox/1608/ - Non-Firefox ClickOnce helper is an attempted a
solution, however it is not tested
http//www.softwarepunk.com/cohelper/ - Note The ClickOnce team will fix this in the
next release of the framework.
44Warnings File Patching and Rebuilds
- Issue
- The File Patching model for assemblies (even
strong assemblies) is based entirely on file
hash. - Projects when rebuilt in VS often cause the same
assemblies (exactly same source) to have
different hashes. Hence if you are rebuilding
your entire v2.0 solution its possible that
assemblies that have not changed in terms of
functionality will still have a different hash
and hence be downloaded again by ClickOnce
instead of being copied locally. - Workaround
- Dont hit rebuild unless you need to! (when
references mightve changed)
45WarningsManifest Overwriting
- Issue
- The manifest file for the ltAppNamegt.exe.manifest
is overwritten, causes strange compile errors
when included in the solution. - Workaround
- You dont need the manifest file in .Net 2 for XP
Styles. If you need it for any other reason, then
merge your manifest into the one built with
clickonce. - Note If you are running SSW Code Auditor, this
would not have been a problem ?
46Warnings File Compression
- Issue
- There are no file compression mechanisms in
ClickOnce. By default, your file will be
downloaded uncompressed across the
network/internet. - Workaround
- ClickOnce supports HTTP 1.1 compression. Simply
enable this on your web server the files
downloaded will be compressed.
47Suggestions Missing Features
- Rollback Feedback
- We want our clients to give us feedback as to why
they are rolling back a version - Rollback Count
- Clients should be able to rollback back to a
certain number of versions (set by the developer) - Version Download/Update/Rollback Stats
- What versions our clients are downloading,
updating to and rolling back from. Presented in
Reporting Services reports. - Microsoft should release MSN messenger as a
ClickOnce app. - Staged Rollout
- Specify beta testers, and grouped downloads via
authentication - eg. MSN Messenger could let MVPs and RDs get the
latest beta - We want 10 released each day, to manage
bandwidth and transition. - Scalability
- limit to x concurrent - the rest would not be
told of the new version until later.
48Moving your Application to ClickOnce
- You must consider
- What about your previous Windows Installer
installation on the client machines? - Suggestion Create a prerequisite that checks
for and uninstalls the previous versions. (or in
the start of your app) - Where is your data stored? ClickOnce uses
different App folders for each new version, for
each user. - Suggestion Use ApplicationData folder if the
settings are per user, otherwise
CommonApplicationData per application for all
users. - You must consider the Limitations
49Limitations Overview
- Installation of shared files, drivers, assemblies
in GAC, for multiple users, office addins, etc - Installation UI cannot be changed
- Add application to Startup group, Favorites menu
- Bootstrappers still need admin privileges if
there are prerequisite redistributables - Register file types
- No Updating via FTP
50References
- http//blogs.msdn.com/saurabh/archive/2006/03/02/5
41988.aspx - http//blogs.msdn.com/clickonce/
- http//blogs.msdn.com/saurabh/archive/2006/01/25/5
17613.aspx - http//blogs.msdn.com/winformsue/archive/category/
11821.aspx - http//www.softwarepunk.com/cohelper/
- http//msdn2.microsoft.com/en-us/library/142dbbz4.
aspx - http//www.windowsforms.net/FAQs/default.aspx?Page
ID3CategoryID24SubcategoryID27tabindex2 - http//forums.microsoft.com/MSDN/ShowPost.aspx?Pos
tID615033SiteID1 - http//www.code-magazine.com/article.aspx?quickid
0601041page3 - http//msdn.microsoft.com/library/default.asp?url
/library/en-us/dnreal/html/realworld12012004.asp - http//www.windowsforms.net/articles/appupdater.as
px - http//forums.microsoft.com/MSDN/ShowPost.aspx?Pos
tID173747SiteID1 - http//support.microsoft.com/kb/917952
512 things
52Thank You!