Monday, May 21, 2007

Deploying Windows Applications

Define Deployment?
Deployment is the process of installing applications to the target systems. Traditionally such an installation has been done by invoking a setup program. If hundred or thousand clients must be installed, the installation can be very time consuming. To alleviate this, the system admin can create batch scripts to automate this activity.

What is DLL Hell problem?
DLL hell describes the problems that happen when each of several installed applications require different versions of the same DLL. If one application installs a DLL that overwrites a different version of the same DLL, applications requiring the overwritten DLL might break.

How is the .NET DLL Hell avoided?
The .NET DLL hell is avoided by using the private and shared assemblies. Private assemblies are copied with every application, so there cannot be a conflict with assemblies from other applications. Shared assemblies have strong name that includes the version number. Multiple versions of the same assembly can coexist on the same system.

No-touch Deployment: the .NET 1.0 supported a technology known as no-touch deployment. With no-touch deployment, it was possible for the user to automatically install an application by clicking a link on a Web page. However, .NET 1.0 no-touch deployment had some complexity because of security issues, and it was missing many features that are required with many client applications – clearly this was a version 1 release. These issues are solved with the ClickOnce deployment technology that is new with .NET 2.0.

xcopy deployment: Simple application can be installed with a simple xcopy deployment, but for installation to hundreds of clients, an xcopy deployment is not really useful. For this you have two options:
1. ClickOnce deployment
2. Microsoft Installer

ClickOnce deployment: with this the application can be installed automatically by clicking a link inside a Web page. The user on the client system doesn’t need administrative privileges, as the application is installed in a user-specific directory.
· With ClickOnce you can install applications with a rich user interface.
· After the application is installed to the client, the client can be offline – there is no need for the client to access the server where application was installed from
· Application can be used offline
· The updates can happen automatically when the client application starts or as a background task while the client application is running.
· The installation can be done from a website, a UNC share, or a file location.
· The application is installed on the client system, it is available with Start menu shortcuts, and it can be uninstalled from the Add/Remove Programs dialog.

ClickOnce deployment is described by manifest files.
· The application manifest describes the application and permissions required by the application.
· The deployment manifest describes deployment configuration such as update policies.
Successfully deploying the assembly across the network requires that the manifest that is used with the installation must have a certificate associated. The certificate shows for the user installing the application about the organization that created the installation program.

How is the ClickOnce deployment different to no-touch deployment?
With the ClickOnce deployment, an application icon is available from the Start menu, the security issues are easier to solve, and the application can easily be uninstalled.

What are the restrictions with the ClickOnce deployment?
ClickOnce cannot be used
· if you need to install shared components in the GAC
· if the application needs COM Components that require Registry settings
· if you want the user to decide in what directory the application should be installed.
In all the above restriction cases, you must use the Windows Installer. The Windows Installer is the traditional way to install windows applications.

Why do you need to create a Test Certificate that is associated with the ClickOnce manifests?
A certificate is used that the user installing the application can identify the creator of the installation package. By reading the certificate, the user can decide if he can trust the installation to approve the security requirements.
Note: with the test certificate, if the user doesn’t get real trust information and receives a warning that “this certificate cannot be trusted”. Such certificate is for testing only. Before you make the application ready for deployment, you have to get a real certificate from a certification authority such as Verisign. If the application is deployed only within the Intranet, you can also get a certificate from a local certificate server. For ex: the MS Certificate server can be installed with Windows Server 2003.

How are the required permissions defined with ClickOnce deployment?
How do you Calculate Permissions that is associated with the ClickOnce Security Settings?
The .NET uses evidence-based security to define what assemblies are allowed to do.
· Resources should be secured (Exs of resources are: files, directories, networking sockets, and environmental variables. For all these resources, .NET permissions exist that allow access to them. Ex is the FileIOPermission class, which is used to allow access to the complete file system or to specific files and directories.
· Must define who is allowed to use these resources. Exs of such groups are assemblies that are installed locally, or loaded from the n/w.
With the Calculate Permissions from the Security Properties of VS, analyzes the code used by the application to check the application’s permission requirements.

Note: with the defined security requirements, you can start to publish the application by creating a deployment manifest. This can easily be done with the Publish Wizard.

What does the Publish Wizard do?
The Publish Wizard creates a website on the local Internet Information Services Web server. The assemblies of the application (exe & dlls) as well as the application and deployment manifests, a set.exe and a sample webpage, publish.htm are copied to the webserver

Note: the application will be available online or offline by selecting its option. This way the application is installed on the client system and can be accessed from the start menu.
If you select that the application to be available only online, the user must always click the Website link to load the application from the server and start it locally.

What is an Update Policy?
The Update Policy is defined by a setting in the deployment manifest with the XML element >update>. You can change the update policy by clicking the Updates… button with the Publish Settings.
In the Application Updates dialog, you can define whether the client should look for updates. If updates should be checked, you can define whether the check should happen before the application starts or if the update should occur in the background while the application is running. If the update should occur in the background, you can set the time interval for them, with every start of the application or with a specific number of hours, days, or weeks.

What template is used for deploying Windows Applications?
In the Add New Project dialog, Other Project Types > Setup and Deployment > the Setup Project template is the one you will use. This template is used to create Windows Installer Packages, so it can be used for deploying Windows Applications.
Note: the Web Setup Project template is used to install Web applications.

When is the Merge Module Project template used?
The Merge Module Project template is used to create Windows Installer merge modules. A merge module is n installer file that can be included in multiple Microsoft Installer installation packages. For components that should be installed with more than one installation program, a merge module can be created to include this module in the installation package.
Ex is: .NET runtime itself. It is delivered in a merge module; therefore the .NET runtime can be included with the installer package of an application. You will use a merge module in the sample application.

When is the Setup Wizard template used?
The Setup Wizard is a step-by-step way to choose the other templates.

When is the Can Project template used?
The can project template allows you to create cabinet files. Cabinet files can be used to merge multiple assemblies into a single file and compress it. Since the cabinet files can be compressed, a Web client can download a smaller file from the server.

When is the Smart Device Cab Project template used?
The Smart Device Cab Project template can be used to create an installer package for smart applications.

Windows Installer Terms:
1. Packages
2. Features
3. Components
Note: In the Context of the Windows Installer, a component is not the same as a component in the .NET Framework. A Windows Installer component is just a single file (or multiple files that are logically belong together). Such a file can be an executable, a DLL or even a simple text file.

Package: consists of one or more features. A package is a single MS Installer database (MSI db).

Feature: is the user’s view of the capabilities of a product and can consist of features and components.

Component: is the developer’s view of the installation; it is the smallest unit of installation and consists of one or more files.

Differnce b/w features and components is:
· Single component can be included within multiple features
· A single feature cannot be included within multiple features

What are the advantages of the Windows Installer?
· Features can be installed, not installed, or advertised
· If an application becomes corrupt, it can self-repair through the repair feature of Windows Installer package
· An automatic rollback will be done if the installation fails. After the installation fails everything is left as before: no additional Registry Keys, no files, and so on, are left on the system
· With uninstall, all relevant files, Registry keys, and so on are removed—the application can be completely uninstalled. No temporary files are left out, and the Registry is also reinstated.
Note: you can read the tables of the MSI db files to find information about such things as what files are copied and what Registry keys are written.

What are the different files and directories should we use for building the installation program?
1. Files needed for the application
1. Documentation file
2. Readme.txt file
3. License file
4. Document template
5. Pictures
6. Configuration files

2. Directories should be used?
1. Application files should be installed in Program Files\Application name
2. With the installer, you can use a special predefined folder to put files in the Program Files directory.
Note: Under no circumstances should the directories be hard-coded. The Simple Editor will have the executable in the default application directory unless the installing user selects a different path.

3. How should the user access the application?
1. You can put a shortcut to the executable in the Start menu, or place an icon on the desktop.
Note: With Windows XP, the guideline is to have the desktop as clean as possible.

4. What is the distribution media?
1. Put the installation packages in a CD, floppy, disks or a network share.

5. What questions should the user answer?
1. Accept the license information
2. Show a ReadMe file
3. logo
4. Enter the path (directory) to install

When is it necessary to use the windows installer?
· if you need to install shared components in the GAC
· if the application needs COM Components that require Registry settings
· if you want the user to decide in what directory the application should be installed.
In all the above restriction cases, you must use the Windows Installer. The Windows Installer is the traditional way to install windows applications.

What are the different packaging options of the files that are installed?
The files that are to be installed are packaged with three options:
· As loose uncompressed files à stores all program and data files as they are. No compressing takes place
· In setup file à merges and compresses all the files into the MSI file. This file can be overridden for single components in the package.
· In Cabinet file(s) à with this method, the MSI file is used just to load and install the CAB files. With CAB files, it is possible to set file sizes that enable installations on CDs or floppy disks.

What different editors can you use to create a Windows Installer package using Visual Studio?
With a VS 2005 Setup Project you have six editors available. They are as follows:
1. File System Editor à is used to add files to the installation package.
2. Registry Editor à you can create Registry keys for the application.
3. File Types Editor à allows you to register specific file extensions for an application.
4. User Interface Editor à you can add and configure dialogs that are shown during installation of the product.
5. Custom Actions Editor à allows you to start custom programs during installation and uninstallation.
6. Launch Conditions Editor à you can specify requirements for your application, for ex, that the .NET runtime already has to be in place.

What is File System Editor?
With the File System Editor, you can add files to the installation package and configure the locations where they should be installed.
The editor is opened with the menu options View à Editor à File System.

What are the predefine special Folders in the File System Editor?
Some of the predefined special folders are automatically opened and they are:
· Application Folder
· User’s Desktop
· User’s Programs Menu
1. The Application Folder is used to store the executables and libraries. The location is defined as:
[ProgramFilesFolder]\[Manufacturer]\[ProductName]

2. The User’s Desktop Folder can be used to place the icon on the desktop. The default path to this folder is:
C:\Documents and Settings\username\Desktop à if the installation is done for single user
[or]
C:\Documents and Settings\All Users\Desktop à if the installation is done for all users

3. User’s Program Menu Folder: The user will usually start a program by starting it from the All Programs menu. The default path is:
C:\ Docuements and Settings\username\Start Menu\Programs
You can put a shortcut to the application menu. The shortcut should have a name that includes the company and the application name, so that the user can easily identify the application.
Note: do not put the uninstall program and help file in this menu.

Note: You can set the following properties of file in a folder:
1. Condition
2. Exclude
3. PackageAs
4. Permanent
5. ReadOnly
6. Vital
For Ex: You may want the readme file to be available for the user to read before the installation is started.
· So set the property PackageAs to vsdpaLoose, do that this readme file will not be compressed into the Installer package.
· Also set the ReadOnly property to true so that this file cannot be changed.

What is File Types Editor?
If your application uses custom file types and you want to register file extensions for files that should start your application when a user double-clicks them, you can use the File Types Editor.
The Editor can be started with View à Editor à File Types.
With the File Types Editor, you can configure a file extension that should be handled from your application. The extension has the following properties:
· Name
· Command
· Description
· Extension
· Icon

What is Launch Condition Editor?
With the Launch Editor you can specify some requirements that the target system must have before the installation can take place.
You can start the Launch Editor by selecting the menu View à Editor à Launch Conditions
This editor has two sections to specify the requirements:
· Search Target Machine à Specify what specific file or Registry key to search for
· Launch Conditions à defines the error message if the search is not successful

What are the different Launch Conditions you can define using the Action Menu?
1. File Launch Condition à searches the target system for a file you define before the installation starts.
2. Registry Launch Condition à allows you to require a check of Registry keys before the installation starts.
3. Windows Installer Launch Condition à search for Windows Installer components that must be present.
4. .NET Framework Launch Condition à checks if the .NET Framework is already installed on the target system.
5. Internet Information Services Launch Condition à checks for the installed IIS. Adding this launch conditions adds a Registry Search for a specific Registry Key that is defined when IIS is installed, and adds a condition to check for a specific version.

Note: By default, a .NET Framework Launch Condition is included, and its properties have been set to predefined values: the Message property is set to [VSDNETMSG], which is a predefined error message. If the .NET Framework is not installed, a message informing the user to install the .NET Framework pops up.

What is User Interface Editor?
With the User Interface Editor, you can define the dialogs the user sees when configuring the installation. Here, you can inform the user about license agreements and ask for installation paths and other information to configure the application.
You can start the User Interface Editor by selecting the menu View à Editor à User Interface

What are the two installation modes available in the User Interface Editor?
· Install Mode à used to install the application on a target system
· Administrative Install à install an image of the application on a network share. Afterward a user can install the application from the network.

What are the Default Dialogs in the User Interface Editor?
· Start
o Welcome
o Installation Folder
o Confirm Installation
· Progress
o Progress
· End
Note: The Default Dialogs will show up automatically at installation time, even if you never opened the User Interface Editor in the solution. But you should configure these dialogs so that useful messages for your application are displayed.

How do you add Additional or Custom Dialogs to the User Interface Editor?
You cannot design a custom dialog and add it to the installation sequence with the VS installer.
A more sophisticated tool such as InstallShield or Wise for Windows is required to do this – but with the VS installer, you can add and customize many of the predefined dialogs in the Add Dialog screen.

Selecting the Start Sequence in the User Interface Editor and choosing the menu options Action à Add Dialog, causes the Add Dialog to be displayed. All these dialogs are configurable. You can configure these dialogs by setting their properties.

No comments: