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);
        }
Exemple #2
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);
        }
        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 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");
        }