Пример #1
0
        public override WixSection GenerateSection()
        {
            if (this.System || String.IsNullOrEmpty(this.MsiId))
            {
                return(null);
            }

            Folder  folder        = (Folder)this.Item;
            WixItem parentMsiItem = WixBackendCompilerServices.ResolveParentFolderMsiItem(folder.ParentFolder, this.Backend.WixItems);

            if (parentMsiItem == null)
            {
                return(null);
            }

            WixSection section = new WixSection(this.MsiId, "fragment", this.Item.LineNumber);

            string defaultDir = String.IsNullOrEmpty(folder.Name) ? "." : WixBackendCompilerServices.GenerateMsiFileName(false, folder.Name.TrimEnd(new char[] { '\\' }), "Directory", parentMsiItem.MsiId);

            WixBackendCompilerServices.GenerateRow(section, "Directory", this.Item.LineNumber,
                                                   this.MsiId,          // Id
                                                   parentMsiItem.MsiId, // Directory_Parent
                                                   defaultDir);         // DefaultDir

            WixBackendCompilerServices.GenerateSimpleReference(section, "Directory", this.Item.LineNumber, parentMsiItem.MsiId);

            return(section);
        }
        /// <summary>
        /// Generates the final output from a set of intermediates.
        /// </summary>
        /// <param name="intermediates">Intermediates that provide data to be generated.</param>
        /// <param name="outputPath">Path for output file to be generated.</param>
        public override void Generate(IEnumerable <Intermediate> intermediates, string outputPath)
        {
            if (this.OutputType != CompilerOutputType.WixLibrary)
            {
                throw new NotImplementedException("Only creating .wixlib files is currently supported.");
            }

            this.WixItems = this.ProcessIntermediates(intermediates);

            XElement library = new XElement(WixBackendCompilerServices.WixlibNamespace + "wixLibrary",
                                            new XAttribute("version", WixBackendCompilerServices.WixlibVersion));

            foreach (WixItem item in this.WixItems.Values)
            {
                if (item.System) // skip system items.
                {
                    continue;
                }

                WixSection section = item.GenerateSection();
                if (section != null)
                {
                    library.Add(section.Xml);
                }
            }

            FileTransfer wixlibTransfer = FileTransfer.Create(null, IO.Path.GetTempFileName(), outputPath, "WixLibrary", true);

            using (IO.Stream wixlibStream = IO.File.Open(wixlibTransfer.Source, IO.FileMode.Create, IO.FileAccess.ReadWrite, IO.FileShare.Delete))
            {
                library.Save(wixlibStream);
            }

            FileTransfer.ExecuteTransfer(this, wixlibTransfer);
        }
        public override WixSection GenerateSection()
        {
            if (this.System)
            {
                return(null);
            }

            WixSection section = new WixSection(this.MsiId, "fragment", this.Item.LineNumber);

            this.GenerateComponentGroup(section);

            foreach (WixItem msiItem in this.ContainedWixItems)
            {
                if (msiItem.Item is Group) // nested Groups become ComponentGroupRefs
                {
                    this.CreateComponentGroupRef(section, msiItem.MsiId);
                }
                else if (!String.IsNullOrEmpty(msiItem.ComponentMsiId)) // must be an item that creates a Component.
                {
                    this.CreateComponentRef(section, msiItem.ComponentMsiId);
                }
            }

            return(section);
        }
        public static XElement GenerateSimpleReference(WixSection section, string tableName, FileLineNumber typeStartLineNumber, params string[] primaryKeys)
        {
            XElement row = GenerateRow(section, "WixSimpleReference", typeStartLineNumber);

            row.Add(new XElement(WixBackendCompilerServices.WixobjNamespace + "field", tableName));
            row.Add(new XElement(WixBackendCompilerServices.WixobjNamespace + "field", String.Join("/", primaryKeys)));

            return(row);
        }
Пример #5
0
        public override WixSection GenerateSection()
        {
            if (this.System)
            {
                return(null);
            }

            File    file          = (File)this.Item;
            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 ? 256 : 0;
            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);

            WixBackendCompilerServices.GenerateSimpleReference(section, "Directory", this.Item.LineNumber, folderMsiItem.MsiId);
            WixBackendCompilerServices.GenerateSimpleReference(section, "Media", this.Item.LineNumber, "1");

            foreach (ITargetFile targetFileItem in file.Items)
            {
                File childsFile = targetFileItem.GetTargetedFile();
                if (childsFile == file)
                {
                    WixItem item = this.Backend.WixItems[(PackageItem)targetFileItem];
                    item.GenerateSectionRowsForComponent(section, componentId);
                }
            }

            return(section);
        }
        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);
        }
Пример #7
0
        public override void GenerateSectionRowsForComponent(WixSection section, string componentId)
        {
            File    file          = (File)this.Item;
            WixItem folderMsiItem = WixBackendCompilerServices.ResolveParentFolderMsiItem(file.ParentFolder, this.Backend.WixItems);

            string fileId   = this.MsiId;
            string fileName = WixBackendCompilerServices.GenerateMsiFileName(true, file.Name, "File", fileId);
            bool   gac      = (folderMsiItem is WixFolderReference && folderMsiItem.System && folderMsiItem.Item.Id.Equals("GacFolder"));

            WixBackendCompilerServices.GenerateRow(section, "File", this.Item.LineNumber,
                                                   fileId,                                              // Id
                                                   componentId,                                         // Component
                                                   fileName,                                            // FileName
                                                   0,                                                   // Size
                                                   null,                                                // Version
                                                   null,                                                // Language
                                                   WixBackendCompilerServices.MsidbFileAttributesVital, // Attributes
                                                   null);                                               // Sequence

            WixBackendCompilerServices.GenerateRow(section, "WixFile", this.Item.LineNumber,
                                                   fileId,                                                                         // Id
                                                   gac ? "0" : null,                                                               // AssemblyAttributes
                                                   null,                                                                           // AssemblyManifest
                                                   null,                                                                           // AssemblyAssemblyApplication
                                                   folderMsiItem.MsiId,                                                            // Directory
                                                   1,                                                                              // DiskId
                                                   file.Source,                                                                    // Source
                                                   null /*file.Architecture*/,                                                     // TODO: make this right
                                                   -1,
                                                   String.Equals(file.Name, fileName, StringComparison.OrdinalIgnoreCase) ? 0 : 1, // GeneratedShortName
                                                   0,
                                                   null,
                                                   null,
                                                   null,
                                                   null);

            if (gac)
            {
                WixBackendCompilerServices.GenerateRow(section, "MsiAssembly", this.Item.LineNumber,
                                                       componentId,              // ComponentId
                                                       Guid.Empty.ToString("B"), // Feature (complex reference)
                                                       null,                     // AssemblyManifest
                                                       null,                     // AssemblyApplication
                                                       0);                       // AssemblyAttributes
            }
        }
        public override WixSection GenerateSection()
        {
            if (this.System)
            {
                return(null);
            }

            FileSearch fs = (FileSearch)this.Item;

            if (String.IsNullOrEmpty(fs.Id))
            {
                // TODO: display error that id is required.
                return(null);
            }

            WixSection section = new WixSection(fs.Id, "fragment", this.Item.LineNumber);

            WixBackendCompilerServices.GenerateRow(section, "AppSearch", this.Item.LineNumber,
                                                   this.MsiId, // Property
                                                   fs.Id);     // Signature_

            WixBackendCompilerServices.GenerateRow(section, "Property", this.Item.LineNumber,
                                                   this.MsiId, // Property
                                                   null);      // Value

            if (!String.IsNullOrEmpty(fs.Registry))
            {
                int root = ConvertRegistryRoot(fs.RegistryRoot);

                WixBackendCompilerServices.GenerateRow(section, "RegLocator", this.Item.LineNumber,
                                                       fs.Id,           // Signature_
                                                       root,            // Root
                                                       fs.RegistryKey,  // Key
                                                       fs.RegistryName, // Name
                                                       2);              // Type (raw)
            }
            else
            {
                WixBackendCompilerServices.GenerateRow(section, "CompLocator", this.Item.LineNumber,
                                                       fs.Id,                                         // Signature_
                                                       fs.Component.ToString("B").ToUpperInvariant(), // ComponentId
                                                       1);                                            // Type (file)
            }

            return(section);
        }
        private void CreateComponentRef(WixSection section, string refMsiId)
        {
            WixBackendCompilerServices.GenerateSimpleReference(section, "Component", this.Item.LineNumber, refMsiId);

            WixBackendCompilerServices.GenerateRow(section, "WixComplexReference", this.Item.LineNumber,
                                                   this.MsiId,
                                                   WixBackendCompilerServices.ComplexReferenceParentTypeComponentGroup,
                                                   null,
                                                   refMsiId,
                                                   WixBackendCompilerServices.ComplexReferenceChildTypeComponent,
                                                   0);

            WixBackendCompilerServices.GenerateRow(section, "WixGroup", this.Item.LineNumber,
                                                   this.MsiId,
                                                   "ComponentGroup",
                                                   refMsiId,
                                                   "Component");
        }
        public static XElement GenerateRow(WixSection section, string tableName, FileLineNumber typeStartLineNumber, params object[] fields)
        {
            string sourceLineNumbers = GenerateSourceLineNumbers(typeStartLineNumber);

            XElement row = new XElement(WixBackendCompilerServices.WixobjNamespace + "row",
                                        new XAttribute("sourceLineNumber", sourceLineNumbers));

            XElement table = section.GetTable(tableName);

            table.Add(row);

            foreach (var field in fields)
            {
                row.Add(new XElement(WixBackendCompilerServices.WixobjNamespace + "field", field));
            }

            return(row);
        }
Пример #11
0
        public override void GenerateSectionRowsForComponent(WixSection section, string componentId)
        {
            NgenPackageItem ngen = (NgenPackageItem)this.Item;

            int priority = 3;

            switch (ngen.Execute)
            {
            case NgenExecuteType.asynchronous:
                priority = 1;
                break;

            case NgenExecuteType.idle:
                priority = 3;
                break;

            case NgenExecuteType.immediate:
                priority = 0;
                break;
            }

            int attributes = 0x2; // dependencies are not processed automatically.

            switch (this.Backend.Architecture)
            {
            case PackageArchitecture.Arm:
            case PackageArchitecture.X86:
                attributes |= 0x8;     // 32-bit
                break;

            case PackageArchitecture.X64:
                attributes |= 0x10;     // 64-bit
                break;

            case PackageArchitecture.Unknown:
            case PackageArchitecture.Neutral:
                attributes |= 0x18;     // both
                break;
            }

            WixItem msiFileItem = this.Backend.WixItems[ngen.File];
            string  refTable    = null;
            string  refId       = null;

            string applicationFile = null;

            if (ngen.Application != null)
            {
                WixItem item = this.Backend.WixItems[ngen.Application.GetPackageItem()];
                if (item.Item is Lexicon.File)
                {
                    applicationFile = item.MsiId;
                    refTable        = "File";
                    refId           = item.MsiId;
                }
                else if (item.Item is Lexicon.Msi.Property || item.Item is Lexicon.Msi.FileSearch)
                {
                    applicationFile = String.Concat("[", item.MsiId, "]");
                    refTable        = "Property";
                    refId           = item.MsiId;
                }
                else
                {
                    // TODO: display error.
                }
            }

            string applicationFolder = null;

            if (ngen.Folder != null)
            {
                WixItem item = this.Backend.WixItems[ngen.Folder];
                applicationFolder = item.MsiId;
                refTable          = "Directory";
                refId             = item.MsiId;
            }

            if (!String.IsNullOrEmpty(refTable))
            {
                WixBackendCompilerServices.GenerateSimpleReference(section, refTable, this.Item.LineNumber, refId);
            }

            WixBackendCompilerServices.GenerateRow(section, "NetFxNativeImage", this.Item.LineNumber,
                                                   msiFileItem.MsiId,  // Id
                                                   msiFileItem.MsiId,  // File_
                                                   priority,           // Priority
                                                   attributes,         // Attributes
                                                   applicationFile,    // File_Application
                                                   applicationFolder); // Directory_ApplicationBase

            WixBackendCompilerServices.GenerateSimpleReference(section, "CustomAction", this.Item.LineNumber, "NetFxScheduleNativeImage");
        }
 private void GenerateComponentGroup(WixSection section)
 {
     WixBackendCompilerServices.GenerateRow(section, "WixComponentGroup", this.Item.LineNumber,
                                            this.MsiId);
 }
Пример #13
0
 public virtual void GenerateSectionRowsForComponent(WixSection section, string componentId)
 {
 }
        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
                }
            }
        }