Wednesday, February 25, 2009

Smart Clients Applications : ClickOnce Deployement Features of VS.NET 2005

What is a Smart Client Application?


Smart client applications can be designed to combine the benefits of a rich client
Application with the deployment and manageability strengths of a thin client
Application, although the precise nature of the balance between the two approaches
Depends on the exact scenario.

Smart client applications often have very diverse requirements, and so vary greatly
In design and implementation. However, all smart clients share some or all of the
Following characteristics:

• Make Use of Local Resources
• Make Use of network Resources
• Support occasionally connected users
• Make use of network resources
• Support, Provide intelligent installation and update
• Provide client device flexibility




What is ClickOnce Feature of .NET 2005?


ClickOnce is a deployment technology that enables self-updating Windows-based applications that can be installed and run with minimal user interaction. Applications are published to a file share, Web Site, or media such as a CD.
Once published, ClickOnce apps can be automatically updated with minimal user input.
ClickOnce deployment overcomes three major issues inherent in deployment:
• Difficulties in updating applications. With Microsoft Windows Installer deployment, whenever an application is updated, the user must reinstall the entire application; with ClickOnce deployment, you can provide updates automatically. Only those portions of the application that have changed are downloaded, then the full, updated application is reinstalled from a new side-by-side folder.
• Impact to the user's computer. With Windows Installer deployment, applications often rely on shared components, with the potential for versioning conflicts; with ClickOnce deployment, each application is self-contained and cannot interfere with other applications.
• Security permissions. Windows Installer deployment requires administrative permissions and allows only limited user installation; ClickOnce deployment allows non-administrative users to install and grants only those Code Access Security permissions necessary for the application.




The core ClickOnce deployment architecture is based on two XML manifest files: an Application manifest file and a Deployment manifest file.

The application manifest describes the application itself, including the assemblies, the dependencies and files that make up the application, the required permissions, and the location where updates will be available. The application developer authors the application manifest by using the Publish Wizard in Visual Studio 2005 or the manifest generation tool (Mage.exe) in the .NET Framework SDK.

The 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. An administrator authors the deployment manifest using the manifest generation tool (Mage.exe) in the .NET Framework SDK.
To make a ClickOnce application available to users, you must publish it to a Web server; file share, or removable media. You can publish the application using the Publish Wizard; additional properties related to publishing are available on the Publish page of the Project Designer or you can publish the application on the server manually.


To Publish to Web Using Publish Wizard


1. In Solution Explorer, select the application project.
2. Right-click the project node and choose Publish. The Publish Wizard appears.
3. On the Where do you want to publish the application? Page; enter a valid URL using the format http://localhost/foldername, then clicks Next.
4. In the “Will the application be available offline?” page, click the appropriate option:
o If you want to enable the application to be run when the user is disconnected from the network, click Yes, this application will be available online or offline. A shortcut on the Start menu will be created for the application.
o If you want to run the application directly from the publish location, click No, this application is only available online. A shortcut on the Start menu will not be created.
Click Finish to publish the application. Publishing status is displayed in the status notification area of the taskbar.

The above solution to deploy the ClickOnce applications is suitable for the Projects Where all the projects are under the same Project/Solution. It is not suitable for the projects in which all projects are separately built. Like in Our project there is a main logon application through which an user is login & then he/she will click on the applications available to that user and that application is executed. In this case we have to mention the start up exe file and dependent files in manifest files used for ClickOnce.The other way to publish your application on the Web Server is to manually create your application & deployment manifest file using a command line toll mage.exe provided by the .NET SDK.






To Publish the application manually on Web Server


To publish your application on the Web Server without using the publish wizard is little bit tricky. For this you have to follow the steps given below:

STEPS:
1. Please create one folder under wwwroot folder for example YourClickOnceApplication.
2. Create one subfolder under YourClickOnceApplication for example YourClickOnceApplication _1_0_0_0 since first time you are publishing application.
3. Copy your .exe, .dlls, resource files\folders & config files from bin\Release folder into YourClickOnceApplication _1_0_0_0.
4.Go to Start-->Program-->Microsoft .Net Framework SDK v2.0-->SDK Command Prompt & type MageUi.exe one window will open,

Mageui Screen.


5. Create a new application manifest by selecting File, New, Application Manifest from the menu.
6. On the default Name tab, enter the name and version number of this deployment.
7. Select the Files tab and click the Browse... button next to the Application Directory text box.
8. Select the directory containing your application files that you created in step 2, and click OK on the folder selection dialog box.
9. Click the Populate button to add all your application files to the file list. If your application contains more than one executable file, mark the main executable file for this deployment as the startup application by selecting Entry Point from the File Type drop-down list. (If your application only contains one executable file, MageUI.exe will mark it automatically for you.). To have a custom icon displayed in your ClickOnce application the icon must be deployed with the application and the file must be specified as the value for the iconFile attribute in the .exe.manifest file.
10. Select the Permissions Required tab and select the level of trust you need your application to assert. The default is Full Trust, which will be suitable for most applications.
11. Select File, Save from the menu, and save the application manifest. You will be prompted to sign the application manifest when you save it. Save it in folder created in step 2 (i.e. under YourClickOnceApplication _1_0_0_0 folder).
12. Select File, New, Deployment Manifest from the menu to create your deployment manifest, and then on the Name tab, supply a name and version number (1.0.0.0 in this example).
13. Select the Publisher tab, and supply values for Publisher and Product. (Product is the name given your application on the Windows Start menu when you install your application locally.)
14. Switch to the Deployment tab, Select the Application type as Install locally & give the URL of the virtual directory which u have created in step1 named YourClickOnceApplication like here you can give like http://localhost/ YourClickOnceApplication/YourAppName.application.
15. Switch to the Update tab, and specify how often you would like this application to update. If your application uses the ClickOnce Deployment API to check for updates itself, clear the check box labeled this application should check for updates if not check the checkbox Also you can define the way your application will self update.
16. Switch to the Application Reference tab. You can pre-populate all of the values on this tab by clicking the Select Manifest button and selecting the application manifest you created in 9th step.
17. Choose Save and save the deployment manifest to disk. You will be prompted to sign the application manifest when you save it. Save deployment manifest in folder created in step 1 (i.e. under YourClickOnceApplication folder).
That’s it now browse .application file from location given in step 12 for example
http://localhost/ YourClickOnceApplication/YourAppName.application
Note: ClickOnce doesn’t support Fire Fox browser. To Support fire fox you have to install a plug-in provide on URL.


Applications distributed with ClickOnce do not get installed in the program Files folder. Instead they are placed in an Application cache that resides in the Local Settings folder under the current user’s Document’s & Settings Folder. By controlling this aspect of the deployment, multiple versions of an application can reside on the client pc at the same time.
All ClickOnce applications, whether they are installed locally or hosted online, are stored on the client computer in a ClickOnce application cache. A ClickOnce cache is a family of hidden directories under the Local Settings directory of the current user's Documents and Settings folder. This cache holds all the application's files, including the assemblies, configuration files, application and user settings, and data directory. The cache is also responsible for migrating the application's data directory to the latest version. Because of this it is very simple process to rollback a ClickOnce application to its previous version. If the user goes to the Add/Remove programs control applet, the dialog presented will have the choice of removing the ClickOnce application or the rolling back to the previous version. An administrator can change the manifest file to point to the previous version.
By default, client computers have 250 MB of storage for online ClickOnce applications. Data files do not count toward this limit. A system administrator can enlarge or reduce this quota on a particular client computer by changing the registry key, HKEY_CURRENT_USER\Software\Classes\Software\Microsoft\Windows\CurrentVersion\Deployment\OnlineAppQuotaInKB, which is a DWORD value that expresses the cache size in kilobytes. For example, in order to reduce the cache size to 50 MB, you would change this value to 51200.
When you need to deploy a new version of the application, you will need to create a new directory named after the new version—for example, YourClickOnceApplication _1_1_0_0 and move the new application files into that new directory. You should generate a new application manifest and store it in the new directory, and have the publisher sign the new manifest. Once you get the signed manifest back, you can use Mage.exe to update the deployment manifest and point it at the new application manifest:
mage -Update YourAppName.application -Version 1.1.0.0 -AppManifest YourClickOnceApplication _1_1_0_0\ YourAppName.exe.manifest
Now when you will run your application it will ask that a new version is updated on server whether you want to install or not. If you say yes then it will download the entire latest file from the server and reinstall the application on your system.

Now there are some issues with this manual deployment of ClickOnce application in comparison to deployment through wizard. Like
• When you deploy through wizard it creates an html page by itself to show the application manifest URL and user can easily navigate through this URL to install the ClickOnce application.
• Other thing is if you want to add some prerequisites with your ClickOnce application through wizard it is very easy task you have to just Click On prerequisites button and it will provide you to add the prerequisites list. Wizard automatically creates a ‘SetUp.exe’ which contain that prerequisite installation URL and settings related to those prerequisites.
• Next thing is wizard automatically create a certificate (myapplication.pfx) to sign your application & deployment manifest files.
• If you want to change anything in application or deployment manifest files then you have to again sign it with the certificate (licence) provided by the issuer.



We can do the above task manually in following ways when we are deploying the ClickOnce application manually as:

We can use windows built in facility to create the certificate files. Using makecert command we can create a certificate (.pfx) and after creating this file we can add this certificate in Clients certificates. The level of trust that is being requested is part of trust license configuration. A public key is used to sign the application must also be supplied to the license issuer. The trust licence is then embedded in the deployment manifest. The last step is to sign the deployment manifest with your own key pair. To Sign the application and deployment manifest we can use following commands as:

mage -s app manifest -cf cert_file -pwd password
mage -u deployment manifest -appm app manifest
mage -s deployment manifest -cf certfile -pwd password

To add the prerequisite for ClickOnce Deployment This should be added in application.exe.manifest file (Application Manifest file) for .NET 2.0 framework

Labels:

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home