Packaging a .NET Application for Deployment

Team-Fly    

Developing XML Web Services and Server Components with Visual C#™ .NET and the .NET Framework, Exam Cram™ 2 (Exam 70-320)
By Amit Kalani, Priti Kalani

Table of Contents
Chapter 11.  Deployment


Packaging an application means identifying all the individual files and settings for an application, and putting them together so that the application can be easily distributed and deployed on the target computers.

The choice of packaging depends on the nature of the application and its users. For installing simple applications, sometimes a tool as simple as the XCOPY command can be used. For sophisticated requirements, you might want to use a tool that creates a Windows Installer based setup package for the application.

Packaging an Application for Deployment by Copying the Files

Applications developed using the Microsoft .NET Framework do not generally use the Windows Registry for storing application-specific data and configuration settings. Instead, all settings are stored in XML-based configuration files.

It is possible to deploy such an application by copying all the build output and content files to a folder of your choice on the target computer. You can simply use the XCOPY command or use FTP if you are deploying across the Internet. Because the deployment process is nonintrusive and causes minimal changes on the target computer, it is also sometimes called zero-impact installation.

However, in some scenarios copying the files is not sufficient for deploying an application. Some common installation tasks that are difficult to do just by copying the files include the following:

  • For a Web service and a Web application, you also need to create a virtual directory on the Web server, set the virtual directory as an IIS application, and possibly configure security or other settings for the virtual directory.

  • For a Windows Service, you need to register the service with the Windows Service Control Manager.

  • For a serviced component, you need to register the component with the COM+ catalog.

  • You might need to take extra steps to provide for the application's integration with the user's desktop, such as creating shortcuts and Start menu entries.

  • You might need to add shared assemblies to the GAC.

  • You might need to copy files to relative paths on the target machine that differ from the paths on the source machine.

  • You might need to create or configure databases during the installation.

  • You might need to add custom event logs and performance counters to the target machine.

  • You might need to check whether the .NET Framework is installed on the target machine.

  • You might need to do license key management and user registration as part of the installation.

Using Microsoft Windows Installer to Package an Application for Deployment

Microsoft Windows Installer is an installation and configuration service that is built into the Windows operating system. It gives you complete control over the installation of an application, a component, or an update.

Windows Installer includes many built-in actions for performing the installation process. In addition to performing the standard actions, such as installing files, creating shortcuts to files, making Start menu entries, and writing Registry entries, Windows Installer offers several advanced features:

  • It enables you to take custom actions during application installation. For example, you might want to run a SQL script to install an application database during application installation.

  • It provides on-demand installation of features. This capability enables the user to later install an optional feature that was not installed during the application's initial installation.

  • It manages, repairs, updates, and uninstalls an application without breaking any other application that depends on it.

When you create an installation program for Windows Installer, you create a Windows Installer (.msi) package. When this package is executed on the target machine, Windows Installer installs the program by reading the installation information stored in the Windows Installer package.

Visual Studio .NET provides a category of projects called the Setup and Deployment projects to create setup packages by using Windows Installer. These packages are as follows:

  • Setup Project Used to create installation packages for deploying various types of applications, such as Windows applications, Windows Services, and console applications.

  • Web Setup Project Used to create installation packages for deploying Web-based applications such as an ASP.NET Web application or an XML Web service.

  • Merge Module Project Used to create installation packages for components that might be shared by multiple applications.

  • Cab Project Used to package ActiveX components so that they can be downloaded over the Internet. This type of project is largely obsolete.

Customizing Visual Studio .NET Setup and Deployment Projects

When you are creating a setup and deployment project, you might also want to provide custom features and perform custom actions while performing installation (for example, create Registry entries, provide a customized user interface for installation, perform custom actions, check for conditions to be satisfied for installation, create menu options and shortcuts, and so on).

Visual Studio .NET provides the following editors to customize various aspects of the installation process:

  • File System Editor The File System Editor provides a mapping of the file system on the target machine. Each folder is referred to with a special name that is converted to represent the folder on the target machine during the installation process. For example, at the time of installation, the special folder User's Desktop will be converted to the actual desktop path on the target machine.

    You can add files to various special folders, such as the Application folder, Common Files folder, Program Files folder, the user's desktop, System folder, the user's Startup folder, and many others each of which represents a particular folder on the target machine.

  • Registry Editor The Registry Editor enables you to specify Registry keys, subkeys, and values that are added to the Registry on the target machine during the installation process. You can also import Registry files into the Registry Editor.

  • File Types Editor The File Types Editor enables you to associate file extensions and actions with applications. For example, files with an extension (.qry, .txt and so on) and actions (open, print, edit and so on) can be associated with the application. Later the application gets triggered whenever the associated actions are performed on files with the associated extensions.

  • User Interface Editor The User Interface Editor enables you to customize the user interface that is provided to the user during the installation process. The user interface is made up of various dialog boxes that appear during the installation process. The user interface provided to the user is divided into three stages: Start, Progress, and End.

    The User Interface Editor displays the user interface that is applicable during both end user installation and administrative installation. You can customize the user interface for both of these types of installations. The administrative installation occurs when you run the msiexec command-line tool with the /a option.

  • Custom Actions Editor The Custom Actions Editor enables you to run compiled DLLs, EXEs, scripts, or assembly files at the end of an installation. These files can be used to perform custom actions that are vital but were not carried out during the installation. If the custom action fails, the entire installation process is rolled back. For example, you might have to install the database that your application requires during the installation process.

  • Launch Conditions Editor The Launch Conditions Editor enables you to set conditions that are to be evaluated when an installation begins on a target machine. If the conditions are not met, the installation stops. For example, let's say that you want to install a Visual C# .NET application only if the .NET Framework is installed on the target machine. By default, this condition is added by Visual Studio .NET. You might also need to perform other checks, such as whether a particular file exists on the target machine, or verify a particular Registry key value on the target machine.


    Team-Fly    
    Top


    MCAD Developing XML Web Services and Server Components with Visual C#. NET and the. NET Framework Exam Cram 2 (Exam Cram 70-320)
    Managing Globally with Information Technology
    ISBN: 789728974
    EAN: 2147483647
    Year: 2002
    Pages: 179

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net