Monday, March 1, 2010

Click Once Deployment

Deployment term can mean an installation of software program on user’s machines. Microsoft Visual Studio 2008 provides several methods for deploying your application. A familiar technology we all know is Microsoft Installer program which offers more detailed and complex deployment scenarios with multiple configuration steps. We’ll see another alternative light weight mechanism called ClickOnce.

Click Once Deployment features:

  • A ClickOnce setup can’t perform custom actions (accessing file system,registry, custom installation folder, custom setup wizard) when compared to extensive MSI setups. On the other hand, biggest gaining point is “Automatic update feature.”
  • ClickOnce applications are installed for a single user. You cannot install an application for all users on a machine. ClickOnce applications are always installed in a system-managed user-specific folder. You cannot change the folder where the application is installed.
  • ClickOnce setup can’t install shared components in the global assembly cache (GAC). ClickOnce apps are self-contained and isolated from rest of systems and runs no risk of breaking other apps.
  • By default, ClickOnce applications are self-updating. They can check for an update whenever they’re launched. ClickOnce usually is considered to be the preferred technology for WPF deployment.
  • ClickOnce technology supports stand alone deployments and deployments to web or file share. Many aspects of its behavior are completely fixed to guarantee a consistent user experience.
  • Clickonce deployment allows a user to launch a setup program from a browser page.
  • As you publish newer versions of your application, ClickOnce adds new subdirectories for each new version. The ClickOnce engine, dfsvc.exe, handles updates and downloads.The publishing wizard is a quick way to create a ClickOnce deployment
  • The key difference is that the publish version is the criteria that are used to determine whether a new update is available. If a user launches version 1.0.0.0 of an application and version 1.0.0.1 is available, the ClickOnce infrastructure will show the update dialog box. The Updates button isn’t available if you’re creating an online-only application. An online-only application always runs from its published location on a website or network share.
  • ClickOnce is a light weight setup option compared to MSI-based setups. Due to which, Click Once deployment doesn’t allow for much configuration and suitable for apps that don’t have elaborate installation requirements and have minimum security reqs. ClickOnce can deploy apps (WPF,Win Forms, page apps) in Full-Trust as well as partial trust apps(XBAP’s). 
  • ClickOnce supports two flavors of apps. i.e Online/Offline modes. If you choose to create an online-only available application, the user needs to return to the published location to run the application.   An old version of the application can’t be used after you roll out an update in online-only apps. This part of the deployment model is similar to a web application.
  • The publish.htm file is present only if you’re deploying to a web server. If you choose to publish for a CD installation, you don’t have the option of creating an online-only application.
  • In ClickOnce deployment, the .manifest and .application files store information about required files, update settings, and other details. These files are digitally signed at the time of publication, so these files can’t be modified by hand. If you do make a change, ClickOnce will notice the discrepancy and refuse to install the application.

Using Visual Studio:

 

You can deploy an application using ClickOnce directly from Visual Studio IDE using Publish tab of the project properties dialog box.

 

image

 

You can publish your app using ClickOnce by setting different publish properties in this page and then clicking “Publish Now” button.

Publish Location:

Specify the publishing location in Publishing Folder Location combo box. This can be a file path, a network file path, IIS path, a FTP address or external http address. Remember, Whatever value you specify, this will finally the go to location to install the app.

image

Installation folder:

Specify alternate Installation Folder URL if you’re planning to publishing to temporary location (staging) before it’s available for users to download.

Install Mode and Settings:

You can have your app available online which means app is available only when user is online OR you can make it offline. If you choose Online mode, app will be run directly from the publish location ensuring that the user always runs the most recent version. NO client installations!!

You can select “The Application is Available Offline As Well” to make app available both online and off-line. Anyways, local copy of app is available on client computer running offline.

Publish Wizard:

Clicking Publish Wizard makes things easy for you. If you like wizard like interface to configure your ClickOnce deployment, You’re lucky. A wizard will guide your through similar steps what we’re discussing to publish your application.

Options:

 

image

Clicking options button on publish dialog box brings up the above window. Obviously, you can set Publisher Name, the Product Name, the Support URL, and the name for the Deployment Web Page that is generated when the app is published.

Updates:

image

Clicking update button on publish dialog box brings up the above window. This is where magic happens. You can this window to specify whether app can check for updates automatically and time to check for updates.

Check “The application should check for updates” to enable app to check for updates. Either before app starts/after app starts we can check for updates. We can get into more granularity by specifying frequency for update check in terms of days.

You can also specify a minimum required  version for the application, and you can also specify a different location for updates if your updates are hosted in a location other than the install location.

Signing the ClickOnce manifests(.manifest/.Application)

image

Clicking the signing tab opens up the above shown window. You can use this window to associate a certificate/test certificate

with your application. You can use certificates to sign your ClickOnce based apps. You can also create Test certificate right from this window for signing.

 

Finally, Visual studio creates few criticial files like Application Manifest during ClickOnce deployment that describes the files and dependencies, identity of assemblies and file associations. We cannot configure File associations via Visual Studio user interface. To create a file association, we must edit the manifest file manually.

I missing screen shot of final publish.htm file that pops out when published from visual studio.