320 likes | 483 Vues
Deployment. Your Salvation from DLL Hell. Objectives. Overview Assemblies „XCopy“ Deployment Configuration Administration. Contents. Section 1: Looking Back Section 2: Basic Deployment Section 3: Advanced Tasks Section 4: Putting it all together Summary. Section 1: Looking Back.
E N D
Deployment Your Salvation from DLL Hell
Objectives • Overview • Assemblies • „XCopy“ Deployment • Configuration • Administration
Contents • Section 1: Looking Back • Section 2: Basic Deployment • Section 3: Advanced Tasks • Section 4: Putting it all together • Summary
Section 1: Looking Back • DLL Hell • Version Conflicts • Installation Directories • Uninstall
Section 2: Basic Deployment • Assemblies • "Xcopy" Deployment • Packaging • Configuration • Locating Assemblies
Assemblies 1/3 • Assemblies are the building blocks of an application • ‘Logical DLLs’ • Self-describing via Metadata • Versioning • Security • Private Assemblies • Shared Assemblies • More detailed Information: see Module “Assembly”
Assemblies 2/3 • Private Assemblies • Only visible for the application • Stored in application folder or subdirectory • Isolated from changes to the system • No naming requirements (except uniqueness to application) Application App.exe Assembly1.dll Assembly2.dll
Assemblies 3/3 • Shared Assemblies • Stored in the Global Assembly Cache (GAC) • Strong Names required • Versioning • Signing • Install with • Installer for deployment tasks • Gacutil.exe for development Gacutil –i mydll.dll • Admin rights required
“XCopy” Deployment • Just copy assemblies to application path • Local or network path allowed • .NET Runtime required on executing machine • Uninstall means just deleting assemblies
Avoiding DLL Hell • No registration of components • No copying to %windir%\System32 needed • Side-By-Side Versioning for shared components • No risk of overwriting components
Packaging • Packaging a .NET Application • Configuration Files • Locating Assemblies
Packaging The Application • Packaging a .NET Application • …as .MSI or .MSM files for Windows Installer • …as .CAB files for ‘traditional’ installation • Only one assembly per CAB file • Same name as file in assembly that contains manifest Example: MyDll.DLL MyDll.CAB • …as .CAB files for download with IE >= 5.5 • Specify location to search for referenced assembliesin configuration file
Configuration Files 1/4 • <application>.cfg • Used for application-specific configuration • Must be in same location as application’s main .EXE • Admin.cfg • Global for each computer • Overrides any other configuration file • Resides in %windir% (I.e. C:\WINNT ) • XML-Files • Human readable and editable
Configuration Files 2/4 • Specify behavior of Common Language Runtime: • AppDomain • Tells runtime where to look for assemblies app.cfg RootDir Subdir1 Assembly1 Subdir2
Configuration Files 3/4 • BindingMode • Normal: Use version policy (major.minor / QFE) • Safe: Bind to exact version • BindingRedir • Tells runtime to use specific version • CodeBaseHint • Explicitly causes runtime to look for assemblies in specified location
Configuration Files 4/4 • Application.cfg sample:<?xml version ="1.0"?> <Configuration> <AppDomain PrivatePath="bin;mycode" ShadowCopy="True"/> <BindingMode> <AppBindingMode Mode="normal"/> </BindingMode> <BindingPolicy> <BindingRedir Name="MyCode.dll" Originator="3e59bf1a5ed0ec84" Version="*" VersionNew="3.3.3.3" UseLatestBuildRevision="no"/> </BindingPolicy> <Assemblies> <CodeBaseHint Name="MyCode.dll" Originator="3e59bf1a5ed0ec84" Version="3.3.3.3" CodeBase="http://codebasehint/Mydll.dll"/> </Assemblies> </Configuration>
Locating Assemblies • Searching for • Files with extensions .mcl, .dll, .exe • Shared Assemblies • Steps • Apply <Application>.cfg policy • Search in • Application directory • Subdirectories specified inPrivatePath • Subdirectory named like assembly • Global Assembly Cache • Apply admin.cfg policy
Section 3: Advanced Tasks • Installation Components • COM Components • Serviced Components • ASP.NET • Using Installation Services • Maintenance • Administration
Installation Components 1/2 • Installation Components • Created in InstallerClass of your application • Install associated Resources: • MessageQueues • EventLog • PerformanceCounter • Services
Installation Components 2/2 • Installation Components • Save state in text files • Transactional Installation • Commit, if succeeded • Rollback, if at least one failed • Support for uninstall • Not transactional
CLR COM .NET CCW App Assembly COM Components • Components that will be called via COM must be registered • Using RegAsm /tlb[:filename] • Assembly must be in path of calling application • Runtime creates a COM Callable Wrapper (CCW) • Reference counted like COM Object • Transparent to assembly • Handles marshalling
Serviced Components • Typically hosted in COM+ • Derived from ServicedComponent • Dynamic Registration • Xcopy to destination path • Registers automatically on first use • Manual Registration using RegSvcs.exe • “.NET Services Installation Tool” • Loads and registers an assembly • Generates, registers and installs the type library into an existing COM+ application • Compulsory for unmanaged clients
ASP.NET Deployment • Deploy by simply ‘xcopy’ to server • WebPages • WebServices • Compiled Components • Configuration (Meta)Data • Advantages: • No registration needed • No local server access needed • No web server restarts needed
Using Installation Services • Windows Installer 1.5+ supports assemblies • Use assemblies as components • All Windows Installer Features available: • Local & Remote installation • Resiliency (Recover from broken installations) • Installation-On-Demand • Maintenance Installation • Supported by • SMS • IntelliMirror
Maintenance • Installing new version of private assembly • Replace original file • Developer is responsible for function • Installing QuickFix of assembly • Install in GAC • Applications automatically use QuickFix version • Except version policy denies this • Install new version of shared assembly • Install in GAC • Depending on version policy (app.cfg or admin.cfg) application uses new or previous version
Administration 1/2 • Deleting Shared Assemblies • Use Gacutil.exe • Gacutil -u myDll,Ver=1.1.0.0,Loc=en,PK=874e… • Use Windows Explorer Shell Extension • Right Click in Global Assembly Cache • Admin rights required
Administration 2/2 • Clearing Download Cache • Cleared automatically based on LRU Policy • No manual action necessary • Moving Applications • Just move complete local file structure • Managing Applications After Deployment • Use DynamicProperties • Change properties via XML files • No need to recompile • Changes will be applied after next start
Section 4: Putting it all together • Demo • Creating a simple Application Package • Creating a complex SetupProject
Summary • .NET simplifies Deployment • Local • Remote • Web based • .NET avoids DLL Hell • No more need for third party Installers? • There’s enough left to be done…