protected override string CalculateMsiId() { InprocServer inprocServer = this.Item as InprocServer; OutprocServer outprocServer = this.Item as OutprocServer; Class firstClass = this.inproc ? inprocServer.Classes[0] : outprocServer.Classes[0]; string key = this.GetKey(firstClass.Id); string id = WixBackendCompilerServices.GenerateIdForRegKey(this.Backend, this.Item, 0, key, null); return(id); }
protected override string CalculateComponentMsiId() { InprocServer inprocServer = this.Item as InprocServer; OutprocServer outprocServer = this.Item as OutprocServer; File file = this.inproc ? inprocServer.File : outprocServer.File; if (file == this.Item.Parent) { return(String.Empty); } return(base.CalculateComponentMsiId()); }
public override WixSection GenerateSection() { if (this.System) { return(null); } InprocServer inprocServer = this.Item as InprocServer; OutprocServer outprocServer = this.Item as OutprocServer; File file = this.inproc ? inprocServer.File : outprocServer.File; if (file == this.Item.Parent) { return(null); } WixItem folderMsiItem = WixBackendCompilerServices.ResolveParentFolderMsiItem(file.ParentFolder, this.Backend.WixItems); if (folderMsiItem == null) { return(null); } string componentId = this.ComponentMsiId; int attributes = this.Backend.Architecture == PackageArchitecture.X64 ? 260 : 4; string condition = WixBackendCompilerServices.GenerateMsiCondition(this); if (!String.IsNullOrEmpty(condition)) { attributes |= 64; // mark Component transitive when there is a condition. } WixSection section = new WixSection(this.MsiId, "fragment", this.Item.LineNumber); WixBackendCompilerServices.GenerateRow(section, "Component", this.Item.LineNumber, componentId, // Id "*", // Guid folderMsiItem.MsiId, // Directory attributes, // Attributes condition, // Condition this.MsiId); // KeyPath this.GenerateSectionRowsForComponent(section, componentId); return(section); }
/// <summary> /// /// </summary> /// <param name="InteropPath"></param> /// <returns></returns> public static string GetComDllPath(string InteropPath) { string path = InteropPath; if (!System.IO.File.Exists(path)) { throw new FileNotFoundException(InteropPath + "文件不存在。"); } AssemblyName assName = System.Reflection.AssemblyName.GetAssemblyName(path); Assembly ass = Assembly.Load(assName); Type[] types = ass.GetTypes(); string classID = ""; foreach (Type type in types) { string guid = type.GUID.ToString().ToUpper(); if (guid.Length == 36) { classID = guid; break; } } Microsoft.Win32.RegistryKey classRoot, InprocServer; classRoot = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey("CLSID"); classRoot = classRoot.OpenSubKey("{" + classID + "}"); if (classRoot == null) { throw new Exception(InteropPath + "未注册."); } InprocServer = classRoot.OpenSubKey("InprocServer32"); path = InprocServer.GetValue(null).ToString(); return(path); }
private Dictionary <PackageItem, WixItem> ProcessIntermediates(IEnumerable <Intermediate> intermediates) { Dictionary <PackageItem, WixItem> wixItems = new Dictionary <PackageItem, WixItem>(); foreach (Intermediate intermediate in intermediates) { foreach (PackageItem item in intermediate.Items) { File file = item as File; if (file != null) { WixFile msiFile = new WixFile(this, file); wixItems.Add(file, msiFile); NgenPackageItem ngen; if (Ngen.TryGetPackageItem(file, out ngen)) { ngen.LineNumber = file.LineNumber; file.Items.Add(ngen); WixNativeImage nativeImage = new WixNativeImage(this, ngen); wixItems.Add(ngen, nativeImage); } } else { Folder folder = item as Folder; if (folder != null) { if (folder.External) { WixFolderReference msiFolderRef = new WixFolderReference(this, folder); wixItems.Add(folder, msiFolderRef); } else { WixFolder msiFolder = new WixFolder(this, folder); wixItems.Add(folder, msiFolder); } } else { InprocServer inprocServer = item as InprocServer; if (null != inprocServer) { WixClassId classId = new WixClassId(this, inprocServer); wixItems.Add(inprocServer, classId); } else { OutprocServer outprocServer = item as OutprocServer; if (null != outprocServer) { WixClassId classId = new WixClassId(this, outprocServer); wixItems.Add(outprocServer, classId); } else { Property property = item as Property; if (property != null) { WixProperty prop = new WixProperty(this, property); wixItems.Add(property, prop); } else { FileSearch fileSearch = item as FileSearch; if (fileSearch != null) { WixFileSearch fs = new WixFileSearch(this, fileSearch); wixItems.Add(fileSearch, fs); } else { Group group = item as Group; if (group != null) { WixGroup msiGroup = new WixGroup(this, group); wixItems.Add(group, msiGroup); } else if (item is Package) { // TODO: send an error message since library files cannot process Package elements. } } } } } } } } } // Fix up all the item parents and groups now that we have them // all processed into a single look up dictionary. foreach (var kv in wixItems) { PackageItem pi = kv.Key; WixItem wi = kv.Value; if (pi.Parent != null) { wi.Parent = wixItems[pi.Parent]; } if (pi.Group != null) { wi.Group = (WixGroup)wixItems[pi.Group]; wi.Group.ContainedWixItems.Add(wi); } } return(wixItems); }
public override void GenerateSectionRowsForComponent(WixSection section, string componentId) { InprocServer inprocServer = this.Item as InprocServer; OutprocServer outprocServer = this.Item as OutprocServer; IEnumerable <Class> classes = this.inproc ? inprocServer.Classes : outprocServer.Classes; foreach (Class classId in classes) { File fileItem = this.inproc ? inprocServer.File : outprocServer.File; WixItem msiFileItem = this.Backend.WixItems[fileItem]; string guidClassId = new Guid(classId.Id).ToString("B").ToUpperInvariant(); string key = this.GetKey(guidClassId); string value = String.Concat("[#", msiFileItem.MsiId, "]"); if (!this.inproc && !String.IsNullOrWhiteSpace(outprocServer.Arguments)) { value = String.Concat("\"", value, "\" ", outprocServer.Arguments); } string msiId = WixBackendCompilerServices.GenerateIdForRegKey(this.Backend, null, 0, key, null); WixBackendCompilerServices.GenerateRow(section, "Registry", this.Item.LineNumber, msiId, // Id 0, // HKCR key, // Key null, // Name value, // Value componentId); // Component string threadingModel = ConvertThreadingModel(classId.ThreadingModel); msiId = WixBackendCompilerServices.GenerateIdForRegKey(this.Backend, null, 0, key, "ThreadingModel"); WixBackendCompilerServices.GenerateRow(section, "Registry", this.Item.LineNumber, msiId, // Id 0, // HKCR key, // Key "ThreadingModel", // Name threadingModel, // Value componentId); // Component if (!String.IsNullOrEmpty(classId.Implementation)) { key = String.Concat("CLSID\\", guidClassId, "\\ProgID"); msiId = WixBackendCompilerServices.GenerateIdForRegKey(this.Backend, null, 0, key, null); WixBackendCompilerServices.GenerateRow(section, "Registry", this.Item.LineNumber, msiId, // Id 0, // HKCR key, // Key null, // Name classId.Implementation, // Value componentId); // Component key = String.Concat(classId.Implementation, "\\CLSID"); msiId = WixBackendCompilerServices.GenerateIdForRegKey(this.Backend, null, 0, key, null); WixBackendCompilerServices.GenerateRow(section, "Registry", this.Item.LineNumber, msiId, // Id 0, // HKCR key, // Key null, // Name guidClassId, // Value componentId); // Component } } }
public WixClassId(WixBackendCompiler backend, InprocServer inproc) : base(backend, inproc) { this.inproc = true; }