Resources

Various ways to deploy C# applications

Lesson 1 - Planning Deployment

  • Goal = simple + easy installation of app files (+any others required) to client machine
  • Simple apps = copy to destination directory
  • Complex apps = use Windows Installer to configure client machine

XCOPY Deployment

  • Name derived from DOS XCOPY - copy directory (and subdirectories) from source to target
  • Accomplished from command prompt
  • All files required by app must be located within its directory (or below)
  • .NET framework must be installed on client machine
  • App can not require presence of resources (e.g. DB) not known to be already present on client
  • Usually only use for Apps with no externally dependencies and where it is known client will have .NET installed

Creating Setup Project

  • Visual Studio .NET can create Windows Installer projects

  • 2 forms

    • setup - deploying executables
    • merge - deploy controls and components that do not exist as standalone apps. Redistributable package that can be merged into existing setup
  • Create via Setup Project wizard

    • Add setup project to existing solution

    • Choose project type (e.g. setup for windows app, or create merge module)

    • Determine what outputs to include in setup

      • Primary output (.exe or .dlls)
      • Resources
      • Debug symbols
      • Content files
      • Source files
    • Select any additional files to include (browse across hard drive)

Build Properties for Setup

  • Configure output of project via properties window
  • Produces at least one file (with .msi extension) containing all info required to install app
  • Can create additional files to install app on machines without Windows Installer already present

Output File Name

  • Location and name Windows Installer file will reside once built
  • Default => <configuration>\<projectname>.<extension> where
    • <configuration> = subdirectory for selected configuration (e.g. release) in project directory
    • <projectname> = name of project
    • <extension> = .msi for Windows Installer application project or .msm for Windows Installer merge project

Package Files

  • Determines how output files will be packaged

  • Default = package into setup file itself

    • High compression
    • Low level of complexity
  • Place into Cabinet (CAB) files

    • Can determine size of CAB files (useful if size limitation on output, e.g. destination = floppy)
  • Package into loose, uncompressed files in same directory as MSI file

Bootstrapper

  • Determine if bootstrapping app to be generated
  • Bootstrapping app installs Windows Installer 1.5 onto target machine
  • Not required if targeting Windows XP

Compression

  • Unavailable if packaging as loose, uncompressed files
  • Otherwise 3 settings
    • None - fastest to install, but very large image
    • For Speed - fast to install, larger image
    • For Size - slower to install, smaller image

Authenticode Signature

  • Permits signing of project
  • Specify folder containing Certificate File used for signing
  • Specify folder containing Private Key for encrypting signed files
  • Optionally specify URL for timestamp server to use when signing files

Build

  • To Build, select project in solution explorer and choose Build
  • Many distribution options available, including

Distribute

Removable Media

  • Traditional mechanism
  • If setup app bigger than size of chosen medium must package output as appropriately sized CAB files and copy to required number of disks

Network Share

  • Used when destined for group of users on common network
  • Simplest method of distribution
  • Network administrator can set privileges to restrict access to specified groups or individuals

World Wide Web

  • For projects with wide distribution audience
  • Fundamentally same as via network share
  • Copy installation files to virtual Web directory

Deployment

  • If no bootstrapper, double click .MSI file
  • If bootstrapper included double click setup.exe

Lesson 2 - Configuring Setup Project

  • Windows Installer projects highly configurable
    • Target file locations
    • Create file associations
    • Check for pre-existing conditions
    • Execute custom actions

Setup Project Properties

  • Configure via project properties window

  • AddRemoveProgramIcon - icon for Add/Remove programs dialog

  • Author - Programs author

  • Description - Description of app

  • Keywords - Keywords associated with app

  • Localization - Locale for app

  • Manufacturer - Info about apps manufacturer

  • ManufacturerURL - URL for manufacturer

  • ProductName - Name of product

  • Subject - Subject of application

  • SupportPhone - Phone number for support

  • SupportURL - URL for support

  • Title - Title of app

  • DetectNewerInstall - When true looks for more recent version of app on computer and aborts install if one found

  • RemovePreviousVersion - When true looks for earlier versions of app on computer and removes them if found

  • Version - Version of the app

  • vsdrpDoNoRegister - Object requires no registration

  • csdrpCOM - Object registered as COM object

  • vsdrpCOMRelativePath - Object will be registered as isolated COM object

  • vsdrpCOMSelfReg - Object will be self-registered as COM object when installed

  • vsdrpFont - Object will be registered as Font upon installation

  • To register component upon install, select component and ser Register property to true

Installation Editors

  • 6 installation editors provided by IDE

File System Editor

  • Manipulate file system on target machine

  • 2 panes

  • Right = project output files

  • Left = directory structure of target computer

    • Application folder
    • User desktop
    • User program menu
    • Add additional folder by choosing Add Special Folder
  • Install to GAC

  • Assembly must be incorporated in project as loose file

  • Assembly must not be compressed with other project output

  • Sign assembly with strong name

  • Add GAC folder to File System Editor

  • Add assembly to GAC folder

Registry Editor

  • Create new registry entries
  • Write new values to existing entries
  • Left pane = registry structure on target
  • Right pane = registry key values

File Types Editor

  • Create association between file extension and application

  • Right click File Type Editor and choose Add File Type

  • Provide extension(s) separated by ; (do not prefix with .)

  • Default& Open action already present

  • Add additional actions by right clicking and choosing Add Action

  • For each additional action

    • Command = application to launch when action taken
    • Name = text appearing in context menu
    • Verb = verb used to invoke action
    • Arguments = values passed to application
  • When invoked app receives fully qualified file name as argument 1 followed by any additional arguments (as defined by action)

User Interface Editor

  • Alter visual interface user sees during installation

  • Consists of 2 trees

    • Install
    • Administrative Install
  • Trees represent dialog boxes user sees during install

  • Divided into 3 sections

    • Start

      • installer gathers info from user and machine
      • dialog boxes requiring choices placed here
      • at end installer checks for disk space, if not enough deployment aborted
    • Progress

      • Single dialog indicating installation in progress
    • End

      • Present information about installation to user
  • Administrative Install typically has more options in Start phase, e.g. may not have Installation Folder dialog present in User Install

  • Can add customisable dialogues to installation

    • Choose from variety of dialogs accepting input through check boxes, radio buttons or text boxes
    • Customise appearance via properties, e.g. BannerText, BodyText, Button1Label, DefaultValue, etc.

Custom Actions Editor

  • Code to be executed during installation events

    • Install
    • Commit
    • Rollback
    • Uninstall
  • Add custom action(s) under appropriate event

  • Set properties for custom action(s)

    • Arguments - pass args to custom actions represented as .exe
    • Condition - Boolean statement to be evaluated before custom action executed (e.g. evaluate properties chosen in custom dialog boxes)
    • CustomActionData - pass additional required data to custom action
    • EntryPoint - name of method to execute for custom action (if blank same as source event, e.g. Install). Only applicable if custom action implemented as DLL
    • InstallerClass - true if custom action implemented as Installer class
    • SourcePath - path to file implementing custom action

Launch Conditions Editor

  • Specify conditions to be met on target machine before installation executes, e.g. determine version of Windows running
  • Editor divided into 2 parts - search and launch conditions
    • Create search by right clicking Search Target Machine and choose from

      • File - find specific file (including version, size and date)
      • Registry - find specific key
      • Windows Installer - find specified Windows Installer component
      • Specify property name for search - used by launch conditions to determine status of search
    • Create launch condition by clicking Launch Conditions

      • Specify name
      • Condition is string containing Boolean expression which if True permits installation to proceed. Can contain more than one expression joined by AND, OR, etc.
      • Message to display if condition fails

Installing Native Assembly

  • Apps generally deployed as MSIL
  • Where performance is critical may want to deploy as native code
  • Use ngen.exe to create native image for application

Verify Installed Assembly Security Policies

  • User PermView.exe to view permissions app requests
  • By default displays assembly level permissions
  • Use /DECL flag to examine all declared permissions (including those at class and method level)

Downloads