Example #1
0
            public ComponentRow AddComponentRow(string DisplayName, string HelpText, string Id, uint Characteristics, System.Guid InstanceGuid, string PnpDevNodeId, System.Guid ClassGuid, string BindName)
            {
                ComponentRow rowComponentRow = ((ComponentRow)(this.NewRow()));

                object[] columnValuesArray = new object[] {
                    DisplayName,
                    HelpText,
                    Id,
                    Characteristics,
                    InstanceGuid,
                    PnpDevNodeId,
                    ClassGuid,
                    BindName
                };
                rowComponentRow.ItemArray = columnValuesArray;
                this.Rows.Add(rowComponentRow);
                return(rowComponentRow);
            }
        public void ComponentUsesInlineDirectorySyntax()
        {
            XDocument doc = XDocument.Parse("<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'><Product Id='*' Language='1033' Manufacturer='WixTests' Name='ComponentUsesInlineDirectorySyntax' Version='1.0.0' UpgradeCode='12345678-1234-1234-1234-1234567890AB'><Feature Id='Feature1'><ComponentRef Id='Component1'/></Feature></Product>" +
                                            @"<Fragment><Component Id='protected Component1' Directory='BinFolder:\comp\' /></Fragment>" +
                                            @"<Fragment><Directory Id='protected BinFolder' Name='TARGETDIR:\foo\bar\bin\' /></Fragment>" +
                                            "<Fragment><Directory Id='TARGETDIR' Name='SourceDir' /></Fragment></Wix>");
            XDocument src      = new Preprocessor().Process(doc.CreateReader(), new Dictionary <string, string>());
            Compiler  compiler = new Compiler();
            Linker    linker   = new Linker();

            Intermediate intermediate = compiler.Compile(src);
            Output       output       = linker.Link(intermediate.Sections, OutputType.Product);

            RowIndexedList <Row> directoryRows = new RowIndexedList <Row>(output.Sections.SelectMany(sec => sec.Tables).Where(t => t.Name.Equals("Directory")).SelectMany(d => d.Rows));
            ComponentRow         componentRow  = output.Sections.SelectMany(sec => sec.Tables).Where(t => t.Name.Equals("Component")).SelectMany(c => c.Rows).Cast <ComponentRow>().Single();
            Row compFolder = directoryRows.Get(componentRow.Directory);

            Assert.NotNull(compFolder);
            Assert.Equal(AccessModifier.Private, compFolder.Access);
            Assert.Equal("BinFolder", compFolder[1]);
            Assert.Equal("comp", compFolder[2]);
        }
Example #3
0
        /// <summary>
        /// Creates a new row in the table.
        /// </summary>
        /// <param name="sourceLineNumbers">Original source lines for this row.</param>
        /// <param name="add">Specifies whether to only create the row or add it to the table automatically.</param>
        /// <returns>Row created in table.</returns>
        public Row CreateRow(SourceLineNumber sourceLineNumbers, bool add = true)
        {
            Row row;

            switch (this.Name)
            {
            case "BBControl":
                row = new BBControlRow(sourceLineNumbers, this);
                break;

            case "WixBundlePackage":
                row = new WixBundlePackageRow(sourceLineNumbers, this);
                break;

            case "WixBundleExePackage":
                row = new WixBundleExePackageRow(sourceLineNumbers, this);
                break;

            case "WixBundleMsiPackage":
                row = new WixBundleMsiPackageRow(sourceLineNumbers, this);
                break;

            case "WixBundleMspPackage":
                row = new WixBundleMspPackageRow(sourceLineNumbers, this);
                break;

            case "WixBundleMsuPackage":
                row = new WixBundleMsuPackageRow(sourceLineNumbers, this);
                break;

            case "Component":
                row = new ComponentRow(sourceLineNumbers, this);
                break;

            case "WixBundleContainer":
                row = new WixBundleContainerRow(sourceLineNumbers, this);
                break;

            case "Control":
                row = new ControlRow(sourceLineNumbers, this);
                break;

            case "File":
                row = new FileRow(sourceLineNumbers, this);
                break;

            case "WixBundleMsiFeature":
                row = new WixBundleMsiFeatureRow(sourceLineNumbers, this);
                break;

            case "WixBundleMsiProperty":
                row = new WixBundleMsiPropertyRow(sourceLineNumbers, this);
                break;

            case "Media":
                row = new MediaRow(sourceLineNumbers, this);
                break;

            case "WixBundlePayload":
                row = new WixBundlePayloadRow(sourceLineNumbers, this);
                break;

            case "Property":
                row = new PropertyRow(sourceLineNumbers, this);
                break;

            case "WixRelatedBundle":
                row = new WixRelatedBundleRow(sourceLineNumbers, this);
                break;

            case "WixBundleRelatedPackage":
                row = new WixBundleRelatedPackageRow(sourceLineNumbers, this);
                break;

            case "WixBundleRollbackBoundary":
                row = new WixBundleRollbackBoundaryRow(sourceLineNumbers, this);
                break;

            case "Upgrade":
                row = new UpgradeRow(sourceLineNumbers, this);
                break;

            case "WixBundleVariable":
                row = new WixBundleVariableRow(sourceLineNumbers, this);
                break;

            case "WixAction":
                row = new WixActionRow(sourceLineNumbers, this);
                break;

            case "WixApprovedExeForElevation":
                row = new WixApprovedExeForElevationRow(sourceLineNumbers, this);
                break;

            case "WixBundle":
                row = new WixBundleRow(sourceLineNumbers, this);
                break;

            case "WixBundlePackageExitCode":
                row = new WixBundlePackageExitCodeRow(sourceLineNumbers, this);
                break;

            case "WixBundlePatchTargetCode":
                row = new WixBundlePatchTargetCodeRow(sourceLineNumbers, this);
                break;

            case "WixBundleSlipstreamMsp":
                row = new WixBundleSlipstreamMspRow(sourceLineNumbers, this);
                break;

            case "WixBundleUpdate":
                row = new WixBundleUpdateRow(sourceLineNumbers, this);
                break;

            case "WixBundleCatalog":
                row = new WixBundleCatalogRow(sourceLineNumbers, this);
                break;

            case "WixChain":
                row = new WixChainRow(sourceLineNumbers, this);
                break;

            case "WixChainItem":
                row = new WixChainItemRow(sourceLineNumbers, this);
                break;

            case "WixBundlePackageCommandLine":
                row = new WixBundlePackageCommandLineRow(sourceLineNumbers, this);
                break;

            case "WixComplexReference":
                row = new WixComplexReferenceRow(sourceLineNumbers, this);
                break;

            case "WixDeltaPatchFile":
                row = new WixDeltaPatchFileRow(sourceLineNumbers, this);
                break;

            case "WixDeltaPatchSymbolPaths":
                row = new WixDeltaPatchSymbolPathsRow(sourceLineNumbers, this);
                break;

            case "WixFile":
                row = new WixFileRow(sourceLineNumbers, this);
                break;

            case "WixGroup":
                row = new WixGroupRow(sourceLineNumbers, this);
                break;

            case "WixMedia":
                row = new WixMediaRow(sourceLineNumbers, this);
                break;

            case "WixMediaTemplate":
                row = new WixMediaTemplateRow(sourceLineNumbers, this);
                break;

            case "WixMerge":
                row = new WixMergeRow(sourceLineNumbers, this);
                break;

            case "WixPayloadProperties":
                row = new WixPayloadPropertiesRow(sourceLineNumbers, this);
                break;

            case "WixProperty":
                row = new WixPropertyRow(sourceLineNumbers, this);
                break;

            case "WixSimpleReference":
                row = new WixSimpleReferenceRow(sourceLineNumbers, this);
                break;

            case "WixUpdateRegistration":
                row = new WixUpdateRegistrationRow(sourceLineNumbers, this);
                break;

            case "WixVariable":
                row = new WixVariableRow(sourceLineNumbers, this);
                break;

            default:
                row = new Row(sourceLineNumbers, this);
                break;
            }

            if (add)
            {
                this.Rows.Add(row);
            }

            return(row);
        }
Example #4
0
        /// <summary>
        /// Parses a Tag element for Software Id Tag registration under a Product element.
        /// </summary>
        /// <param name="node">The element to parse.</param>
        private void ParseProductTagElement(XmlNode node)
        {
            SourceLineNumberCollection sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
            string    name     = null;
            string    regid    = null;
            string    feature  = "WixSwidTag";
            YesNoType licensed = YesNoType.NotSet;
            string    type     = null;;

            foreach (XmlAttribute attrib in node.Attributes)
            {
                if (0 == attrib.NamespaceURI.Length || attrib.NamespaceURI == this.schema.TargetNamespace)
                {
                    switch (attrib.LocalName)
                    {
                    case "Name":
                        name = this.Core.GetAttributeLongFilename(sourceLineNumbers, attrib, false);
                        break;

                    case "Regid":
                        regid = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
                        break;

                    case "Feature":
                        feature = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
                        break;

                    case "Licensed":
                        licensed = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
                        break;

                    case "Type":
                        type = this.ParseTagTypeAttribute(sourceLineNumbers, node, attrib);
                        break;

                    default:
                        this.Core.UnexpectedAttribute(sourceLineNumbers, attrib);
                        break;
                    }
                }
                else
                {
                    this.Core.UnsupportedExtensionAttribute(sourceLineNumbers, attrib);
                }
            }

            foreach (XmlNode child in node.ChildNodes)
            {
                if (XmlNodeType.Element == child.NodeType)
                {
                    if (child.NamespaceURI == this.Schema.TargetNamespace)
                    {
                        this.Core.UnexpectedElement(node, child);
                    }
                    else
                    {
                        this.Core.UnsupportedExtensionElement(node, child);
                    }
                }
            }

            if (String.IsNullOrEmpty(name))
            {
                XmlAttribute productNameAttribute = node.ParentNode.Attributes["Name"];
                if (null != productNameAttribute)
                {
                    name = productNameAttribute.Value;
                }
                else
                {
                    this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name, "Name"));
                }
            }

            if (!String.IsNullOrEmpty(name) && !CompilerCore.IsValidLongFilename(name, false))
            {
                this.Core.OnMessage(TagErrors.IllegalName(sourceLineNumbers, node.ParentNode.LocalName, name));
            }

            if (String.IsNullOrEmpty(regid))
            {
                this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name, "Regid"));
            }

            if (!this.Core.EncounteredError)
            {
                string directoryId = "WixTagRegidFolder";
                string fileId      = this.Core.GenerateIdentifier("tag", regid, ".product.tag");
                string fileName    = String.Concat(regid, " ", name, ".swidtag");
                string shortName   = this.Core.GenerateShortName(fileName, false, false);

                this.Core.CreateWixSimpleReferenceRow(sourceLineNumbers, "Directory", directoryId);

                ComponentRow componentRow = (ComponentRow)this.Core.CreateRow(sourceLineNumbers, "Component");
                componentRow.Component   = fileId;
                componentRow.Guid        = "*";
                componentRow[3]          = 0;
                componentRow.Directory   = directoryId;
                componentRow.IsLocalOnly = true;
                componentRow.KeyPath     = fileId;

                this.Core.CreateWixSimpleReferenceRow(sourceLineNumbers, "Feature", feature);
                this.Core.CreateComplexReference(sourceLineNumbers, ComplexReferenceParentType.Feature, feature, null, ComplexReferenceChildType.Component, fileId, true);

                FileRow fileRow = (FileRow)this.Core.CreateRow(sourceLineNumbers, "File");
                fileRow.File      = fileId;
                fileRow.Component = fileId;
                fileRow.FileName  = String.Concat(shortName, "|", fileName);

                WixFileRow wixFileRow = (WixFileRow)this.Core.CreateRow(sourceLineNumbers, "WixFile");
                wixFileRow.Directory  = directoryId;
                wixFileRow.File       = fileId;
                wixFileRow.DiskId     = 1;
                wixFileRow.Attributes = 1;
                wixFileRow.Source     = String.Concat("%TEMP%\\", fileName);

                this.Core.EnsureTable(sourceLineNumbers, "SoftwareIdentificationTag");
                Row row = this.Core.CreateRow(sourceLineNumbers, "WixProductTag");
                row[0] = fileId;
                row[1] = regid;
                row[2] = name;
                if (YesNoType.Yes == licensed)
                {
                    row[3] = 1;
                }
                row[4] = type;

                this.Core.CreateWixSimpleReferenceRow(sourceLineNumbers, "File", fileId);
            }
        }
Example #5
0
 public ComponentRowChangeEvent(ComponentRow row, global::System.Data.DataRowAction action)
 {
     this.eventRow    = row;
     this.eventAction = action;
 }
Example #6
0
 public void RemoveComponentRow(ComponentRow row)
 {
     this.Rows.Remove(row);
 }
Example #7
0
 public void AddComponentRow(ComponentRow row)
 {
     this.Rows.Add(row);
 }
Example #8
0
        /// <summary>
        /// Parses a Tag element for Software Id Tag registration under a Product element.
        /// </summary>
        /// <param name="node">The element to parse.</param>
        private void ParseProductTagElement(XmlNode node)
        {
            SourceLineNumberCollection sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
            string name             = null;
            string regid            = null;
            string feature          = "WixSwidTag";
            string installDirectory = null;
            bool   win64            = (Platform.IA64 == this.Core.CurrentPlatform || Platform.X64 == this.Core.CurrentPlatform);

            foreach (XmlAttribute attrib in node.Attributes)
            {
                if (0 == attrib.NamespaceURI.Length || attrib.NamespaceURI == this.schema.TargetNamespace)
                {
                    switch (attrib.LocalName)
                    {
                    case "Name":
                        name = this.Core.GetAttributeLongFilename(sourceLineNumbers, attrib, false);
                        break;

                    case "Regid":
                        regid = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
                        break;

                    case "Feature":
                        feature = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
                        break;

                    case "InstallDirectory":
                        installDirectory = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
                        break;

                    case "InstallPath":
                        this.Core.OnMessage(WixErrors.ExpectedParentWithAttribute(sourceLineNumbers, node.Name, attrib.Name, "Bundle"));
                        break;

                    case "Licensed":
                        this.Core.OnMessage(WixWarnings.DeprecatedAttribute(sourceLineNumbers, node.Name, attrib.Name));
                        break;

                    case "Type":
                        this.Core.OnMessage(WixWarnings.DeprecatedAttribute(sourceLineNumbers, node.Name, attrib.Name));
                        break;

                    case "Win64":
                        win64 = (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib));
                        break;

                    default:
                        this.Core.UnexpectedAttribute(sourceLineNumbers, attrib);
                        break;
                    }
                }
                else
                {
                    this.Core.UnsupportedExtensionAttribute(sourceLineNumbers, attrib);
                }
            }

            foreach (XmlNode child in node.ChildNodes)
            {
                if (XmlNodeType.Element == child.NodeType)
                {
                    if (child.NamespaceURI == this.Schema.TargetNamespace)
                    {
                        this.Core.UnexpectedElement(node, child);
                    }
                    else
                    {
                        this.Core.UnsupportedExtensionElement(node, child);
                    }
                }
            }

            if (String.IsNullOrEmpty(name))
            {
                XmlAttribute productNameAttribute = node.ParentNode.Attributes["Name"];
                if (null != productNameAttribute)
                {
                    name = productNameAttribute.Value;
                }
                else
                {
                    this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name, "Name"));
                }
            }

            if (!String.IsNullOrEmpty(name) && !CompilerCore.IsValidLongFilename(name, false))
            {
                this.Core.OnMessage(TagErrors.IllegalName(sourceLineNumbers, node.ParentNode.LocalName, name));
            }

            if (String.IsNullOrEmpty(regid))
            {
                this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name, "Regid"));
            }
            else if (regid.StartsWith("regid."))
            {
                this.Core.OnMessage(TagWarnings.DeprecatedRegidFormat(sourceLineNumbers, regid));
                return;
            }
            else if (regid.Equals("example.com", StringComparison.OrdinalIgnoreCase))
            {
                this.Core.OnMessage(TagErrors.ExampleRegid(sourceLineNumbers, regid));
                return;
            }

            if (String.IsNullOrEmpty(installDirectory))
            {
                this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name, "InstallDirectory"));
            }

            if (!this.Core.EncounteredError)
            {
                string fileId    = this.Core.GenerateIdentifier("tag", regid, ".product.tag");
                string fileName  = String.Concat(name, ".swidtag");
                string shortName = this.Core.GenerateShortName(fileName, false, false);

                Row directoryRow = this.Core.CreateRow(sourceLineNumbers, "Directory");
                directoryRow[0] = "WixTagInstallFolder";
                directoryRow[1] = installDirectory;
                directoryRow[2] = ".";

                this.Core.CreateWixSimpleReferenceRow(sourceLineNumbers, "Directory", installDirectory);

                ComponentRow componentRow = (ComponentRow)this.Core.CreateRow(sourceLineNumbers, "Component");
                componentRow.Component   = fileId;
                componentRow.Guid        = "*";
                componentRow[3]          = (win64 ? TagCompiler.MsidbComponentAttributes64bit : 0);
                componentRow.Directory   = TagCompiler.TagFolderId;
                componentRow.IsLocalOnly = true;
                componentRow.KeyPath     = fileId;

                this.Core.CreateWixSimpleReferenceRow(sourceLineNumbers, "Directory", TagCompiler.TagFolderId);

                this.Core.CreateWixSimpleReferenceRow(sourceLineNumbers, "Feature", feature);
                this.Core.CreateComplexReference(sourceLineNumbers, ComplexReferenceParentType.Feature, feature, null, ComplexReferenceChildType.Component, fileId, true);

                FileRow fileRow = (FileRow)this.Core.CreateRow(sourceLineNumbers, "File");
                fileRow.File      = fileId;
                fileRow.Component = fileId;
                fileRow.FileName  = String.Concat(shortName, "|", fileName);

                WixFileRow wixFileRow = (WixFileRow)this.Core.CreateRow(sourceLineNumbers, "WixFile");
                wixFileRow.Directory  = TagCompiler.TagFolderId;
                wixFileRow.File       = fileId;
                wixFileRow.DiskId     = 1;
                wixFileRow.Attributes = 1;
                wixFileRow.Source     = fileName;

                this.Core.EnsureTable(sourceLineNumbers, "SoftwareIdentificationTag");
                Row row = this.Core.CreateRow(sourceLineNumbers, "WixProductTag");
                row[0] = fileId;
                row[1] = regid;
                row[2] = name;

                this.Core.CreateWixSimpleReferenceRow(sourceLineNumbers, "File", fileId);
            }
        }
Example #9
0
 public ComponentRowChangeEvent(ComponentRow row, global::System.Data.DataRowAction action) {
     this.eventRow = row;
     this.eventAction = action;
 }
Example #10
0
 public void RemoveComponentRow(ComponentRow row) {
     this.Rows.Remove(row);
 }
Example #11
0
 public void AddComponentRow(ComponentRow row) {
     this.Rows.Add(row);
 }