private static void WriteWxsFile(string sOutputWxs, List <RegistryKey> wixKeys, List <RegistryValue> wixValues) { var wix = new Wix(); var wixFragment = new Fragment(); wix.AddChild(wixFragment); var wixDirectory = new Directory(); wixFragment.AddChild(wixDirectory); wixDirectory.Id = ""; var wixComponent = new Component(); wixDirectory.AddChild(wixComponent); wixComponent.Id = ""; wixComponent.Guid = "*"; foreach (RegistryKey wixKey in wixKeys) { wixComponent.AddChild(wixKey); } foreach (RegistryValue wixValue in wixValues) { wixComponent.AddChild(wixValue); } // Save to the output file using (var xw = new XmlTextWriter(new FileStream(sOutputWxs, FileMode.Create, FileAccess.Write, FileShare.Read), Encoding.UTF8)) { xw.Formatting = Formatting.Indented; wix.OutputXml(xw); } }
public void TestComposite() { var rootComponent = new Component(); var component1 = new Component(); var component2 = new Component(); var leafComponent1 = new LeafComponent(); var leafComponent2 = new LeafComponent(); rootComponent.AddChild(component1); rootComponent.AddChild(component2); component1.AddChild(leafComponent1); component2.AddChild(leafComponent2); rootComponent.Operation(); }
/// <summary> /// Processes the installation files, produces the WiX data. /// </summary> private int ConvertFiles(DirectoryRef wixDirectoryRef, ComponentGroup wixComponentGroup, InstallationDataXml dataxml, IDictionary <string, string> macros) { int nProduced = 0; // Each installation folder derives a component, regardless of whether there are more files in the same folder, or not foreach (FolderXml folderxml in dataxml.Files) { folderxml.AssertValid(); // Create the component with the files var wixComponent = new Component(); wixComponent.Id = string.Format("{0}.{1}", ComponentIdPrefix, folderxml.Id); wixComponent.Guid = folderxml.MsiComponentGuid; wixComponent.DiskId = Bag.Get <int>(AttributeName.DiskId); wixComponent.Location = Component.LocationType.local; ConvertFiles_AddToDirectory(folderxml, wixComponent, wixDirectoryRef); // To the directory structure // Add to the feature var wixComponentRef = new ComponentRef(); wixComponentRef.Id = wixComponent.Id; wixComponentGroup.AddChild(wixComponentRef); // To the feature var diSource = new DirectoryInfo(Path.Combine(LocalInstallDataResolved.ResolveSourceDirRoot(folderxml.SourceRoot, Bag), folderxml.SourceDir)); if (!diSource.Exists) { throw new InvalidOperationException(string.Format("The source folder “{0}” does not exist.", diSource.FullName)); } // Add files foreach (FileXml filexml in folderxml.Files) { filexml.AssertValid(); FileInfo[] files = diSource.GetFiles(filexml.SourceName); if (files.Length == 0) { throw new InvalidOperationException(string.Format("There are no files matching the “{0}” mask in the source folder “{1}”.", filexml.SourceName, diSource.FullName)); } if ((files.Length > 1) && (filexml.TargetName.Length > 0)) { throw new InvalidOperationException(string.Format("There are {2} files matching the “{0}” mask in the source folder “{1}”, in which case it's illegal to specify a target name for the file.", filexml.SourceName, diSource.FullName, files.Length)); } foreach (FileInfo fiSource in files) { nProduced++; var wixFile = new File(); wixComponent.AddChild(wixFile); wixFile.Id = string.Format("{0}.{1}.{2}", FileIdPrefix, folderxml.Id, fiSource.Name).Replace('-', '_').Replace(' ', '_'); // Replace chars that are not allowed in the ID wixFile.Name = filexml.TargetName.Length > 0 ? filexml.TargetName : fiSource.Name; // Explicit target name, if present and if a single file; otherwise, use from source wixFile.Checksum = YesNoType.yes; wixFile.ReadOnly = YesNoType.yes; wixFile.Source = fiSource.FullName; } } } return(nProduced); }
private void LoadGacAssembly(bool isWin64, Artifact artifact, string rootFolderPath, Directory rootDirectory) { // Create a new component for the gac assembly using the gac guid. string guid = artifact.GetMetadata(Constants.Catalogue.Artifact.GacGuid); if (string.IsNullOrEmpty(guid)) { guid = System.Guid.Empty.ToString(); } Component component = CreateComponent(isWin64, artifact.ProjectRelativePath, new System.Guid(guid), Wix.Xml.Id.GacPrefix); // Put the component into a special directory. Directory gacDirectory = GetDirectory(rootDirectory, "Gac"); gacDirectory.AddChild(component); // Create a file, not adding the assembly application property. File file = CreateFile(artifact.ProjectRelativePath, FilePath.GetAbsolutePath(artifact.ProjectRelativePath, rootFolderPath), Wix.Xml.Id.GacPrefix); component.AddChild(file); file.KeyPath = YesNoType.yes; file.Assembly = File.AssemblyType.net; }
private void LoadAssembly(bool isWin64, Artifact artifact, string rootFolderPath, Directory rootDirectory, Component component) { // Create a file. File file = CreateFile(artifact.ProjectRelativePath, FilePath.GetAbsolutePath(artifact.ProjectRelativePath, rootFolderPath)); component.AddChild(file); file.KeyPath = YesNoType.yes; file.Assembly = File.AssemblyType.net; // Set the assembly application which will copy the assembly to the install location, event if it is subsequently installed into the GAC. file.AssemblyApplication = file.Id; // Check whether to register the file. if (artifact.GetBooleanMetadata(Constants.Catalogue.Artifact.Register)) { RegisterAssembly(artifact, rootFolderPath, component); } if (artifact.GetBooleanMetadata(Constants.Catalogue.Artifact.RegisterPackages)) { RegisterPackages(artifact, rootFolderPath, component); } // Check whether the assembly is to be loaded into the gac as well. if (artifact.GetBooleanMetadata(Constants.Catalogue.Artifact.InstallInGac)) { LoadGacAssembly(isWin64, artifact, rootFolderPath, rootDirectory); } }
public static Component AddChild <T>(this Component component, string childName) where T : Component { component.AddChild(childName); T t = component.get_transform().FindChild(childName).AddComponent <T>(); return(component); }
/// <summary> /// Checks whether the DLL defines an Omea plugin, and adds registration for it, if that is the case. /// </summary> private static void RegisterPlugin(AssemblyXml assemblyxml, File wixFileAssembly, Component wixComponentRegistry) { Assembly assembly = Assembly.Load(assemblyxml.Include); foreach (Type type in assembly.GetTypes()) { if (type.ContainsGenericParameters) { continue; // Generics cannot be plugins } if (type.FindInterfaces(delegate(Type m, object filterCriteria) { return((m.Name == "IPlugin") && (m.Assembly.GetName().Name == "OpenAPI")); }, null).Length == 0) { continue; // Not a single plugin in this DLL } // Yes, it's a plugin — produce registration in the Registry var wixRegValue = new RegistryValue(); wixComponentRegistry.AddChild(wixRegValue); wixRegValue.Id = string.Format("{0}.Plugin.{1}", RegistryValueIdPrefix, assemblyxml.Include); wixRegValue.Action = RegistryValue.ActionType.write; wixRegValue.Root = RegistryRootType.HKMU; wixRegValue.Key = PluginsRegistryKey; wixRegValue.Name = Regex.Replace(assemblyxml.Include, "(.+?)(Plugin)?", "$1"); wixRegValue.Type = RegistryValue.TypeType.@string; wixRegValue.Value = string.Format("[#{0}]", wixFileAssembly.Id); } }
/// <summary> /// Create the Registry key for the Plugins section. /// </summary> private static void CreatePluginsRegistryKey(Component wixComponentRegistry) { var wixRegKeyPlugins = new RegistryKey(); wixComponentRegistry.AddChild(wixRegKeyPlugins); wixRegKeyPlugins.Id = string.Format("{0}.PluginsKey", RegistryValueIdPrefix); wixRegKeyPlugins.Action = RegistryKey.ActionType.createAndRemoveOnUninstall; wixRegKeyPlugins.Root = RegistryRootType.HKMU; wixRegKeyPlugins.Key = PluginsRegistryKey; }
/// <summary> /// Processes the files that should be taken from the “References” folder and installed “AS IS”. /// </summary> private int ProcessReferences(Directory wixDirectory, ComponentGroup wixComponentGroup, AllAssembliesXml allassembliesxml, Dictionary <string, string> mapTargetFiles) { int nGeneratedComponents = 0; // Replaces illegal chars with underscores var regexMakeId = new Regex("[^a-zA-Z0-9_.]"); foreach (ItemGroupXml group in allassembliesxml.ItemGroup) { if (group.References == null) { continue; } foreach (ReferenceXml referencexml in group.References) { nGeneratedComponents++; var fiReference = new FileInfo(Path.Combine(Bag.GetString(AttributeName.ProductReferencesDir), referencexml.Include)); if (!fiReference.Exists) { throw new InvalidOperationException(string.Format("The reference file “{0}” could not be found.", fiReference.FullName)); } string sIdSuffix = regexMakeId.Replace(fiReference.Name, "_"); // Create the component for the assembly (one per assembly) var wixComponent = new Component(); wixDirectory.AddChild(wixComponent); wixComponent.Id = string.Format("{0}.{1}", FileComponentIdPrefix, sIdSuffix); wixComponent.Guid = referencexml.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 reference file (and make it the key path) var wixFileReference = new File(); wixComponent.AddChild(wixFileReference); wixFileReference.Id = string.Format("{0}.{1}", FileIdPrefix, sIdSuffix); wixFileReference.Name = fiReference.Name; wixFileReference.KeyPath = YesNoType.yes; wixFileReference.Checksum = YesNoType.yes; wixFileReference.Vital = YesNoType.yes; wixFileReference.ReadOnly = YesNoType.yes; RegisterTargetFile(wixFileReference.Name, string.Format("The “{0}” reference.", referencexml.Include), mapTargetFiles); } } return(nGeneratedComponents); }
public override Component CopyTo(Component newParent, string newId) { var newFolder = new FolderComponent { Id = newId, Name = $"Copy of {Name}" }; newParent.AddChild(newFolder); return(newFolder); }
private void LoadTlb(Artifact artifact, string rootFolderPath, Component component) { // Create a file. File file = CreateFile(artifact.ProjectRelativePath, FilePath.GetAbsolutePath(artifact.ProjectRelativePath, rootFolderPath)); component.AddChild(file); file.KeyPath = YesNoType.yes; // Check for extra registration. if (artifact.GetBooleanMetadata(Constants.Catalogue.Artifact.Register)) { RegisterTypeLib(artifact, rootFolderPath, component); } }
public override Fragment[] Harvest(string categoryName) { var component = new Component { KeyPath = YesNoType.yes, Id = string.IsNullOrEmpty(ComponentId) ? CompilerCore.GetIdentifierFromName(categoryName) : ComponentId.Trim(), Directory = string.IsNullOrEmpty(DirectoryId) ? "TARGETDIR" : DirectoryId.Trim() }; component.AddChild(GetPerformanceCategory(categoryName)); var fragment = new Fragment(); fragment.AddChild(component); return(new [] { fragment }); }
public override void CopyTo(Component newParent) { var newFolder = new FolderComponent { Id = Id, //TODO Name = $"Copy of {Name}" }; newParent.AddChild(newFolder); if (Children != null) { foreach (var child in Children) { child.CopyTo(newFolder); } } }
private void LoadDefault(Artifact artifact, string rootFolderPath, Directory directory, Component component) { // Create a file. File file = CreateFile(artifact.ProjectRelativePath, FilePath.GetAbsolutePath(artifact.ProjectRelativePath, rootFolderPath)); component.AddChild(file); // Check for short cuts. string shortcutName = artifact.GetMetadata(Constants.Catalogue.Artifact.ShortcutName); string shortcutPath = artifact.GetMetadata(Constants.Catalogue.Artifact.ShortcutPath); if (!string.IsNullOrEmpty(shortcutName) || !string.IsNullOrEmpty(shortcutPath)) { CreateShortcut(artifact, directory, shortcutName, shortcutPath, file); } }
private static void InvokeWixRedirector(FileInfo fi, File wixFile, Component wixComponent, Action onInvokeSelfReg) { RegistryValue[] values; using (new WixRegistryHarvester(true)) { onInvokeSelfReg(); values = WixRegistryHarvester.HarvestRegistry(); } // Proper roots, file refs TranslateValues(values, wixFile, fi); // Mount foreach (RegistryValue value in values) { wixComponent.AddChild(value); } }
/// <summary> /// Scrapes a directory subtree. /// </summary> /// <param name="target">Directory currently being scraped.</param> private static void ScrapeDirectory(Directory target) { ArrayList subItems = new ArrayList(); foreach (string directory in IO.Directory.GetDirectories(target.FileSource)) { Directory scrapedDirectory = new Directory(); directoryId++; scrapedDirectory.Id = String.Format(CultureInfo.InvariantCulture, "Dir{0}", directoryId); scrapedDirectory.LongName = IO.Path.GetFileName(directory); scrapedDirectory.Name = scrapedDirectory.Id; scrapedDirectory.FileSource = directory; target.AddChild(scrapedDirectory); ScrapeDirectory(scrapedDirectory); } foreach (string file in IO.Directory.GetFiles(target.FileSource)) { File scrapedFile = new File(); scrapedFile.LongName = IO.Path.GetFileName(file); scrapedFile.Source = file; fileId++; string fileExtension = IO.Path.GetExtension(file); if (fileExtension.Length > 4) { scrapedFile.Id = String.Format(CultureInfo.InvariantCulture, "Fil{0}{1}", fileId, fileExtension.Substring(0, 4)); } else { scrapedFile.Id = String.Format(CultureInfo.InvariantCulture, "Fil{0}{1}", fileId, fileExtension); } scrapedFile.Name = scrapedFile.Id; Component fileComponent = new Component(); fileComponent.Id = String.Format(CultureInfo.InvariantCulture, "Comp{0}", scrapedFile.Name); fileComponent.DiskId = 1; fileComponent.Guid = Guid.NewGuid().ToString(); fileComponent.AddChild(scrapedFile); target.AddChild(fileComponent); } }
protected override void OnStart(TextWriter writer) { // Check if we're in a navbar, and if so, make sure we're in a navbar nav if (GetComponent <Navbar>() != null && GetComponent <NavbarNav>() == null) { GetHelper().NavbarNav().Component.Start(writer); } // Check if we're in a nav if (GetComponent <Nav>(true) != null || GetComponent <NavbarNav>(true) != null) { TagName = "li"; Link link = GetHelper().Link(null).Component; link.AddCss(Css.DropdownToggle); link.MergeAttribute("data-toggle", "dropdown"); _toggle = link; } else { // Create a button and copy over any button classes and text Button button = GetHelper().Button().Component; button.RemoveCss(Css.BtnDefault); button.AddCss(Css.DropdownToggle); button.MergeAttribute("data-toggle", "dropdown"); foreach (string buttonClass in CssClasses.Where(x => x.StartsWith("btn"))) { button.CssClasses.Add(buttonClass); } _toggle = button; } CssClasses.RemoveWhere(x => x.StartsWith("btn")); // Add the text and caret if (TextContent != null) { _toggle.AddChild(GetHelper().Content(TextContent)); _toggle.AddChild(GetHelper().Content(" ")); } else { Element element = GetHelper().Element("span").AddCss(Css.SrOnly).Component; element.AddChild(GetHelper().Content("Toggle Dropdown")); _toggle.AddChild(element); } TextContent = null; if (Caret) { _toggle.AddChild(GetHelper().Caret()); } // Check if we're in a InputGroupButton, then // Check if we're in a button group, and if so change the outer CSS class // Do this after copying over the btn classes so this doesn't get copied if (GetComponent <InputGroupButton>(true) != null) { _inputGroupButton = true; } else if (GetComponent <ButtonGroup>(true) != null) { ToggleCss(Css.BtnGroup, true, Css.Dropdown); } // Create the list _list = GetHelper().List(ListType.Unordered).Component; _list.AddCss(Css.DropdownMenu); _list.MergeAttribute("role", "menu"); if (MenuRight) { _list.AddCss(Css.DropdownMenuRight); } if (MenuLeft) { _list.AddCss(Css.DropdownMenuLeft); } if (Scrollable) { _list.AddCss(Css.PreScrollable); } // Start this component base.OnStart(_inputGroupButton ? new SuppressOutputWriter() : writer); // Output the button _toggle.StartAndFinish(writer); // Output the start of the list _list.Start(writer); }
static public void OverwriteChildByNameAdvisory(this Component item, string name, Operation <GameObject> operation) { item.DestroyChildByNameAdvisory(name); item.AddChild(operation()).IfNotNull(g => g.name = name); }
static public GameObject SpawnChild(this Component item, GameObject prefab) { return(item.AddChild(prefab.SpawnInstance())); }
static public T SpawnChild <T>(this Component item, T prefab) where T : Component { return(item.AddChild(prefab.SpawnInstance())); }
static public GameObject SpawnEmptyChild(this Component item) { return(item.AddChild(new GameObject())); }
static public void AddChildren(this Component item, IEnumerable <GameObject> children) { children.Process(c => item.AddChild(c)); }
static public void AddChildren <T>(this Component item, IEnumerable <T> children) where T : Component { children.Process(c => item.AddChild(c)); }
static public T AddChild <T>(this Component item, T child) where T : Component { item.AddChild(child.IfNotNull(c => c.gameObject)); return(child); }
private void HarvestPublisherPolicyAssemblies(AssemblyXml assemblyxml, Directory directory, ComponentGroup componentgroup, ref int nGeneratedComponents, Dictionary <string, string> mapTargetFiles, GuidCacheXml guidcachexml) { if (!Bag.Get <bool>(AttributeName.IncludePublisherPolicy)) { return; } int nWasGeneratedComponents = nGeneratedComponents; var diFolder = new DirectoryInfo(Bag.GetString(AttributeName.ProductBinariesDir)); string sSatelliteWildcard = string.Format("Policy.*.{0}.{1}", assemblyxml.Include, "dll"); // Even an EXE assembly has a DLL policy file foreach (FileInfo fiPolicyAssembly in diFolder.GetFiles(sSatelliteWildcard)) { // Find the companion policy config file var fiPolicyConfig = new FileInfo(Path.ChangeExtension(fiPolicyAssembly.FullName, ".Config")); if (!fiPolicyConfig.Exists) { throw new InvalidOperationException(string.Format("Could not locate the publisher policy config file for the assembly “{0}”; expected: “{1}”.", fiPolicyAssembly.FullName, fiPolicyConfig.FullName)); } // We have to create a new component for each of the DLLs we'd like to GAC as publisher policy assemblies nGeneratedComponents++; // Create the component for the assembly (one per assembly) var component = new Component(); directory.AddChild(component); component.Id = string.Format("{0}.{1}", FileComponentIdPrefix, fiPolicyAssembly.Name); component.Guid = guidcachexml[assemblyxml.Include + " PublisherPolicy"].ToString("B").ToUpper(); component.DiskId = Bag.Get <int>(AttributeName.DiskId); component.Location = Component.LocationType.local; // Register component in the group var componentref = new ComponentRef(); componentgroup.AddChild(componentref); componentref.Id = component.Id; // Add the assembly file (and make it the key path) var fileAssembly = new File(); component.AddChild(fileAssembly); fileAssembly.Id = string.Format("{0}.{1}", FileIdPrefix, fiPolicyAssembly.Name); fileAssembly.Name = fiPolicyAssembly.Name; fileAssembly.KeyPath = YesNoType.yes; fileAssembly.Checksum = YesNoType.yes; fileAssembly.Vital = YesNoType.no; fileAssembly.Assembly = File.AssemblyType.net; fileAssembly.ReadOnly = YesNoType.yes; RegisterTargetFile(fileAssembly.Name, string.Format("Publisher policy assembly file for the {0} product assembly.", assemblyxml.Include), mapTargetFiles); // Add the policy config file var filePolicy = new File(); component.AddChild(filePolicy); filePolicy.Id = string.Format("{0}.{1}", FileIdPrefix, fiPolicyConfig.Name); filePolicy.Name = fiPolicyConfig.Name; filePolicy.KeyPath = YesNoType.no; filePolicy.Checksum = YesNoType.yes; filePolicy.Vital = YesNoType.no; filePolicy.ReadOnly = YesNoType.yes; RegisterTargetFile(fileAssembly.Name, string.Format("Publisher policy configuration file for the {0} product assembly.", assemblyxml.Include), mapTargetFiles); } if (nWasGeneratedComponents == nGeneratedComponents) // None were actually collected { throw new InvalidOperationException(string.Format("Could not locate the Publisher Policy assemblies for the “{0}” assembly. The expected full path is “{1}\\{2}”.", assemblyxml.Include, diFolder.FullName, sSatelliteWildcard)); } }
protected override void OnStart(TextWriter writer) { // Check if we're in a navbar, and if so, make sure we're in a navbar nav if (GetComponent <INavbar>() != null && GetComponent <INavbarNav>() == null) { new NavbarNav <THelper>(Helper).Start(writer); } // Check if we're in a nav if (GetComponent <INav>(true) != null || GetComponent <INavbarNav>(true) != null) { TagName = "li"; Link <THelper> link = Helper.Link(null); link.AddCss(Css.DropdownToggle); link.AddAttribute("data-toggle", "dropdown"); _toggle = link; } else { // Create a button and copy over any button classes and text Button <THelper> button = Helper.Button(); button.RemoveCss(Css.BtnDefault); button.AddCss(Css.DropdownToggle); button.AddAttribute("data-toggle", "dropdown"); foreach (string buttonClass in CssClasses.Where(x => x.StartsWith("btn"))) { button.CssClasses.Add(buttonClass); } _toggle = button; } CssClasses.RemoveWhere(x => x.StartsWith("btn")); // Add the text and caret if (!string.IsNullOrWhiteSpace(TextContent)) { _toggle.AddChild(new Content <THelper>(Helper, TextContent + " ")); } else { Element <THelper> element = new Element <THelper>(Helper, "span").AddCss(Css.SrOnly); element.AddChild(new Content <THelper>(Helper, "Toggle Dropdown")); _toggle.AddChild(element); } TextContent = null; if (_caret) { _toggle.AddChild(Helper.Caret()); } // Check if we're in a IDropdownButton or IInputGroupButton, then // Check if we're in a button group, and if so change the outer CSS class // Do this after copying over the btn classes so this doesn't get copied if (GetComponent <IDropdownButton>(true) != null || GetComponent <IInputGroupButton>(true) != null) { _dropdownButton = true; } else if (GetComponent <IButtonGroup>(true) != null) { ToggleCss(Css.BtnGroup, true, Css.Dropdown); } // Create the list _list = Helper.List(ListType.Unordered); _list.AddCss(Css.DropdownMenu); _list.MergeAttribute("role", "menu"); if (_menuRight) { _list.AddCss(Css.DropdownMenuRight); } if (_menuLeft) { _list.AddCss(Css.DropdownMenuLeft); } // Start this component base.OnStart(_dropdownButton ? new SuppressOutputWriter() : writer); // Output the button _toggle.StartAndFinish(writer); // Output the start of the list _list.Start(writer); }
public static Component AddChild <T>(this Component component, string childName, ref T instance) where T : Component { component.AddChild(childName); instance = component.transform.FindChild(childName).AddComponent <T>(); return(component); }
/// <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); }