creating installations for microsoft.net framework - wise -

Upload: parthasarathi

Post on 30-May-2018

221 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/14/2019 Creating Installations for Microsoft.net Framework - Wise -

    1/12

    Creating Installations forMicrosofts .NET Frameworkusing Wise for Windows Installer

    Abstract

    This paper provides an overview of creatingan installation for an application created for Microsofts

    .NET Framework. By following the process, a software

    developer can install private and shared .NET assemblies

    using a Windows Installer (.MSI) package.

  • 8/14/2019 Creating Installations for Microsoft.net Framework - Wise -

    2/12

    Creating Installations for .NET - 2 - Copyright 2001, 2002 by Wise Solutions, Inc.

    The .NET Framework makes it much easier to deploy certain types ofapplications, while others become more complicated and increase thereliance upon Microsofts Windows Installer service. As Microsoftexplains:

    The .NET Framework simplifies deployment by making zero-impactinstall and XCOPY deployment of applications feasible. Because allrequests are resolved first to the private application directory, simplycopying an application's directory files to disk is all that is needed torun the application. No registration is required.

    This scenario is particularly compelling for Web applications, WebServices, and self-contained desktop applications. However, thereare scenarios where XCOPY is not sufficient as a distributionmechanism. An example is when the application has little privatecode and relies on the availability of shared assemblies, or when theapplication is not locally installed (but rather downloaded ondemand). For these cases, the .NET Framework provides extensivecode download services and integration with the Windows Installer.The code download support provided by the .NET Framework offersseveral advantages over current platforms, including incrementaldownload, code access security (no more Authenticode dialogs), andapplication isolation (code downloaded on behalf of one applicationdoesn't affect other applications). The Windows Installer is anotherpowerful deployment mechanism available to .NET applications. Allof the features of Windows Installer, including publishing,advertisement, and application repair will be available to .NETapplications in Windows Installer 2.0

    Excerpt from Microsoft .NET Framework FAQ, July 2001

    Installation Options for Simple Applications

    For a .NET application that only uses managed code and privateassemblies, the installation process can be as simple as copying files tothe destination PC. Even in this case, however, developers typicallyneed to create an installation that provides a user-friendly interface to theend user, pre-installs the required runtime, and has a compressed,single-file installation that can be easily deployed.

    Installation Options for Complex Applications

    For .NET applications that use shared assemblies or have a mix ofmanaged and unmanaged code, the Windows Installer service should beused to install the application. The Windows Installer service manages allinstalled components on a system and can even fix components if theybecome corrupted.

    Wise for Windows Installer makes this installation technology accessibleto developers by providing a visual, step-by-step approach to creatinginstallations for .NET applications. This white paper describes the

    Introduction

  • 8/14/2019 Creating Installations for Microsoft.net Framework - Wise -

    3/12

    Creating Installations for .NET - 3 - Copyright 2001, 2002 by Wise Solutions, Inc.

    process of creating a .NET installation, as well as discussing how Wisefor Windows Installer simplifies this process.

    Before you begin to create an installation for your .NET application,identify the following information about your application:

    1. Gather all of your assemblies, Win32 and .NET, and their associatedmanifests into a common location.

    2. Determine where the assemblies are to be installed (see the sectiontitled Best Practices for more information).

    3. Generate PrivateKeyTokens for the assemblies and digitally sign allthe assemblies if they are to be installed to the Global AssemblyCache.

    Preparing Wise for Windows Installer

    Wise for Windows Installer 4.0 includes the necessary features forcreating installations for .NET. To take advantage of these features, youneed to have the Windows Installer 2.0 runtime and the CommonLanguage Runtime installed on your system. You must install the .NETFramework installation to obtain the Common Language Runtime. TheWindows Installer runtime is automatically installed along with allversions of Wise for Windows Installer, and the .NET Framework isoptionally installed with Wise for Windows Installer 4.01 or later.

    If you have the .NET Framework installed, you are ready to work on your.NET installation. Either create a new installation or open an existinginstallation that you wish to convert to .NET. Go to the Product Details

    page in Installation Expert and change the Application Type drop-downlist to ".NET Application." Now .NET features are enabled in the currentinstallation. A standard Win32 installation does not have assemblies, amixed installation has both Win32 and .NET components, and a .NETinstallation has only .NET components.

    You can customize how Wise for Windows Installer handles theassemblies added to your installation by changing the settings on the.NET Assemblies tab of the Preferences dialog.

    Getting Started

  • 8/14/2019 Creating Installations for Microsoft.net Framework - Wise -

    4/12

    Creating Installations for .NET - 4 - Copyright 2001, 2002 by Wise Solutions, Inc.

    The Default Application Type field specifies the installation type of allfuture installations you create, but does not change the currentinstallation. The Rescan COM interop registry keys on compilecheckbox determines how Wise handles the scanning of COM interopregistry entries.

    In addition, you can set Wise up to automatically add any dependencyassemblies. When Scan Dependencies is set to Always scandependencies, Wise scans the assembly manifest for any dependenciesand automatically adds those assemblies to the installation, along withthe required assembly entries in the Windows Installer tables. For fullcontrol, this can be turned off and you can be prompted to scan fordependencies or you can add all files manually. This enables you, as theinstallation package author, to have a full range of control throughout thecreation of the installation.

    Once you have customized .NET preferences, each future project youcreate with Wise for Windows Installer inherits the settings from these

    global options. Now you are ready to start adding components to yourinstallation.

  • 8/14/2019 Creating Installations for Microsoft.net Framework - Wise -

    5/12

    Creating Installations for .NET - 5 - Copyright 2001, 2002 by Wise Solutions, Inc.

    You should add the Common Language Runtime redistributable runtimeto your installation to ensure that all the necessary runtimes are pre-installed on the destination PC. To add the Common Language Runtime,go to the Releases page of Installation Expert, double-click the releaseyou are currently working with, and in Release Details, choose to pre-install the .NET common language runtime from the Pre-install Optionsdrop-down list.

    It is generally a good idea to include any runtimes that are required bythe application you're installing. This prevents runtime errors for endusers and can significantly decrease help desk calls. The .NETFramework runtime includes BOTH the Common Language Runtime andthe Windows Installer 2.0 runtimes. Therefore, when including the .NETFramework runtime the Windows Installer runtime does not need to beincluded.

    Common Language

    Runtime

  • 8/14/2019 Creating Installations for Microsoft.net Framework - Wise -

    6/12

    Creating Installations for .NET - 6 - Copyright 2001, 2002 by Wise Solutions, Inc.

    Within the Wise for Windows Installer 4.0 Professional Edition, you canuse WebDeploy to deploy applications over the Web. WebDeploycontains a feature to optionally download the Windows Installer and.NET runtimes if the user requires them. This can significantly reducedownload times and reduces the number of concurrent connections onyour http or ftp servers.

  • 8/14/2019 Creating Installations for Microsoft.net Framework - Wise -

    7/12

    Creating Installations for .NET - 7 - Copyright 2001, 2002 by Wise Solutions, Inc.

    Navigate to the Files page in Installation Expert. From here, you candrag and drop your assemblies into the appropriate directory. As you addassemblies, Wise automatically adds the appropriate table entries toinstall and register your assemblies in their destination location.

    Global Assembly Cache, WinSxS, Private Assemblies

    For those assemblies that should be installed into the Global AssemblyCache, select the files and drag and drop them into the Global AssemblyCache folder.

    Note: To install .NET Assemblies into the Global Assembly Cache, theymust be Strongly Named. You can find out more on this topic in the .NETFramework SDK.

    To install your Win32 assemblies into the WinSxS (side-by-side) folder,simply navigate to the WinSxS folder under the Windows folder in thelower left, then add your assembly files. Wise automatically designatesthe .MANIFEST file as the file in your component that contains themanifest.

    To install your assemblies to a private location, you can add them as youwould add any other file to your installation directory.

    To customize any of these automated entries, double-click the assemblyfile youd like to edit and the File Details dialog appears.

    Adding Files

  • 8/14/2019 Creating Installations for Microsoft.net Framework - Wise -

    8/12

    Creating Installations for .NET - 8 - Copyright 2001, 2002 by Wise Solutions, Inc.

    In the File Details dialog, there is an option to register each assembly for

    reference within Visual Studio .NET. When marked, this option creates aregistry entry for this assembly. Then, the next time Visual Studio.NET isopened, the assembly is available for any future projects via the Project> References menu item.

    Note: You cannot drag and drop files directly from the Global AssemblyCache (C:\WINNT\Assembly folder) on your development machine.

    In addition, any of these entries can be edited from the Table editor.Wise gives full access to all tables via the Tables tab of Setup Editor toensure that you have full control throughout the installation authoringprocess. (See the section titled Behind the Scenes... for specificexamples of how to edit these entries.)

    When you are using Wise for Windows Installer to automate the tableentries for your .NET application, there is a lot going on behind thescenes. A Windows Installer package includes a number of databasetables that describe the application to Microsofts Windows Installerservice. The tables involved in installing an assembly are MsiAssemblyand MsiAssemblyName. These tables are automatically filled in whenyou set the installation to be a .NET Application on the Product Detailspage. The tables that are described below store the necessary data thatWindows Installer needs to install and/or register your assembly in thedestination location.

    Behind the Scenes...

  • 8/14/2019 Creating Installations for Microsoft.net Framework - Wise -

    9/12

    Creating Installations for .NET - 9 - Copyright 2001, 2002 by Wise Solutions, Inc.

    MsiAssembly Table

    The MsiAssembly table contains one record for each assembly to beinstalled. There are five fields in the MsiAssembly table. The exampleMsiAssembly table shown below is referenced in examples later in thissection.

    Component_. This is the foreign key to the Component record thatcontains the assembly. If your assembly is comprised of multiple files,they should be authored into the same component.

    Feature_. This field specifies the feature in the installation with which theassembly is associated.

    File_Manifest. This field is a foreign key to the File table for the file thatcontains the manifest for the assembly. If the assembly is comprised ofmany files, this entry will be the file in the assembly that contains theassembly manifest information. A Portable Executable is a self-contained.NET assembly. It contains the compiled assembly in addition to theassembly manifest and Strong Name information. When working withPortable Executables (PE), the File_Manifest field contains the PortableExecutable file name. This is because the manifest is self-containedwithin the PE .dll or .exe.

    File_Application. This field should be blank if the assembly is to beinstalled into the Global Assembly Cache on the destination PC. Forprivate assemblies, the File_Application field contains a foreign key to

    the File table for the main application file. Windows Installer installs theassembly into the directory where the component is installed, asdetermined in the Component tables Directory field. If the component isinstalled into the INSTALLDIR directory, the assembly is then installed inthat directory, along with the application files. The directory assigned tothis component is resolved in the Directory table and can be set atruntime by the user on the Single Feature Destination dialog.

    Private Assembly (NOT available with Windows 95, 98, or NT)In the example MsiAssembly table shown above, Component2 willbe installed into the application directory. This means it is a privateassembly and only available for the application that's being installed.Component1 is a shared assembly and will be installed and

    registered into the Global Assembly Cache on the destination PC.

    WinSxS Assembly (only available with Windows XP)When Win32 assemblies are installed into the WinSxS directory,they are not registered globally on the system, as they are wheninstalled into the Global Assembly Cache. However, they areavailable to any application that references them. To enable side-by-side sharing, your component must be installed into the WinSxSfolder. During installation of the application, Windows Installer

  • 8/14/2019 Creating Installations for Microsoft.net Framework - Wise -

    10/12

    Creating Installations for .NET - 10 - Copyright 2001, 2002 by Wise Solutions, Inc.

    resolves the Directory table to obtain the path to the WinSxS folder ifthe File_Application field is not null. For assemblies to be installedinto the WinSxS directory, a .LOCAL file is not needed, because itnot utilized in this scenario.

    Shared Assembly (Global Assembly Cache or GAC)When the File_Application table is set to a null value, WindowsInstaller ignores the components destination directory and installsthe entire component into the Global Assembly Cache. Theassembly is then available to all other applications that use thisassembly version. In the example above, Component2 will beinstalled into the Global Assembly Cache, based on the null value inthe File_Application field.

    Attributes. This field is used to determine if the assembly is a Win32 ora .NET Application. For .NET assemblies, the value authored into thisfield would be 0 (zero), and if the assembly is a Win32 application, thevalue would be 1.

    MsiAssemblyName Table

    For each assembly attribute (as authored in the manifest), a recordinitializing the attribute and its data value must be entered into theMsiAssemblyName table. Wise for Windows Installer has added theability to scan the assembly manifest to automate this process.Windows Installer needs these attributes to appropriately register theassembly when it is installed. When you add an assembly, this table isautomatically propagated with the necessary data. You can modify theentries that Wise creates in this table by going to the Tables tab of SetupEditor and scrolling to the MsiAssemblyName table.

    Examples of possible entries are as follows:

    Component. This field contains one of the Component_ values authoredinto the MsiAssembly table that represents an assembly.

    Name. This field contains one of the assembly attributes (as defined inthe manifest).

    Value. This field contains the string value of that attribute.

    The entries are variable, and this example shows only a few possibleentries. For all possible attributes, see the .NET Framework SDK. In the

  • 8/14/2019 Creating Installations for Microsoft.net Framework - Wise -

    11/12

    Creating Installations for .NET - 11 - Copyright 2001, 2002 by Wise Solutions, Inc.

    example above, Name, Version and Culture are pulled directly from thestring that is entered into the manifest.

    At this point, you have enough information to distribute .NET and Win32assemblies. After you add all of the assemblies needed for yourapplication, the installation package is ready to be compiled anddistributed. Compilation of your Wise project produces an .MSI or .EXE,depending on the settings you have set on the Releases Page ofInstallation Expert. After you create the .MSI or .EXE, your project can bedistributed.

    Managed Assemblies that are shared with many other applicationsauthored by different vendors should be installed into the GlobalAssembly Cache. This is a central repository of all shared assemblies.The installation of assemblies into the Global Assembly Cache should bewell planned. Assemblies should not arbitrarily placed in the GlobalAssembly Cache without justification.

    The WinSxS folder is a subdirectory located off the Windows directory onWindows XP. Both managed and unmanaged assemblies can be

    installed into the WinSxS directory. It is good common practice to installassemblies that are shared with applications created by the same vendorinto the WinSxS directory.

    In addition, assemblies can be stored in the application directory if theyare to be private, or if they are only used by the application beinginstalled. In this case, it makes most sense not to share them, since noother application will be calling them.

    Wise Solutions, Inc. is committed to providing the most current andthorough support for Microsofts .NET Framework. This is exemplified bythe timely .NET updates to our Wise for Windows Installer product line,the frequent updates to white papers and resource materials, as well as

    our close relationship with several key Microsoft teams.

    Please keep checking our Web site for product updates and supportdocumentation to aid you in your transition to the .NET Framework.

    Conclusion

    Compilation and

    Distribution

    Best Practices

  • 8/14/2019 Creating Installations for Microsoft.net Framework - Wise -

    12/12