// Method public AssemblyName GetAssemblyName(string assemblyFile) { return(AssemblyName.GetAssemblyName(assemblyFile)); }
/// <summary> /// Processes those AllAssemblies.Xml entries that are our own product assemblies. /// </summary> private int ProcessAssemblies(Directory wixDirectory, ComponentGroup wixComponentGroup, Component wixComponentRegistry, AllAssembliesXml allassembliesxml, Dictionary <string, string> mapTargetFiles, GuidCacheXml guidcachexml) { // Collect the assemblies int nGeneratedComponents = 0; foreach (ItemGroupXml group in allassembliesxml.ItemGroup) { if (group.AllAssemblies == null) { continue; } foreach (AssemblyXml assemblyxml in group.AllAssemblies) { nGeneratedComponents++; FileInfo fiAssembly = FindAssemblyFile(assemblyxml); string sExtension = fiAssembly.Extension.TrimStart('.'); // The extension without a dot // Create the component for the assembly (one per assembly) var wixComponent = new Component(); wixDirectory.AddChild(wixComponent); wixComponent.Id = string.Format("{0}.{1}.{2}", FileComponentIdPrefix, assemblyxml.Include, sExtension); wixComponent.Guid = assemblyxml.MsiGuid; wixComponent.DiskId = Bag.Get <int>(AttributeName.DiskId); wixComponent.Location = Component.LocationType.local; // Register component in the group var componentref = new ComponentRef(); wixComponentGroup.AddChild(componentref); componentref.Id = wixComponent.Id; // Add the assembly file (and make it the key path) var wixFileAssembly = new File(); wixComponent.AddChild(wixFileAssembly); wixFileAssembly.Id = string.Format("{0}.{1}.{2}", FileIdPrefix, assemblyxml.Include, sExtension); wixFileAssembly.Name = string.Format("{0}.{1}", assemblyxml.Include, sExtension); wixFileAssembly.KeyPath = YesNoType.yes; wixFileAssembly.Checksum = YesNoType.yes; wixFileAssembly.Vital = YesNoType.yes; wixFileAssembly.ReadOnly = YesNoType.yes; RegisterTargetFile(wixFileAssembly.Name, string.Format("The {0} product assembly.", assemblyxml.Include), mapTargetFiles); // Check whether it's a managed or native assembly AssemblyName assemblyname = null; try { assemblyname = AssemblyName.GetAssemblyName(fiAssembly.FullName); } catch (BadImageFormatException) { } // Add COM Self-Registration data if (assemblyxml.ComRegister) { /* * foreach(ISchemaElement harvested in HarvestComSelfRegistration(wixFileAssembly, fiAssembly)) * wixComponent.AddChild(harvested); */ SelfRegHarvester.Harvest(fiAssembly, assemblyname != null, wixComponent, wixFileAssembly); } // Ensure the managed DLL has a strong name if ((assemblyname != null) && (Bag.Get <bool>(AttributeName.RequireStrongName))) { byte[] token = assemblyname.GetPublicKeyToken(); if ((token == null) || (token.Length == 0)) { throw new InvalidOperationException(string.Format("The assembly “{0}” does not have a strong name.", assemblyxml.Include)); } } // Add PDBs if (Bag.Get <bool>(AttributeName.IncludePdb)) { HarvestSatellite(assemblyxml, assemblyxml.Include + ".pdb", wixComponent, MissingSatelliteErrorLevel.Error, "PDB file", mapTargetFiles); } // Add XmlDocs if ((assemblyname != null) && (Bag.Get <bool>(AttributeName.IncludeXmlDoc))) { HarvestSatellite(assemblyxml, assemblyxml.Include + ".xml", wixComponent, MissingSatelliteErrorLevel.Error, "XmlDoc file", mapTargetFiles); } // Add configs HarvestSatellite(assemblyxml, assemblyxml.Include + "." + sExtension + ".config", wixComponent, (assemblyxml.HasAppConfig ? MissingSatelliteErrorLevel.Error : MissingSatelliteErrorLevel.None), "application configuration file", mapTargetFiles); HarvestSatellite(assemblyxml, assemblyxml.Include + "." + sExtension + ".manifest", wixComponent, (assemblyxml.HasMainfest ? MissingSatelliteErrorLevel.Error : MissingSatelliteErrorLevel.None), "assembly manifest file", mapTargetFiles); HarvestSatellite(assemblyxml, assemblyxml.Include + ".XmlSerializers." + sExtension, wixComponent, (assemblyxml.HasXmlSerializers ? MissingSatelliteErrorLevel.Error : MissingSatelliteErrorLevel.None), "serialization assembly", mapTargetFiles); // Add publisher policy assemblies if (assemblyname != null) { HarvestPublisherPolicyAssemblies(assemblyxml, wixDirectory, wixComponentGroup, ref nGeneratedComponents, mapTargetFiles, guidcachexml); } // Register as an OmeaPlugin if (assemblyname != null) { RegisterPlugin(assemblyxml, wixFileAssembly, wixComponentRegistry); } } } return(nGeneratedComponents); }