Exemple #1
0
 public CreateBurnManifestCommand(string executableName, IntermediateSection section, WixBundleSymbol bundleSymbol, IEnumerable <WixBundleContainerSymbol> containers, WixChainSymbol chainSymbol, IEnumerable <PackageFacade> orderedPackages, IEnumerable <WixBundleRollbackBoundarySymbol> boundaries, IEnumerable <WixBundlePayloadSymbol> uxPayloads, Dictionary <string, WixBundlePayloadSymbol> allPayloadsById, Dictionary <string, Dictionary <string, WixBundlePayloadSymbol> > packagesPayloads, IEnumerable <ISearchFacade> orderedSearches, string intermediateFolder)
 {
     this.ExecutableName      = executableName;
     this.Section             = section;
     this.BundleSymbol        = bundleSymbol;
     this.Chain               = chainSymbol;
     this.Containers          = containers;
     this.OrderedPackages     = orderedPackages;
     this.RollbackBoundaries  = boundaries;
     this.UXContainerPayloads = uxPayloads;
     this.Payloads            = allPayloadsById;
     this.PackagesPayloads    = packagesPayloads;
     this.OrderedSearches     = orderedSearches;
     this.IntermediateFolder  = intermediateFolder;
 }
        /// <summary>
        /// Called after database variable resolution occurs.
        /// </summary>
        public override void SymbolsFinalized(IntermediateSection section)
        {
            // Only process MSI packages.
            if (section.Type != SectionType.Product)
            {
                return;
            }

            var tagSymbols = this.CreateProductTagFiles(section);

            foreach (var tagSymbol in tagSymbols)
            {
                section.Symbols.Add(tagSymbol);
            }
        }
Exemple #3
0
        /// <summary>
        /// Processes an element for the Compiler.
        /// </summary>
        /// <param name="intermediate"></param>
        /// <param name="section"></param>
        /// <param name="parentElement">Parent element of element to process.</param>
        /// <param name="element">Element to process.</param>
        /// <param name="context">Extra information about the context in which this element is being parsed.</param>
        public override void ParseElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary <string, string> context)
        {
            switch (parentElement.Name.LocalName)
            {
            case "Component":
                string componentId = context["ComponentId"];
                string directoryId = context["DirectoryId"];

                switch (element.Name.LocalName)
                {
                case "SqlDatabase":
                    this.ParseSqlDatabaseElement(intermediate, section, element, componentId);
                    break;

                case "SqlScript":
                    this.ParseSqlScriptElement(intermediate, section, element, componentId, null);
                    break;

                case "SqlString":
                    this.ParseSqlStringElement(intermediate, section, element, componentId, null);
                    break;

                default:
                    this.ParseHelper.UnexpectedElement(parentElement, element);
                    break;
                }
                break;

            case "Fragment":
            case "Module":
            case "Product":
                switch (element.Name.LocalName)
                {
                case "SqlDatabase":
                    this.ParseSqlDatabaseElement(intermediate, section, element, null);
                    break;

                default:
                    this.ParseHelper.UnexpectedElement(parentElement, element);
                    break;
                }
                break;

            default:
                this.ParseHelper.UnexpectedElement(parentElement, element);
                break;
            }
        }
Exemple #4
0
        /// <summary>
        /// Processes an element for the Compiler.
        /// </summary>
        /// <param name="intermediate"></param>
        /// <param name="section"></param>
        /// <param name="parentElement">Parent element of element to process.</param>
        /// <param name="element">Element to process.</param>
        /// <param name="context">Extra information about the context in which this element is being parsed.</param>
        public override void ParseElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary <string, string> context)
        {
            switch (parentElement.Name.LocalName)
            {
            case "Bundle":
            case "Fragment":
                switch (element.Name.LocalName)
                {
                case "Condition":
                    this.ParseConditionElement(intermediate, section, element);
                    break;

                case "ManagedBootstrapperApplicationPrereqInformation":
                    this.ParseMbaPrereqInfoElement(intermediate, section, element);
                    break;

                default:
                    this.ParseHelper.UnexpectedElement(parentElement, element);
                    break;
                }
                break;

            case "BootstrapperApplication":
                switch (element.Name.LocalName)
                {
                case "WixStandardBootstrapperApplication":
                    this.ParseWixStandardBootstrapperApplicationElement(intermediate, section, element);
                    break;

                case "WixManagedBootstrapperApplicationHost":
                    this.ParseWixManagedBootstrapperApplicationHostElement(intermediate, section, element);
                    break;

                case "WixDotNetCoreBootstrapperApplicationHost":
                    this.ParseWixDotNetCoreBootstrapperApplicationHostElement(intermediate, section, element);
                    break;

                default:
                    this.ParseHelper.UnexpectedElement(parentElement, element);
                    break;
                }
                break;

            default:
                this.ParseHelper.UnexpectedElement(parentElement, element);
                break;
            }
        }
Exemple #5
0
        /// <summary>
        /// Processes an element for the Compiler.
        /// </summary>
        /// <param name="sourceLineNumbers">Source line number for the parent element.</param>
        /// <param name="parentElement">Parent element of element to process.</param>
        /// <param name="element">Element to process.</param>
        /// <param name="contextValues">Extra information about the context in which this element is being parsed.</param>
        public override void ParseElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary <string, string> context)
        {
            switch (parentElement.Name.LocalName)
            {
            case "Bundle":
                switch (element.Name.LocalName)
                {
                case "Tag":
                    this.ParseBundleTagElement(intermediate, section, element);
                    break;

                default:
                    this.ParseHelper.UnexpectedElement(parentElement, element);
                    break;
                }
                break;

            case "Package":
                switch (element.Name.LocalName)
                {
                case "Tag":
                    this.ParsePackageTagElement(intermediate, section, element);
                    break;

                default:
                    this.ParseHelper.UnexpectedElement(parentElement, element);
                    break;
                }
                break;

            case "PatchFamily":
                switch (element.Name.LocalName)
                {
                case "TagRef":
                    this.ParseTagRefElement(intermediate, section, element);
                    break;

                default:
                    this.ParseHelper.UnexpectedElement(parentElement, element);
                    break;
                }
                break;

            default:
                this.ParseHelper.UnexpectedElement(parentElement, element);
                break;
            }
        }
        /// <summary>
        /// Parses a FormatsFile and TypesFile element.
        /// </summary>
        /// <param name="node">Element to parse.</param>
        /// <param name="valueName">Registry value name.</param>
        /// <param name="id">Idendifier for parent file or snap-in.</param>
        /// <param name="componentId">Identifier for parent component.</param>
        private void ParseExtensionsFile(Intermediate intermediate, IntermediateSection section, XElement node, string valueName, string id, string componentId)
        {
            var    sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node);
            string fileId            = null;
            string snapIn            = null;

            foreach (var attrib in node.Attributes())
            {
                if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace)
                {
                    switch (attrib.Name.LocalName)
                    {
                    case "FileId":
                        fileId = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
                        snapIn = id;
                        break;

                    case "SnapIn":
                        fileId = id;
                        snapIn = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
                        break;

                    default:
                        this.ParseHelper.UnexpectedAttribute(node, attrib);
                        break;
                    }
                }
                else
                {
                    this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib);
                }
            }

            if (null == fileId && null == snapIn)
            {
                this.Messaging.Write(PSErrors.NeitherIdSpecified(sourceLineNumbers, valueName));
            }

            this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node);

            var registryRoot = RegistryRootType.LocalMachine; // HKLM
            var registryKey  = String.Format(CultureInfo.InvariantCulture, KeyFormat, String.Format(CultureInfo.InvariantCulture, "!(wix.{0}_{1})", VarPrefix, snapIn), snapIn);

            this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.File, fileId);
            this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, valueName, String.Format(CultureInfo.InvariantCulture, "[~][#{0}]", fileId), componentId, false);
        }
Exemple #7
0
        /// <summary>
        /// Processes an element for the Compiler.
        /// </summary>
        /// <param name="sourceLineNumbers">Source line number for the parent element.</param>
        /// <param name="parentElement">Parent element of element to process.</param>
        /// <param name="element">Element to process.</param>
        /// <param name="contextValues">Extra information about the context in which this element is being parsed.</param>
        public override void ParseElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary <string, string> context)
        {
            switch (parentElement.Name.LocalName)
            {
            case "ServiceInstall":
                var serviceInstallName = context["ServiceInstallName"];
                var serviceUser        = String.IsNullOrEmpty(serviceInstallName) ? null : String.Concat("NT SERVICE\\", serviceInstallName);
                var serviceComponentId = context["ServiceInstallComponentId"];

                switch (element.Name.LocalName)
                {
                case "UrlReservation":
                    this.ParseUrlReservationElement(intermediate, section, element, serviceComponentId, serviceUser);
                    break;

                default:
                    this.ParseHelper.UnexpectedElement(parentElement, element);
                    break;
                }
                break;

            case "Component":
                string componentId = context["ComponentId"];

                switch (element.Name.LocalName)
                {
                case "SniSslCertificate":
                    this.ParseSniSslCertificateElement(intermediate, section, element, componentId);
                    break;

                case "UrlReservation":
                    this.ParseUrlReservationElement(intermediate, section, element, componentId, null);
                    break;

                default:
                    this.ParseHelper.UnexpectedElement(parentElement, element);
                    break;
                }
                break;

            default:
                this.ParseHelper.UnexpectedElement(parentElement, element);
                break;
            }
        }
        private void SchedulePropertyExeAction(IntermediateSection section, SourceLineNumber sourceLineNumbers, Identifier name, string source, string cmdline, CustomActionSymbol caTemplate, string condition, string beforeAction, string afterAction)
        {
            const SequenceTable sequence = SequenceTable.InstallExecuteSequence;

            caTemplate.SourceType = CustomActionSourceType.Property;
            caTemplate.Source     = source;
            caTemplate.TargetType = CustomActionTargetType.Exe;
            caTemplate.Target     = cmdline;
            section.AddSymbol(caTemplate);

            section.AddSymbol(new WixActionSymbol(sourceLineNumbers, new Identifier(name.Access, sequence, name.Id))
            {
                SequenceTable = SequenceTable.InstallExecuteSequence,
                Action        = name.Id,
                Condition     = condition,
                // no explicit sequence
                Before      = beforeAction,
                After       = afterAction,
                Overridable = false,
            });

            if (null != beforeAction)
            {
                if (WindowsInstallerStandard.IsStandardAction(beforeAction))
                {
                    this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.WixAction, sequence.ToString(), beforeAction);
                }
                else
                {
                    this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.CustomAction, beforeAction);
                }
            }

            if (null != afterAction)
            {
                if (WindowsInstallerStandard.IsStandardAction(afterAction))
                {
                    this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.WixAction, sequence.ToString(), afterAction);
                }
                else
                {
                    this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.CustomAction, afterAction);
                }
            }
        }
Exemple #9
0
        public override bool TryAddSymbolToOutput(IntermediateSection section, IntermediateSymbol symbol, WindowsInstallerData output, TableDefinitionCollection tableDefinitions)
        {
            if (ExampleSymbolDefinitions.TryGetSymbolType(symbol.Definition.Name, out var symbolType))
            {
                switch (symbolType)
                {
                case ExampleSymbolDefinitionType.Example:
                {
                    var row = (ExampleRow)this.BackendHelper.CreateRow(section, symbol, output, ExampleTableDefinitions.ExampleTable);
                    row.Example = symbol.Id.Id;
                    row.Value   = symbol[0].AsString();
                }
                    return(true);
                }
            }

            return(base.TryAddSymbolToOutput(section, symbol, output, tableDefinitions));
        }
Exemple #10
0
        public Identifier CreateDirectorySymbol(IntermediateSection section, SourceLineNumber sourceLineNumbers, Identifier id, string parentId, string name, string shortName = null, string sourceName = null, string shortSourceName = null)
        {
            if (null == id)
            {
                id = this.CreateIdentifier("d", parentId, name, shortName, sourceName, shortSourceName);
            }

            var symbol = section.AddSymbol(new DirectorySymbol(sourceLineNumbers, id)
            {
                ParentDirectoryRef = parentId,
                Name            = name,
                ShortName       = shortName,
                SourceName      = sourceName,
                SourceShortName = shortSourceName
            });

            return(symbol.Id);
        }
Exemple #11
0
        public void CanSaveAndLoadIntermediateWithCustomDefinitions()
        {
            var sln = new SourceLineNumber("test.wxs", 1);

            var section = new IntermediateSection("test", SectionType.Product, 65001);

            var fieldDefs = new[]
            {
                new IntermediateFieldDefinition("A", IntermediateFieldType.String),
                new IntermediateFieldDefinition("B", IntermediateFieldType.Number),
                new IntermediateFieldDefinition("C", IntermediateFieldType.Bool),
            };

            var symbolDef = new IntermediateSymbolDefinition("CustomDef2", fieldDefs, null);

            var symbol = symbolDef.CreateSymbol(sln, new Identifier(AccessModifier.Public, "customT"));

            symbol.Set(0, "foo");
            symbol.Set(1, 2);
            symbol.Set(2, true);

            section.Symbols.Add(symbol);

            var intermediate = new Intermediate("TestIntermediate", new[] { section }, null);

            var path = Path.GetTempFileName();

            try
            {
                intermediate.Save(path);

                var loaded        = Intermediate.Load(path);
                var loadedSection = loaded.Sections.Single();
                var loadedSymbol  = loadedSection.Symbols.Single();

                Assert.Equal("foo", loadedSymbol.AsString(0));
                Assert.Equal(2, loadedSymbol[1].AsNumber());
                Assert.True(loadedSymbol[2].AsBool());
            }
            finally
            {
                File.Delete(path);
            }
        }
        private void SchedulePropertyExeAction(IntermediateSection section, SourceLineNumber sourceLineNumbers, Identifier name, string source, string cmdline, int extraBits, string condition, string beforeAction, string afterAction)
        {
            const string sequence = "InstallExecuteSequence";

            var actionRow = this.ParseHelper.CreateRow(section, sourceLineNumbers, "CustomAction", name);

            actionRow.Set(1, VSCompiler.MsidbCustomActionTypeProperty | VSCompiler.MsidbCustomActionTypeExe | extraBits);
            actionRow.Set(2, source);
            actionRow.Set(3, cmdline);

            var sequenceRow = this.ParseHelper.CreateRow(section, sourceLineNumbers, "WixAction", new Identifier(name.Access, sequence, name.Id));

            sequenceRow.Set(0, sequence);
            sequenceRow.Set(1, name.Id);
            sequenceRow.Set(2, condition);
            // no explicit sequence
            sequenceRow.Set(4, beforeAction);
            sequenceRow.Set(5, afterAction);
            sequenceRow.Set(6, 0); // not overridable

            if (null != beforeAction)
            {
                if (WindowsInstallerStandard.IsStandardAction(beforeAction))
                {
                    this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "WixAction", sequence, beforeAction);
                }
                else
                {
                    this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", beforeAction);
                }
            }

            if (null != afterAction)
            {
                if (WindowsInstallerStandard.IsStandardAction(afterAction))
                {
                    this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "WixAction", sequence, afterAction);
                }
                else
                {
                    this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", afterAction);
                }
            }
        }
Exemple #13
0
        public string CreateDirectoryReferenceFromInlineSyntax(IntermediateSection section, SourceLineNumber sourceLineNumbers, XAttribute attribute, string parentId)
        {
            string id = null;

            string[] inlineSyntax = this.GetAttributeInlineDirectorySyntax(sourceLineNumbers, attribute, true);

            if (null != inlineSyntax)
            {
                // Special case the single entry in the inline syntax since it is the most common case
                // and needs no extra processing. It's just a reference to an existing directory.
                if (1 == inlineSyntax.Length)
                {
                    id = inlineSyntax[0];
                    this.CreateSimpleReference(section, sourceLineNumbers, "Directory", id);
                }
                else // start creating rows for the entries in the inline syntax
                {
                    id = parentId;

                    int pathStartsAt = 0;
                    if (inlineSyntax[0].EndsWith(":"))
                    {
                        // TODO: should overriding the parent identifier with a specific id be an error or a warning or just let it slide?
                        //if (null != parentId)
                        //{
                        //    this.core.Write(WixErrors.Xxx(sourceLineNumbers));
                        //}

                        id = inlineSyntax[0].TrimEnd(':');
                        this.CreateSimpleReference(section, sourceLineNumbers, "Directory", id);

                        pathStartsAt = 1;
                    }

                    for (int i = pathStartsAt; i < inlineSyntax.Length; ++i)
                    {
                        Identifier inlineId = this.CreateDirectoryRow(section, sourceLineNumbers, null, id, inlineSyntax[i]);
                        id = inlineId.Id;
                    }
                }
            }

            return(id);
        }
Exemple #14
0
        public void CreateWixGroupRow(IntermediateSection section, SourceLineNumber sourceLineNumbers, ComplexReferenceParentType parentType, string parentId, ComplexReferenceChildType childType, string childId)
        {
            if (null == parentId || ComplexReferenceParentType.Unknown == parentType)
            {
                return;
            }

            if (null == childId)
            {
                throw new ArgumentNullException("childId");
            }

            var row = (WixGroupTuple)this.CreateRow(section, sourceLineNumbers, TupleDefinitionType.WixGroup);

            row.ParentId   = parentId;
            row.ParentType = parentType;
            row.ChildId    = childId;
            row.ChildType  = childType;
        }
Exemple #15
0
        public void EnsureTable(IntermediateSection section, SourceLineNumber sourceLineNumbers, string tableName)
        {
            var row = this.CreateRow(section, sourceLineNumbers, TupleDefinitionType.WixEnsureTable);

            row.Set(0, tableName);

            if (this.Creator == null)
            {
                this.CreateTupleDefinitionCreator();
            }

            // We don't add custom table definitions to the tableDefinitions collection,
            // so if it's not in there, it better be a custom table. If the Id is just wrong,
            // instead of a custom table, we get an unresolved reference at link time.
            if (!this.Creator.TryGetTupleDefinitionByName(tableName, out var ignored))
            {
                this.CreateSimpleReference(section, sourceLineNumbers, "WixCustomTable", tableName);
            }
        }
Exemple #16
0
        private void ParseHelpFilterRefElement(Intermediate intermediate, IntermediateSection section, XElement element, Identifier collectionId)
        {
            var        sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element);
            Identifier id = null;

            foreach (var attrib in element.Attributes())
            {
                if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace)
                {
                    switch (attrib.Name.LocalName)
                    {
                    case "Id":
                        id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib);
                        this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, VSSymbolDefinitions.HelpFilter, id.Id);
                        break;

                    default:
                        this.ParseHelper.UnexpectedAttribute(element, attrib);
                        break;
                    }
                }
                else
                {
                    this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib);
                }
            }

            if (null == id)
            {
                this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Id"));
            }

            this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element);

            if (!this.Messaging.EncounteredError)
            {
                section.AddSymbol(new HelpFilterToNamespaceSymbol(sourceLineNumbers, id)
                {
                    HelpFilterRef    = id.Id,
                    HelpNamespaceRef = collectionId.Id,
                });
            }
        }
        public override void ParseElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary <string, string> context)
        {
            var processed = false;

            switch (parentElement.Name.LocalName)
            {
            case "Bundle":
            case "Fragment":
                switch (element.Name.LocalName)
                {
                case "ExampleEnsureTable":
                    this.ParseExampleEnsureTableElement(intermediate, section, element);
                    processed = true;
                    break;

                case "ExampleSearch":
                    this.ParseExampleSearchElement(intermediate, section, element);
                    processed = true;
                    break;

                case "ExampleSearchRef":
                    this.ParseExampleSearchRefElement(intermediate, section, element);
                    processed = true;
                    break;
                }
                break;

            case "Component":
                switch (element.Name.LocalName)
                {
                case "Example":
                    this.ParseExampleElement(intermediate, section, element);
                    processed = true;
                    break;
                }
                break;
            }

            if (!processed)
            {
                base.ParseElement(intermediate, section, parentElement, element, context);
            }
        }
Exemple #18
0
        private static IList<SoftwareTag> CollectPackageTags(IntermediateSection section)
        {
            var tags = new List<SoftwareTag>();

            var msiPackages = section.Symbols.OfType<WixBundlePackageSymbol>().Where(s => s.Type == WixBundlePackageType.Msi).ToList();
            if (msiPackages.Any())
            {
                var payloadSymbolsById = section.Symbols.OfType<WixBundlePayloadSymbol>().ToDictionary(s => s.Id.Id);

                foreach (var msiPackage in msiPackages)
                {
                    var payload = payloadSymbolsById[msiPackage.PayloadRef];

                    using (var db = new Database(payload.SourceFile.Path))
                    {
                        using (var view = db.OpenView("SELECT `Regid`, `UniqueId`, `Type` FROM `SoftwareIdentificationTag`"))
                        {
                            view.Execute();
                            while (true)
                            {
                                using (var record = view.Fetch())
                                {
                                    if (null == record)
                                    {
                                        break;
                                    }

                                    if (!Enum.TryParse(record.GetString(3), out TagType type))
                                    {
                                        type = TagType.Unknown;
                                    }

                                    tags.Add(new SoftwareTag() { Regid = record.GetString(1), Id = record.GetString(2), Type = type });
                                }
                            }
                        }
                    }
                }
            }

            return tags;
        }
        private void ParseExampleElement(Intermediate intermediate, IntermediateSection section, XElement element)
        {
            var        sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element);
            Identifier id    = null;
            string     value = null;

            foreach (var attrib in element.Attributes())
            {
                if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace)
                {
                    switch (attrib.Name.LocalName)
                    {
                    case "Id":
                        id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib);
                        break;

                    case "Value":
                        value = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
                        break;

                    default:
                        this.ParseHelper.UnexpectedAttribute(element, attrib);
                        break;
                    }
                }
                else
                {
                    this.ParseAttribute(intermediate, section, element, attrib, null);
                }
            }

            if (null == id)
            {
                //this.Messaging(WixErrors.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Id"));
            }

            if (!this.Messaging.EncounteredError)
            {
                var tuple = this.ParseHelper.CreateRow(section, sourceLineNumbers, "Example", id);
                tuple.Set(1, value);
            }
        }
Exemple #20
0
        /// <summary>
        /// Parses a TagRef element for Software Id Tag registration under a PatchFamily element.
        /// </summary>
        /// <param name="node">The element to parse.</param>
        private void ParseTagRefElement(Intermediate intermediate, IntermediateSection section, XElement node)
        {
            var    sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node);
            string regid             = null;

            foreach (var attrib in node.Attributes())
            {
                if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace)
                {
                    switch (attrib.Name.LocalName)
                    {
                    case "Regid":
                        regid = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
                        break;

                    default:
                        this.ParseHelper.UnexpectedAttribute(node, attrib);
                        break;
                    }
                }
                else
                {
                    this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib);
                }
            }

            this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node);

            if (String.IsNullOrEmpty(regid))
            {
                this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Regid"));
            }

            if (!this.Messaging.EncounteredError)
            {
                var id = this.ParseHelper.CreateIdentifier("tag", regid, ".product.tag");
#if TODO_PATCHING
                this.ParseHelper.CreatePatchFamilyChildReference(sourceLineNumbers, "Component", id.Id);
#endif
                throw new NotImplementedException();
            }
        }
Exemple #21
0
        public void CanSaveAndLoadIntermediate()
        {
            var sln = new SourceLineNumber("test.wxs", 1);

            var section = new IntermediateSection("test", SectionType.Product, 65001);

            section.Symbols.Add(new ComponentSymbol(sln, new Identifier(AccessModifier.Public, "TestComponent"))
            {
                ComponentId  = new Guid(1, 0, 0, new byte[8]).ToString("B"),
                DirectoryRef = "TestFolder",
                Location     = ComponentLocation.Either,
            });

            var intermediate = new Intermediate("TestIntermediate", IntermediateLevels.Compiled, new[] { section }, null);

            intermediate.UpdateLevel(IntermediateLevels.Linked);
            intermediate.UpdateLevel(IntermediateLevels.Resolved);

            var path = Path.GetTempFileName();

            try
            {
                intermediate.Save(path);

                var loaded = Intermediate.Load(path);

                Assert.True(loaded.HasLevel(IntermediateLevels.Compiled));
                Assert.True(loaded.HasLevel(IntermediateLevels.Linked));
                Assert.True(loaded.HasLevel(IntermediateLevels.Resolved));

                var symbol = (ComponentSymbol)loaded.Sections.Single().Symbols.Single();

                Assert.Equal("TestComponent", symbol.Id.Id);
                Assert.Equal(AccessModifier.Public, symbol.Id.Access);
                Assert.Equal("TestFolder", symbol.DirectoryRef);
                Assert.Equal(ComponentLocation.Either, symbol.Location);
            }
            finally
            {
                File.Delete(path);
            }
        }
Exemple #22
0
        /// <summary>
        /// Called for each extension symbol that hasn't been handled yet.
        /// </summary>
        /// <param name="section">The linked section.</param>
        /// <param name="symbol">The current symbol.</param>
        /// <returns>True if the symbol is a Bundle tag symbol.</returns>
        public override bool TryProcessSymbol(IntermediateSection section, IntermediateSymbol symbol)
        {
            if (symbol is WixBundleTagSymbol tagSymbol)
            {
                tagSymbol.Xml = CalculateTagXml(section, tagSymbol);

                var fragment = new XDocument(
                    new XElement("WixSoftwareTag",
                        new XAttribute("Filename", tagSymbol.Filename),
                        new XAttribute("Regid", tagSymbol.Regid),
                        new XCData(tagSymbol.Xml)
                        )
                    );

                this.BackendHelper.AddBootstrapperApplicationData(fragment.Root.ToString(SaveOptions.DisableFormatting | SaveOptions.OmitDuplicateNamespaces));
                return true;
            }

            return false;
        }
        private void FinalizeBAFactorySymbol(IntermediateSection section)
        {
            var factorySymbol = section.Symbols.OfType <WixBalBAFactoryAssemblySymbol>().SingleOrDefault();

            if (null == factorySymbol)
            {
                return;
            }

            var factoryPayloadSymbol = section.Symbols.OfType <WixBundlePayloadSymbol>()
                                       .Where(p => p.Id.Id == factorySymbol.PayloadId)
                                       .SingleOrDefault();

            if (null == factoryPayloadSymbol)
            {
                return;
            }

            factorySymbol.FilePath = factoryPayloadSymbol.Name;
        }
Exemple #24
0
        private static IntermediateTuple CreateRow(IntermediateSection section, SourceLineNumber sourceLineNumbers, IntermediateTupleDefinition tupleDefinition, Identifier identifier)
        {
            var row = tupleDefinition.CreateTuple(sourceLineNumbers, identifier);

            if (null != identifier)
            {
                if (row.Definition.FieldDefinitions[0].Type == IntermediateFieldType.Number)
                {
                    row.Set(0, Convert.ToInt32(identifier.Id));
                }
                else
                {
                    row.Set(0, identifier.Id);
                }
            }

            section.Tuples.Add(row);

            return(row);
        }
        /// <summary>
        /// Processes the Extension/@IsRichSavedGame attribute.
        /// </summary>
        /// <param name="sourceLineNumbers">Source line number for the parent element.</param>
        /// <param name="contextValues">Extra information about the context in which this element is being parsed.</param>
        private void ProcessIsRichSavedGameAttribute(IntermediateSection section, SourceLineNumber sourceLineNumbers, IDictionary <string, string> context)
        {
            var progId      = context["ProgId"];
            var componentId = context["ComponentId"];
            var extensionId = context["ExtensionId"];

            if (null == extensionId || null == progId || null == componentId)
            {
                this.Messaging.Write(ErrorMessages.ExpectedParentWithAttribute(sourceLineNumbers, "Extension", "IsRichSavedGame", "ProgId"));
            }

            if (!this.Messaging.EncounteredError)
            {
                // write Registry rows according to http://msdn2.microsoft.com/en-us/library/bb173448.aspx
                this.ParseHelper.CreateRegistryTuple(section, sourceLineNumbers, RegistryRootType.ClassesRoot, progId, "PreviewTitle", "prop:System.Game.RichSaveName;System.Game.RichApplicationName", componentId, false);
                this.ParseHelper.CreateRegistryTuple(section, sourceLineNumbers, RegistryRootType.ClassesRoot, progId, "PreviewDetails", "prop:System.Game.RichLevel;System.DateChanged;System.Game.RichComment;System.DisplayName;System.DisplayType", componentId, false);
                this.ParseHelper.CreateRegistryTuple(section, sourceLineNumbers, RegistryRootType.ClassesRoot, String.Concat(".", extensionId, "\\{BB2E617C-0920-11D1-9A0B-00C04FC2D6C1}"), null, "{4E5BFBF8-F59A-4E87-9805-1F9B42CC254A}", componentId, false);
                this.ParseHelper.CreateRegistryTuple(section, sourceLineNumbers, RegistryRootType.LocalMachine, String.Concat("Software\\Microsoft\\Windows\\CurrentVersion\\PropertySystem\\PropertyHandlers\\.", extensionId), null, "{ECDD6472-2B9B-4B4B-AE36-F316DF3C8D60}", componentId, false);
            }
        }
        /// <summary>
        /// Determine if a single symbol is accessible by the referencing section.
        /// </summary>
        /// <param name="referencingSection">Section referencing the symbol.</param>
        /// <param name="symbolWithSection">Symbol being referenced.</param>
        /// <returns>True if symbol is accessible.</returns>
        private bool AccessibleSymbol(IntermediateSection referencingSection, SymbolWithSection symbolWithSection)
        {
            switch (symbolWithSection.Access)
            {
            case AccessModifier.Global:
                return(true);

            case AccessModifier.Library:
                return(symbolWithSection.Section.CompilationId == referencingSection.CompilationId || (null != symbolWithSection.Section.LibraryId && symbolWithSection.Section.LibraryId == referencingSection.LibraryId));

            case AccessModifier.File:
                return(symbolWithSection.Section.CompilationId == referencingSection.CompilationId);

            case AccessModifier.Section:
                return(referencingSection == symbolWithSection.Section);

            default:
                throw new ArgumentOutOfRangeException(nameof(symbolWithSection.Access));
            }
        }
        /// <summary>
        /// Determine if a single symbol is accessible by the referencing section.
        /// </summary>
        /// <param name="referencingSection">Section referencing the symbol.</param>
        /// <param name="symbolWithSection">Symbol being referenced.</param>
        /// <returns>True if symbol is accessible.</returns>
        private bool AccessibleSymbol(IntermediateSection referencingSection, SymbolWithSection symbolWithSection)
        {
            switch (symbolWithSection.Access)
            {
            case AccessModifier.Public:
                return(true);

            case AccessModifier.Internal:
                return(symbolWithSection.Section.CompilationId.Equals(referencingSection.CompilationId) || (null != symbolWithSection.Section.LibraryId && symbolWithSection.Section.LibraryId.Equals(referencingSection.LibraryId)));

            case AccessModifier.Protected:
                return(symbolWithSection.Section.CompilationId.Equals(referencingSection.CompilationId));

            case AccessModifier.Private:
                return(referencingSection == symbolWithSection.Section);

            default:
                throw new ArgumentOutOfRangeException(nameof(symbolWithSection.Access));
            }
        }
Exemple #28
0
        public void CreateWixGroupSymbol(IntermediateSection section, SourceLineNumber sourceLineNumbers, ComplexReferenceParentType parentType, string parentId, ComplexReferenceChildType childType, string childId)
        {
            if (null == parentId || ComplexReferenceParentType.Unknown == parentType)
            {
                return;
            }

            if (null == childId)
            {
                throw new ArgumentNullException(nameof(childId));
            }

            section.AddSymbol(new WixGroupSymbol(sourceLineNumbers)
            {
                ParentId   = parentId,
                ParentType = parentType,
                ChildId    = childId,
                ChildType  = childType,
            });
        }
        public void GeneratesCorrectCustomActionIdentifiers()
        {
            var serviceProvider = WixToolsetServiceProviderFactory.CreateServiceProvider();
            var section         = new IntermediateSection("section", SectionType.Fragment, 0);
            var parseHelper     = serviceProvider.GetService <IParseHelper>();

            parseHelper.CreateCustomActionReference(null, section, "CustomAction32", Platform.X86, CustomActionPlatforms.X86);
            parseHelper.CreateCustomActionReference(null, section, "CustomArmAction", Platform.ARM64, CustomActionPlatforms.X86);
            parseHelper.CreateCustomActionReference(null, section, "CustomArmAction", Platform.ARM64, CustomActionPlatforms.X86 | CustomActionPlatforms.X64 | CustomActionPlatforms.ARM64);
            parseHelper.CreateCustomActionReference(null, section, "CustomAction", Platform.X64, CustomActionPlatforms.X86);
            parseHelper.CreateCustomActionReference(null, section, "CustomAction", Platform.X64, CustomActionPlatforms.X86 | CustomActionPlatforms.X64);

            var simpleReferences = section.Symbols.OfType <WixSimpleReferenceSymbol>();

            Assert.NotNull(simpleReferences.Where(t => t.SymbolicName == "CustomAction:Wix4CustomAction32_X86").FirstOrDefault());
            Assert.NotNull(simpleReferences.Where(t => t.SymbolicName == "CustomAction:Wix4CustomArmAction_X86").FirstOrDefault());
            Assert.NotNull(simpleReferences.Where(t => t.SymbolicName == "CustomAction:Wix4CustomArmAction_A64").FirstOrDefault());
            Assert.NotNull(simpleReferences.Where(t => t.SymbolicName == "CustomAction:Wix4CustomAction_X86").FirstOrDefault());
            Assert.NotNull(simpleReferences.Where(t => t.SymbolicName == "CustomAction:Wix4CustomAction_X64").FirstOrDefault());
        }
        /// <summary>
        /// Parses a RemoteAddress element
        /// </summary>
        /// <param name="element">The element to parse.</param>
        private void ParseRemoteAddressElement(Intermediate intermediate, IntermediateSection section, XElement element, ref string remoteAddresses)
        {
            var    sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element);
            string address           = null;

            // no attributes
            foreach (var attrib in element.Attributes())
            {
                if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace)
                {
                    switch (attrib.Name.LocalName)
                    {
                    case "Value":
                        address = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
                        break;
                    }
                }
                else
                {
                    this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib);
                }
            }

            this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element);

            if (String.IsNullOrEmpty(address))
            {
                this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Value"));
            }
            else
            {
                if (String.IsNullOrEmpty(remoteAddresses))
                {
                    remoteAddresses = address;
                }
                else
                {
                    remoteAddresses = String.Concat(remoteAddresses, ",", address);
                }
            }
        }