Upload
suzan-york
View
236
Download
0
Embed Size (px)
DESCRIPTION
Introduction to Application Deployment Common Concepts Simple Applications Componentized Applications Configuration and Distribution
Citation preview
Module 4: Deployment and Versioning
Overview
Introduction to Application Deployment Application Deployment Scenarios Related Topics and Tools
Introduction to Application Deployment
Common Concepts Simple Applications Componentized Applications Configuration and Distribution
Common Concepts
Classes and Types Used in .NET Framework Applications Are: Organized in a hierarchy of namespaces
Stored in PE files, such as DLLs and EXEs
Fully described by metadata
Assemblies: Are made up of one or more PE files
Contain a manifest that identifies the assembly and its files
Specify exported and imported classes and types
Are units of deployment, reuse, and versioning
Simple Applications
Require .NET Runtime Be Installed on Local Computer Can Be Run Directly from a File Server or Copied
Locally Make No Registry Entries Cannot Break Another Application
Eliminate DLL Hell
Can Be Uninstalled by Deleting Locally Copied File(s)
Componentized Applications
Assemblies Private to an Application Same as a simple application
Assemblies Private to Related Applications Deployed into a common subdirectory
Assemblies Shared with Other Unrelated Applications Require a strong name and version information
Deployed into the global assembly cache
Configuration and Distribution
Configuration Maintained in plain-text files
Deployment Common distribution formats,
such as a .CAB file or a .MSI file
Common distribution mechanisms, such as Windows 2000 IntelliMirror or Microsoft Systems Management Server
Application Deployment Scenarios
A Simple Application A Componentized Application Specifying a Path for Private Assemblies A Strong-Named Assembly Deploying Shared Components A Versioned Assembly Creating Multiple Versions of a Strong-Named Assembly Binding Policy Deploying Multiple Versions of a Strong-Named Assembly
A Simple Application
Use the Microsoft Intermediate Language Disassembler (Ildasm.exe) to Examine the Assembly Manifest Version information
Imported types
Exported types
Deploy the Application by: Running the executable file directly from a file server, or
Installing it locally by copying the file
Uninstall the application by deleting the file
A Componentized Application
Assembly Component to Be Used by Application Assembly Stringer.dll is built from Stringer.cs as follows:
Client Needs to Reference Assembly
Deployment by File Server or Local Copy
csc /target:library Stringer.cs
csc /reference:Stringer.dll Client.cs
Specifying a Path for Private Assemblies
Specifying a Directory From Which to Load Private Assemblies. Client.exe.config file specifies a privatePath tag
Configuration File’s XML Tags Are Case-Sensitive
<configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <probing privatePath=“MyStringer"/> </assemblyBinding> </runtime></configuration>
Global Assembly Cache Contains assemblies shared by unrelated applications
Strong Names Are Required for Assemblies in the Cache Generate a private key:
Add code to source file to specify version and key information:
Compile:
#if STRONG[assembly: System.Reflection.AssemblyVersion("1.0.0.0")][assembly: System.Reflection.AssemblyKeyFile("orgKey.snk")]#endif
csc /define:STRONG /target:library /out:AReverser.dll AReverser.cs
sn –k orgKey.snk
A Strong-Named Assembly
Deploying Shared Components
Installing the Strong-Named Component in the Global Assembly Cache
Examining the Global Assembly Cache
Removing a Shared Component File
gacutil /i AReverser.dll
gacutil /l
gacutil /u AReverser
A Versioned Assembly
Applications Need to Bind to a Suitable Version of a Shared Assembly
The Version Number Is Represented by a 4-Part Number
Applications Get the Versions of Assemblies with Which They Were Built and Tested Unless overridden by explicit policy rules
<major version>.<minor version>.<revision>.<build number>
Creating Multiple Versions of a Strong-Named Assembly
Building Two New Versions of AReverser with a New Key Pair Specify version 2.0.0.0 for one and 2.0.1.0 for the other
For AReverser_v2.0.0.0\AReverser.cs:
Build
Use Ildasm.exe to Examine Different Versions Note the publickey and version numbers
Use Ildasm.exe to Verify Strong Names for Both Assemblies Different .originator property Updated version, 2.0.0.0 or 2.0.1.0
#if STRONG [assembly: System.Reflection.AssemblyVersion("2.0.0.0")][assembly: System.Reflection.AssemblyKeyFile("orgVerKey.snk")]#endif
csc /define:STRONG /target:library /out:AReverser_v2.0.0.0\AReverser.dll AReverser_v2.0.0.0\AReverser.cs
.assembly AReverser{ ... .publickey = (00 24 ... 82 B1 F2 A0 ) .hash algorithm 0x00008004 .ver 2:0:1:0
Binding Policy Policy Resolution
Allows an assembly reference, specified at compile time, to be modified after the application has been deployed without recompiling
Happens in the Following Stages:
1. Application-policy resolution
2. Publisher-policy resolution
3. Administrator-policy resolution In Each Stage, an XML Configuration File Is Read
Note: XML is case-sensitive Version Numbers of Assemblies That Are Not Strong-Named Are Not
Checked Configuration File Tag Examples
privatePath bindingRedirect
Deploying Multiple Versions of a Strong-Named Assembly
Install Both Versions of AReverser.dll into the Global Assembly Cache
Compile the VerClient Executable and Specify Version 2.0.0.0 of the AReverser Component
Use Version Policies to Control Assembly Binding at Run Time
gacutil /i AReverser_v2.0.0.0\AReverser.dllgacutil /i AReverser_v2.0.1.0\AReverser.dll
csc /reference:MyStringer\Stringer.dll /reference:AReverser_v2.0.0.0\AReverser.dll VerClient.cs
Related Topics and Tools
Related Topics Packaging and Deployment Tools
Related Topics
ASP.NET Assemblies Security Localization
Packaging and Deployment Tools
Assembly Linker (Al.exe) Global Assembly Cache tool (Gacutil.exe) MSIL Disassembler (Ildasm.exe) Strong Name (Sn.exe) Native Image Generator (Ngen.exe) Assembly Binding Log Viewer (Fuslogvw.exe) .NET Framework Configuration Tool (Mscorcfg.msc) Code Access Security Policy Tool (Caspol.exe)
Lab 4: Packaging and Deployment
Review
Introduction to Application Deployment Application Deployment Scenarios Related Topics and Tools