Ejemplo n.º 1
0
            public void AddSymbol(IntermediateSymbol symbol, bool symbolIdIsIdAttribute, string ns)
            {
                // There might be a more efficient way to do this,
                // but this is an easy way to ensure we're creating valid XML.
                var sb = new StringBuilder();

                using (var writer = XmlWriter.Create(sb, WriterSettings))
                {
                    writer.WriteStartElement(symbol.Definition.Name, ns);

                    if (symbolIdIsIdAttribute && symbol.Id != null)
                    {
                        writer.WriteAttributeString("Id", symbol.Id.Id);
                    }

                    foreach (var field in symbol.Fields)
                    {
                        if (!field.IsNull())
                        {
                            writer.WriteAttributeString(field.Definition.Name, field.AsString());
                        }
                    }

                    writer.WriteEndElement();
                }

                this.AddXml(sb.ToString());
            }
Ejemplo n.º 2
0
        private static void SetSymbolFieldsFromRow(Wix3.Row row, IntermediateSymbol symbol, bool columnZeroIsId)
        {
            var offset = 0;

            if (columnZeroIsId)
            {
                offset = 1;
            }

            for (var i = offset; i < row.Fields.Length; ++i)
            {
                var column = row.Fields[i].Column;
                switch (column.Type)
                {
                case Wix3.ColumnType.String:
                case Wix3.ColumnType.Localized:
                case Wix3.ColumnType.Object:
                case Wix3.ColumnType.Preserved:
                    symbol.Set(i - offset, FieldAsString(row, i));
                    break;

                case Wix3.ColumnType.Number:
                    int?nullableValue = FieldAsNullableInt(row, i);
                    // TODO: Consider whether null values should be coerced to their default value when
                    // a column is not nullable. For now, just pass through the null.
                    //int value = FieldAsInt(row, i);
                    //symbol.Set(i - offset, column.IsNullable ? nullableValue : value);
                    symbol.Set(i - offset, nullableValue);
                    break;

                case Wix3.ColumnType.Unknown:
                    break;
                }
            }
        }
Ejemplo n.º 3
0
        public PackageFacade(WixBundlePackageSymbol packageSymbol, IntermediateSymbol specificPackageSymbol)
        {
            Debug.Assert(packageSymbol.Id.Id == specificPackageSymbol.Id.Id);

            this.PackageSymbol         = packageSymbol;
            this.SpecificPackageSymbol = specificPackageSymbol;
        }
        public static IntermediateField Set(this IntermediateSymbol symbol, int index, int value)
        {
            var definition = symbol.Definition.FieldDefinitions[index];

            var field = symbol.Fields[index].Set(definition, value);

            return(symbol.Fields[index] = field);
        }
        /// <summary>
        /// See <see cref="IWindowsInstallerBackendBinderExtension.TryProcessSymbol(IntermediateSection, IntermediateSymbol, WindowsInstallerData, TableDefinitionCollection)"/>
        /// </summary>
        public virtual bool TryProcessSymbol(IntermediateSection section, IntermediateSymbol symbol, WindowsInstallerData data, TableDefinitionCollection tableDefinitions)
        {
            if (this.TableDefinitions.Any(t => t.SymbolDefinition == symbol.Definition))
            {
                return(this.BackendHelper.TryAddSymbolToMatchingTableDefinitions(section, symbol, data, tableDefinitions));
            }

            return(false);
        }
Ejemplo n.º 6
0
        public Row CreateRow(IntermediateSection section, IntermediateSymbol symbol, WindowsInstallerData output, TableDefinition tableDefinition)
        {
            var table = output.EnsureTable(tableDefinition);

            var row = table.CreateRow(symbol.SourceLineNumbers);
            row.SectionId = section.Id;

            return row;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// See <see cref="IBurnBackendBinderExtension.TryProcessSymbol(IntermediateSection, IntermediateSymbol)"/>
        /// </summary>
        public virtual bool TryProcessSymbol(IntermediateSection section, IntermediateSymbol symbol)
        {
            if (this.SymbolDefinitions.Any(t => t == symbol.Definition) &&
                symbol.Definition.HasTag(BurnConstants.BootstrapperApplicationDataSymbolDefinitionTag))
            {
                this.BackendHelper.AddBootstrapperApplicationData(symbol);
                return(true);
            }

            return(false);
        }
Ejemplo n.º 8
0
            public Item(IntermediateSymbol row, string type, string id)
            {
                this.Row  = row;
                this.Type = type;
                this.Id   = id;

                this.Key = ItemCollection.CreateKeyFromTypeId(type, id);

                this.afterItems          = new ItemCollection();
                this.beforeItems         = new ItemCollection();
                this.flattenedAfterItems = false;
            }
Ejemplo n.º 9
0
        private static IntermediateSymbol GenericSymbolFromCustomRow(Wix3.Row row, bool columnZeroIsId)
        {
            var columnDefinitions = row.Table.Definition.Columns.Cast <Wix3.ColumnDefinition>();
            var fieldDefinitions  = columnDefinitions.Select(columnDefinition =>
                                                             new IntermediateFieldDefinition(columnDefinition.Name, ColumnType3ToIntermediateFieldType4(columnDefinition.Type))).ToArray();
            var symbolDefinition = new IntermediateSymbolDefinition(row.Table.Name, fieldDefinitions, null);
            var symbol           = new IntermediateSymbol(symbolDefinition, SourceLineNumber4(row.SourceLineNumbers));

            SetSymbolFieldsFromRow(row, symbol, columnZeroIsId);

            return(symbol);
        }
        private bool AddSymbolFromExtension(IntermediateSymbol symbol)
        {
            foreach (var extension in this.BackendExtensions)
            {
                if (extension.TryAddSymbolToDataManifest(this.Section, symbol))
                {
                    return(true);
                }
            }

            return(false);
        }
        public static IntermediateField Set(this IntermediateSymbol symbol, int index, string value)
        {
            if (value == null && NoFieldMetadata(symbol, index))
            {
                return(symbol.Fields[index] = null);
            }

            var definition = symbol.Definition.FieldDefinitions[index];

            var field = symbol.Fields[index].Set(definition, value);

            return(symbol.Fields[index] = field);
        }
Ejemplo n.º 12
0
        public static bool IsIdentical(this IntermediateSymbol first, IntermediateSymbol second)
        {
            var identical = (first.Definition.Type == second.Definition.Type &&
                             (first.Definition.Type != SymbolDefinitionType.MustBeFromAnExtension || first.Definition.Name == second.Definition.Name) &&
                             first.Definition.FieldDefinitions.Length == second.Definition.FieldDefinitions.Length);

            for (var i = 0; identical && i < first.Definition.FieldDefinitions.Length; ++i)
            {
                var firstField  = first[i];
                var secondField = second[i];

                identical = (firstField.AsString() == secondField.AsString());
            }

            return(identical);
        }
Ejemplo n.º 13
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));
        }
Ejemplo n.º 14
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;
        }
 public static bool AsBool(this IntermediateSymbol symbol, int index) => symbol?.Fields[index].AsBool() ?? false;
 public static bool?AsNullableBool(this IntermediateSymbol symbol, int index) => symbol?.Fields[index].AsNullableBool();
Ejemplo n.º 17
0
        private static IEnumerable <string> SymbolToStrings(IntermediateSymbol symbol, Dictionary <string, AssemblySymbol> assemblySymbolsByFileId)
        {
            var name = symbol.Definition.Type == SymbolDefinitionType.SummaryInformation ? "_SummaryInformation" : symbol.Definition.Name;
            var id   = symbol.Id?.Id ?? String.Empty;

            string fields;

            switch (symbol.Definition.Name)
            {
            // Massage output to match WiX v3 rows and v4 symbols.
            //
            case "Component":
            {
                var componentSymbol = (ComponentSymbol)symbol;
                var attributes      = ComponentLocation.Either == componentSymbol.Location ? WindowsInstallerConstants.MsidbComponentAttributesOptional : 0;
                attributes |= ComponentLocation.SourceOnly == componentSymbol.Location ? WindowsInstallerConstants.MsidbComponentAttributesSourceOnly : 0;
                attributes |= ComponentKeyPathType.Registry == componentSymbol.KeyPathType ? WindowsInstallerConstants.MsidbComponentAttributesRegistryKeyPath : 0;
                attributes |= ComponentKeyPathType.OdbcDataSource == componentSymbol.KeyPathType ? WindowsInstallerConstants.MsidbComponentAttributesODBCDataSource : 0;
                attributes |= componentSymbol.DisableRegistryReflection ? WindowsInstallerConstants.MsidbComponentAttributesDisableRegistryReflection : 0;
                attributes |= componentSymbol.NeverOverwrite ? WindowsInstallerConstants.MsidbComponentAttributesNeverOverwrite : 0;
                attributes |= componentSymbol.Permanent ? WindowsInstallerConstants.MsidbComponentAttributesPermanent : 0;
                attributes |= componentSymbol.SharedDllRefCount ? WindowsInstallerConstants.MsidbComponentAttributesSharedDllRefCount : 0;
                attributes |= componentSymbol.Shared ? WindowsInstallerConstants.MsidbComponentAttributesShared : 0;
                attributes |= componentSymbol.Transitive ? WindowsInstallerConstants.MsidbComponentAttributesTransitive : 0;
                attributes |= componentSymbol.UninstallWhenSuperseded ? WindowsInstallerConstants.MsidbComponentAttributes64bit : 0;
                attributes |= componentSymbol.Win64 ? WindowsInstallerConstants.MsidbComponentAttributes64bit : 0;

                fields = String.Join(",",
                                     componentSymbol.ComponentId,
                                     componentSymbol.DirectoryRef,
                                     attributes.ToString(),
                                     componentSymbol.Condition,
                                     componentSymbol.KeyPath
                                     );
                break;
            }

            case "CustomAction":
            {
                var customActionSymbol = (CustomActionSymbol)symbol;
                var type = customActionSymbol.Win64 ? WindowsInstallerConstants.MsidbCustomActionType64BitScript : 0;
                type |= customActionSymbol.TSAware ? WindowsInstallerConstants.MsidbCustomActionTypeTSAware : 0;
                type |= customActionSymbol.Impersonate ? 0 : WindowsInstallerConstants.MsidbCustomActionTypeNoImpersonate;
                type |= customActionSymbol.IgnoreResult ? WindowsInstallerConstants.MsidbCustomActionTypeContinue : 0;
                type |= customActionSymbol.Hidden ? WindowsInstallerConstants.MsidbCustomActionTypeHideTarget : 0;
                type |= customActionSymbol.Async ? WindowsInstallerConstants.MsidbCustomActionTypeAsync : 0;
                type |= CustomActionExecutionType.FirstSequence == customActionSymbol.ExecutionType ? WindowsInstallerConstants.MsidbCustomActionTypeFirstSequence : 0;
                type |= CustomActionExecutionType.OncePerProcess == customActionSymbol.ExecutionType ? WindowsInstallerConstants.MsidbCustomActionTypeOncePerProcess : 0;
                type |= CustomActionExecutionType.ClientRepeat == customActionSymbol.ExecutionType ? WindowsInstallerConstants.MsidbCustomActionTypeClientRepeat : 0;
                type |= CustomActionExecutionType.Deferred == customActionSymbol.ExecutionType ? WindowsInstallerConstants.MsidbCustomActionTypeInScript : 0;
                type |= CustomActionExecutionType.Rollback == customActionSymbol.ExecutionType ? WindowsInstallerConstants.MsidbCustomActionTypeInScript | WindowsInstallerConstants.MsidbCustomActionTypeRollback : 0;
                type |= CustomActionExecutionType.Commit == customActionSymbol.ExecutionType ? WindowsInstallerConstants.MsidbCustomActionTypeInScript | WindowsInstallerConstants.MsidbCustomActionTypeCommit : 0;
                type |= CustomActionSourceType.File == customActionSymbol.SourceType ? WindowsInstallerConstants.MsidbCustomActionTypeSourceFile : 0;
                type |= CustomActionSourceType.Directory == customActionSymbol.SourceType ? WindowsInstallerConstants.MsidbCustomActionTypeDirectory : 0;
                type |= CustomActionSourceType.Property == customActionSymbol.SourceType ? WindowsInstallerConstants.MsidbCustomActionTypeProperty : 0;
                type |= CustomActionTargetType.Dll == customActionSymbol.TargetType ? WindowsInstallerConstants.MsidbCustomActionTypeDll : 0;
                type |= CustomActionTargetType.Exe == customActionSymbol.TargetType ? WindowsInstallerConstants.MsidbCustomActionTypeExe : 0;
                type |= CustomActionTargetType.TextData == customActionSymbol.TargetType ? WindowsInstallerConstants.MsidbCustomActionTypeTextData : 0;
                type |= CustomActionTargetType.JScript == customActionSymbol.TargetType ? WindowsInstallerConstants.MsidbCustomActionTypeJScript : 0;
                type |= CustomActionTargetType.VBScript == customActionSymbol.TargetType ? WindowsInstallerConstants.MsidbCustomActionTypeVBScript : 0;

                fields = String.Join(",",
                                     type.ToString(),
                                     customActionSymbol.Source,
                                     customActionSymbol.Target,
                                     customActionSymbol.PatchUninstall ? WindowsInstallerConstants.MsidbCustomActionTypePatchUninstall.ToString() : null
                                     );
                break;
            }

            case "Directory":
            {
                var directorySymbol = (DirectorySymbol)symbol;

                if (!String.IsNullOrEmpty(directorySymbol.ComponentGuidGenerationSeed))
                {
                    yield return($"WixDirectory:{directorySymbol.Id.Id},{directorySymbol.ComponentGuidGenerationSeed}");
                }

                fields = String.Join(",", directorySymbol.ParentDirectoryRef, directorySymbol.Name, directorySymbol.ShortName, directorySymbol.SourceName, directorySymbol.SourceShortName);
                break;
            }

            case "Feature":
            {
                var featureSymbol = (FeatureSymbol)symbol;
                var attributes    = featureSymbol.DisallowAbsent ? WindowsInstallerConstants.MsidbFeatureAttributesUIDisallowAbsent : 0;
                attributes |= featureSymbol.DisallowAdvertise ? WindowsInstallerConstants.MsidbFeatureAttributesDisallowAdvertise : 0;
                attributes |= FeatureInstallDefault.FollowParent == featureSymbol.InstallDefault ? WindowsInstallerConstants.MsidbFeatureAttributesFollowParent : 0;
                attributes |= FeatureInstallDefault.Source == featureSymbol.InstallDefault ? WindowsInstallerConstants.MsidbFeatureAttributesFavorSource : 0;
                attributes |= FeatureTypicalDefault.Advertise == featureSymbol.TypicalDefault ? WindowsInstallerConstants.MsidbFeatureAttributesFavorAdvertise : 0;

                fields = String.Join(",",
                                     featureSymbol.ParentFeatureRef,
                                     featureSymbol.Title,
                                     featureSymbol.Description,
                                     featureSymbol.Display.ToString(),
                                     featureSymbol.Level.ToString(),
                                     featureSymbol.DirectoryRef,
                                     attributes.ToString());
                break;
            }

            case "File":
            {
                var fileSymbol = (FileSymbol)symbol;

                if (fileSymbol.BindPath != null)
                {
                    yield return($"BindImage:{fileSymbol.Id.Id},{fileSymbol.BindPath}");
                }

                if (fileSymbol.FontTitle != null)
                {
                    yield return($"Font:{fileSymbol.Id.Id},{fileSymbol.FontTitle}");
                }

                if (fileSymbol.SelfRegCost.HasValue)
                {
                    yield return($"SelfReg:{fileSymbol.Id.Id},{fileSymbol.SelfRegCost}");
                }

                int?assemblyAttributes = null;
                if (assemblySymbolsByFileId.TryGetValue(fileSymbol.Id.Id, out var assemblySymbol))
                {
                    if (assemblySymbol.Type == AssemblyType.DotNetAssembly)
                    {
                        assemblyAttributes = 0;
                    }
                    else if (assemblySymbol.Type == AssemblyType.Win32Assembly)
                    {
                        assemblyAttributes = 1;
                    }
                }

                yield return("WixFile:" + String.Join(",",
                                                      fileSymbol.Id.Id,
                                                      assemblyAttributes,
                                                      assemblySymbol?.ManifestFileRef,
                                                      assemblySymbol?.ApplicationFileRef,
                                                      fileSymbol.DirectoryRef,
                                                      fileSymbol.DiskId,
                                                      fileSymbol.Source.Path,
                                                      null, // assembly processor arch
                                                      fileSymbol.PatchGroup,
                                                      0,
                                                      (int)fileSymbol.PatchAttributes,
                                                      fileSymbol.RetainLengths,
                                                      fileSymbol.IgnoreOffsets,
                                                      fileSymbol.IgnoreLengths,
                                                      fileSymbol.RetainOffsets
                                                      ));

                var fileAttributes = 0;
                fileAttributes |= (fileSymbol.Attributes & FileSymbolAttributes.ReadOnly) != 0 ? WindowsInstallerConstants.MsidbFileAttributesReadOnly : 0;
                fileAttributes |= (fileSymbol.Attributes & FileSymbolAttributes.Hidden) != 0 ? WindowsInstallerConstants.MsidbFileAttributesHidden : 0;
                fileAttributes |= (fileSymbol.Attributes & FileSymbolAttributes.System) != 0 ? WindowsInstallerConstants.MsidbFileAttributesSystem : 0;
                fileAttributes |= (fileSymbol.Attributes & FileSymbolAttributes.Vital) != 0 ? WindowsInstallerConstants.MsidbFileAttributesVital : 0;
                fileAttributes |= (fileSymbol.Attributes & FileSymbolAttributes.Checksum) != 0 ? WindowsInstallerConstants.MsidbFileAttributesChecksum : 0;
                fileAttributes |= (fileSymbol.Attributes & FileSymbolAttributes.Compressed) != 0 ? WindowsInstallerConstants.MsidbFileAttributesCompressed : 0;
                fileAttributes |= (fileSymbol.Attributes & FileSymbolAttributes.Uncompressed) != 0 ? WindowsInstallerConstants.MsidbFileAttributesNoncompressed : 0;

                fields = String.Join(",",
                                     fileSymbol.ComponentRef,
                                     fileSymbol.Name,
                                     fileSymbol.FileSize.ToString(),
                                     fileSymbol.Version,
                                     fileSymbol.Language,
                                     fileAttributes);
                break;
            }

            case "Media":
                fields = String.Join(",", symbol.Fields.Skip(1).Select(SafeConvertField));
                break;

            case "Assembly":
            {
                var assemblySymbol = (AssemblySymbol)symbol;

                id     = null;
                name   = "MsiAssembly";
                fields = String.Join(",", assemblySymbol.ComponentRef, assemblySymbol.FeatureRef, assemblySymbol.ManifestFileRef, assemblySymbol.ApplicationFileRef, assemblySymbol.Type == AssemblyType.Win32Assembly ? 1 : 0);
                break;
            }

            case "RegLocator":
            {
                var locatorSymbol = (RegLocatorSymbol)symbol;

                fields = String.Join(",", (int)locatorSymbol.Root, locatorSymbol.Key, locatorSymbol.Name, (int)locatorSymbol.Type, locatorSymbol.Win64);
                break;
            }

            case "Registry":
            {
                var registrySymbol = (RegistrySymbol)symbol;
                var value          = registrySymbol.Value;

                switch (registrySymbol.ValueType)
                {
                case RegistryValueType.Binary:
                    value = String.Concat("#x", value);
                    break;

                case RegistryValueType.Expandable:
                    value = String.Concat("#%", value);
                    break;

                case RegistryValueType.Integer:
                    value = String.Concat("#", value);
                    break;

                case RegistryValueType.MultiString:
                    switch (registrySymbol.ValueAction)
                    {
                    case RegistryValueActionType.Append:
                        value = String.Concat("[~]", value);
                        break;

                    case RegistryValueActionType.Prepend:
                        value = String.Concat(value, "[~]");
                        break;

                    case RegistryValueActionType.Write:
                    default:
                        if (null != value && -1 == value.IndexOf("[~]", StringComparison.Ordinal))
                        {
                            value = String.Concat("[~]", value, "[~]");
                        }
                        break;
                    }
                    break;

                case RegistryValueType.String:
                    // escape the leading '#' character for string registry keys
                    if (null != value && value.StartsWith("#", StringComparison.Ordinal))
                    {
                        value = String.Concat("#", value);
                    }
                    break;
                }

                fields = String.Join(",",
                                     ((int)registrySymbol.Root).ToString(),
                                     registrySymbol.Key,
                                     registrySymbol.Name,
                                     value,
                                     registrySymbol.ComponentRef
                                     );
                break;
            }

            case "RemoveRegistry":
            {
                var removeRegistrySymbol = (RemoveRegistrySymbol)symbol;
                fields = String.Join(",",
                                     ((int)removeRegistrySymbol.Root).ToString(),
                                     removeRegistrySymbol.Key,
                                     removeRegistrySymbol.Name,
                                     removeRegistrySymbol.ComponentRef
                                     );
                break;
            }

            case "ServiceControl":
            {
                var serviceControlSymbol = (ServiceControlSymbol)symbol;

                var events = serviceControlSymbol.InstallRemove ? WindowsInstallerConstants.MsidbServiceControlEventDelete : 0;
                events |= serviceControlSymbol.UninstallRemove ? WindowsInstallerConstants.MsidbServiceControlEventUninstallDelete : 0;
                events |= serviceControlSymbol.InstallStart ? WindowsInstallerConstants.MsidbServiceControlEventStart : 0;
                events |= serviceControlSymbol.UninstallStart ? WindowsInstallerConstants.MsidbServiceControlEventUninstallStart : 0;
                events |= serviceControlSymbol.InstallStop ? WindowsInstallerConstants.MsidbServiceControlEventStop : 0;
                events |= serviceControlSymbol.UninstallStop ? WindowsInstallerConstants.MsidbServiceControlEventUninstallStop : 0;

                fields = String.Join(",",
                                     serviceControlSymbol.Name,
                                     events.ToString(),
                                     serviceControlSymbol.Arguments,
                                     serviceControlSymbol.Wait == true ? "1" : "0",
                                     serviceControlSymbol.ComponentRef
                                     );
                break;
            }

            case "ServiceInstall":
            {
                var serviceInstallSymbol = (ServiceInstallSymbol)symbol;

                var errorControl = (int)serviceInstallSymbol.ErrorControl;
                errorControl |= serviceInstallSymbol.Vital ? WindowsInstallerConstants.MsidbServiceInstallErrorControlVital : 0;

                var serviceType = (int)serviceInstallSymbol.ServiceType;
                serviceType |= serviceInstallSymbol.Interactive ? WindowsInstallerConstants.MsidbServiceInstallInteractive : 0;

                fields = String.Join(",",
                                     serviceInstallSymbol.Name,
                                     serviceInstallSymbol.DisplayName,
                                     serviceType.ToString(),
                                     ((int)serviceInstallSymbol.StartType).ToString(),
                                     errorControl.ToString(),
                                     serviceInstallSymbol.LoadOrderGroup,
                                     serviceInstallSymbol.Dependencies,
                                     serviceInstallSymbol.StartName,
                                     serviceInstallSymbol.Password,
                                     serviceInstallSymbol.Arguments,
                                     serviceInstallSymbol.ComponentRef,
                                     serviceInstallSymbol.Description
                                     );
                break;
            }

            case "Upgrade":
            {
                var upgradeSymbol = (UpgradeSymbol)symbol;

                var attributes = upgradeSymbol.MigrateFeatures ? WindowsInstallerConstants.MsidbUpgradeAttributesMigrateFeatures : 0;
                attributes |= upgradeSymbol.OnlyDetect ? WindowsInstallerConstants.MsidbUpgradeAttributesOnlyDetect : 0;
                attributes |= upgradeSymbol.IgnoreRemoveFailures ? WindowsInstallerConstants.MsidbUpgradeAttributesIgnoreRemoveFailure : 0;
                attributes |= upgradeSymbol.VersionMinInclusive ? WindowsInstallerConstants.MsidbUpgradeAttributesVersionMinInclusive : 0;
                attributes |= upgradeSymbol.VersionMaxInclusive ? WindowsInstallerConstants.MsidbUpgradeAttributesVersionMaxInclusive : 0;
                attributes |= upgradeSymbol.ExcludeLanguages ? WindowsInstallerConstants.MsidbUpgradeAttributesLanguagesExclusive : 0;

                fields = String.Join(",",
                                     upgradeSymbol.VersionMin,
                                     upgradeSymbol.VersionMax,
                                     upgradeSymbol.Language,
                                     attributes.ToString(),
                                     upgradeSymbol.Remove,
                                     upgradeSymbol.ActionProperty
                                     );
                break;
            }

            case "WixAction":
            {
                var wixActionSymbol    = (WixActionSymbol)symbol;
                var data               = wixActionSymbol.Fields[(int)WixActionSymbolFields.SequenceTable].AsObject();
                var sequenceTableAsInt = data is string?(int)SequenceStringToSequenceTable(data) : (int)wixActionSymbol.SequenceTable;

                fields = String.Join(",",
                                     sequenceTableAsInt,
                                     wixActionSymbol.Action,
                                     wixActionSymbol.Condition,
                                     wixActionSymbol.Sequence?.ToString() ?? String.Empty,
                                     wixActionSymbol.Before,
                                     wixActionSymbol.After,
                                     wixActionSymbol.Overridable == true ? "1" : "0"
                                     );
                break;
            }

            case "WixComplexReference":
            {
                var wixComplexReferenceSymbol = (WixComplexReferenceSymbol)symbol;
                fields = String.Join(",",
                                     wixComplexReferenceSymbol.Parent,
                                     (int)wixComplexReferenceSymbol.ParentType,
                                     wixComplexReferenceSymbol.ParentLanguage,
                                     wixComplexReferenceSymbol.Child,
                                     (int)wixComplexReferenceSymbol.ChildType,
                                     wixComplexReferenceSymbol.IsPrimary ? "1" : "0"
                                     );
                break;
            }

            case "WixProperty":
            {
                var wixPropertySymbol = (WixPropertySymbol)symbol;
                var attributes        = wixPropertySymbol.Admin ? 0x1 : 0;
                attributes |= wixPropertySymbol.Hidden ? 0x2 : 0;
                attributes |= wixPropertySymbol.Secure ? 0x4 : 0;

                fields = String.Join(",",
                                     wixPropertySymbol.PropertyRef,
                                     attributes.ToString()
                                     );
                break;
            }

            default:
                fields = String.Join(",", symbol.Fields.Select(SafeConvertField));
                break;
            }

            fields = String.IsNullOrEmpty(id) ? fields : String.IsNullOrEmpty(fields) ? id : $"{id},{fields}";
            yield return($"{name}:{fields}");
        }
 public static string AsString(this IntermediateSymbol symbol, int index) => symbol?.Fields[index].AsString();
Ejemplo n.º 19
0
        private void ResolvePathField(FileResolver fileResolver, IntermediateSymbol symbol, IntermediateField field)
        {
            var fieldValue        = field.AsPath();
            var originalFieldPath = fieldValue.Path;

#if TODO_PATCHING
            // Skip file resolution if the file is to be deleted.
            if (RowOperation.Delete == symbol.Operation)
            {
                continue;
            }
#endif

            // If the file is embedded and if the previous value has a bind variable in the path
            // which gets modified by resolving the previous value again then switch to that newly
            // resolved path instead of using the embedded file.
            if (fieldValue.Embed && field.PreviousValue != null)
            {
                var resolution = this.VariableResolver.ResolveVariables(symbol.SourceLineNumbers, field.PreviousValue.AsString(), errorOnUnknown: false);

                if (resolution.UpdatedValue && !resolution.IsDefault)
                {
                    fieldValue = new IntermediateFieldPathValue {
                        Path = resolution.Value
                    };
                }
            }

            // If we're still using the embedded file.
            if (fieldValue.Embed)
            {
                // Set the path to the embedded file once where it will be extracted.
                var extractPath = this.FilesWithEmbeddedFiles.AddEmbeddedFileToExtract(fieldValue.BaseUri, fieldValue.Path, this.IntermediateFolder);

                field.Set(extractPath);
            }
            else if (fieldValue.Path != null)
            {
                try
                {
                    var resolvedPath = fieldValue.Path;

                    if (!this.BuildingPatch) // Normal binding for non-Patch scenario such as link (light.exe)
                    {
#if TODO_PATCHING
                        // keep a copy of the un-resolved data for future replay. This will be saved into wixpdb file
                        if (null == objectField.UnresolvedData)
                        {
                            objectField.UnresolvedData = (string)objectField.Data;
                        }
#endif
                        resolvedPath = fileResolver.ResolveFile(fieldValue.Path, symbol.Definition, symbol.SourceLineNumbers, BindStage.Normal);
                    }
                    else if (!fileResolver.RebaseTarget && !fileResolver.RebaseUpdated) // Normal binding for Patch Scenario (normal patch, no re-basing logic)
                    {
                        resolvedPath = fileResolver.ResolveFile(fieldValue.Path, symbol.Definition, symbol.SourceLineNumbers, BindStage.Normal);
                    }
#if TODO_PATCHING
                    else // Re-base binding path scenario caused by pyro.exe -bt -bu
                    {
                        // by default, use the resolved Data for file lookup
                        string filePathToResolve = (string)objectField.Data;

                        // if -bu is used in pyro command, this condition holds true and the tool
                        // will use pre-resolved source for new wixpdb file
                        if (fileResolver.RebaseUpdated)
                        {
                            // try to use the unResolved Source if it exists.
                            // New version of wixpdb file keeps a copy of pre-resolved Source. i.e. !(bindpath.test)\foo.dll
                            // Old version of winpdb file does not contain this attribute and the value is null.
                            if (null != objectField.UnresolvedData)
                            {
                                filePathToResolve = objectField.UnresolvedData;
                            }
                        }

                        objectField.Data = fileResolver.ResolveFile(filePathToResolve, symbol.Definition.Name, symbol.SourceLineNumbers, BindStage.Updated);
                    }
#endif

                    if (!String.Equals(originalFieldPath, resolvedPath, StringComparison.OrdinalIgnoreCase))
                    {
                        field.Set(resolvedPath);
                    }
                }
                catch (WixException e)
                {
                    this.Messaging.Write(e.Error);
                }
            }
        }
 /// <summary>
 /// Creates a symbol for a symbol.
 /// </summary>
 /// <param name="section"></param>
 /// <param name="symbol">Symbol for the symbol</param>
 public SymbolWithSection(IntermediateSection section, IntermediateSymbol symbol)
 {
     this.Symbol  = symbol;
     this.Section = section;
     this.Name    = String.Concat(this.Symbol.Definition.Name, ":", this.Symbol.Id.Id);
 }
Ejemplo n.º 21
0
        public void Execute()
        {
            var wixGroupPackagesGroupedById = this.Section.Symbols.OfType <WixGroupSymbol>().Where(g => g.ParentType == ComplexReferenceParentType.Package).ToLookup(g => g.ParentId);
            var exePackages        = this.Section.Symbols.OfType <WixBundleExePackageSymbol>().ToDictionary(t => t.Id.Id);
            var msiPackages        = this.Section.Symbols.OfType <WixBundleMsiPackageSymbol>().ToDictionary(t => t.Id.Id);
            var mspPackages        = this.Section.Symbols.OfType <WixBundleMspPackageSymbol>().ToDictionary(t => t.Id.Id);
            var msuPackages        = this.Section.Symbols.OfType <WixBundleMsuPackageSymbol>().ToDictionary(t => t.Id.Id);
            var exePackagePayloads = this.Section.Symbols.OfType <WixBundleExePackagePayloadSymbol>().ToDictionary(t => t.Id.Id);
            var msiPackagePayloads = this.Section.Symbols.OfType <WixBundleMsiPackagePayloadSymbol>().ToDictionary(t => t.Id.Id);
            var mspPackagePayloads = this.Section.Symbols.OfType <WixBundleMspPackagePayloadSymbol>().ToDictionary(t => t.Id.Id);
            var msuPackagePayloads = this.Section.Symbols.OfType <WixBundleMsuPackagePayloadSymbol>().ToDictionary(t => t.Id.Id);

            var facades = new Dictionary <string, PackageFacade>();

            foreach (var package in this.ChainPackageSymbols)
            {
                var id = package.Id.Id;

                IntermediateSymbol packagePayload = null;
                foreach (var wixGroup in wixGroupPackagesGroupedById[id])
                {
                    if (wixGroup.ChildType == ComplexReferenceChildType.PackagePayload)
                    {
                        IntermediateSymbol tempPackagePayload = null;
                        if (exePackagePayloads.TryGetValue(wixGroup.ChildId, out var exePackagePayload))
                        {
                            if (package.Type == WixBundlePackageType.Exe)
                            {
                                tempPackagePayload = exePackagePayload;
                            }
                            else
                            {
                                this.Messaging.Write(ErrorMessages.PackagePayloadUnsupported(exePackagePayload.SourceLineNumbers, "Exe"));
                                this.Messaging.Write(ErrorMessages.PackagePayloadUnsupported2(package.SourceLineNumbers));
                            }
                        }
                        else if (msiPackagePayloads.TryGetValue(wixGroup.ChildId, out var msiPackagePayload))
                        {
                            if (package.Type == WixBundlePackageType.Msi)
                            {
                                tempPackagePayload = msiPackagePayload;
                            }
                            else
                            {
                                this.Messaging.Write(ErrorMessages.PackagePayloadUnsupported(msiPackagePayload.SourceLineNumbers, "Msi"));
                                this.Messaging.Write(ErrorMessages.PackagePayloadUnsupported2(package.SourceLineNumbers));
                            }
                        }
                        else if (mspPackagePayloads.TryGetValue(wixGroup.ChildId, out var mspPackagePayload))
                        {
                            if (package.Type == WixBundlePackageType.Msp)
                            {
                                tempPackagePayload = mspPackagePayload;
                            }
                            else
                            {
                                this.Messaging.Write(ErrorMessages.PackagePayloadUnsupported(mspPackagePayload.SourceLineNumbers, "Msp"));
                                this.Messaging.Write(ErrorMessages.PackagePayloadUnsupported2(package.SourceLineNumbers));
                            }
                        }
                        else if (msuPackagePayloads.TryGetValue(wixGroup.ChildId, out var msuPackagePayload))
                        {
                            if (package.Type == WixBundlePackageType.Msu)
                            {
                                tempPackagePayload = msuPackagePayload;
                            }
                            else
                            {
                                this.Messaging.Write(ErrorMessages.PackagePayloadUnsupported(msuPackagePayload.SourceLineNumbers, "Msu"));
                                this.Messaging.Write(ErrorMessages.PackagePayloadUnsupported2(package.SourceLineNumbers));
                            }
                        }
                        else
                        {
                            this.Messaging.Write(ErrorMessages.IdentifierNotFound(package.Type + "PackagePayload", wixGroup.ChildId));
                        }

                        if (tempPackagePayload != null)
                        {
                            if (packagePayload == null)
                            {
                                packagePayload = tempPackagePayload;
                            }
                            else
                            {
                                this.Messaging.Write(ErrorMessages.MultiplePackagePayloads(tempPackagePayload.SourceLineNumbers, id, packagePayload.Id.Id, tempPackagePayload.Id.Id));
                                this.Messaging.Write(ErrorMessages.MultiplePackagePayloads2(packagePayload.SourceLineNumbers));
                                this.Messaging.Write(ErrorMessages.MultiplePackagePayloads3(package.SourceLineNumbers));
                            }
                        }
                    }
                }

                if (packagePayload == null)
                {
                    this.Messaging.Write(ErrorMessages.MissingPackagePayload(package.SourceLineNumbers, id, package.Type.ToString()));
                }
                else
                {
                    package.PayloadRef = packagePayload.Id.Id;
                }

                switch (package.Type)
                {
                case WixBundlePackageType.Exe:
                    if (exePackages.TryGetValue(id, out var exePackage))
                    {
                        facades.Add(id, new PackageFacade(package, exePackage));
                    }
                    else
                    {
                        this.Messaging.Write(ErrorMessages.IdentifierNotFound("WixBundleExePackage", id));
                    }
                    break;

                case WixBundlePackageType.Msi:
                    if (msiPackages.TryGetValue(id, out var msiPackage))
                    {
                        facades.Add(id, new PackageFacade(package, msiPackage));
                    }
                    else
                    {
                        this.Messaging.Write(ErrorMessages.IdentifierNotFound("WixBundleMsiPackage", id));
                    }
                    break;

                case WixBundlePackageType.Msp:
                    if (mspPackages.TryGetValue(id, out var mspPackage))
                    {
                        facades.Add(id, new PackageFacade(package, mspPackage));
                    }
                    else
                    {
                        this.Messaging.Write(ErrorMessages.IdentifierNotFound("WixBundleMspPackage", id));
                    }
                    break;

                case WixBundlePackageType.Msu:
                    if (msuPackages.TryGetValue(id, out var msuPackage))
                    {
                        facades.Add(id, new PackageFacade(package, msuPackage));
                    }
                    else
                    {
                        this.Messaging.Write(ErrorMessages.IdentifierNotFound("WixBundleMsuPackage", id));
                    }
                    break;
                }
            }

            this.PackageFacades = facades;
        }
Ejemplo n.º 22
0
 /// <summary>
 /// Creates a delayed field.
 /// </summary>
 /// <param name="symbol">Symbol for the field.</param>
 /// <param name="field">Field needing further resolution.</param>
 public DelayedField(IntermediateSymbol symbol, IntermediateField field)
 {
     this.Symbol = symbol;
     this.Field  = field;
 }
Ejemplo n.º 23
0
 public void AddBootstrapperApplicationData(IntermediateSymbol symbol, bool symbolIdIsIdAttribute = false)
 {
     this.BootstrapperApplicationManifestData.AddSymbol(symbol, symbolIdIsIdAttribute, BurnCommon.BADataNamespace);
 }
        private static bool NoFieldMetadata(IntermediateSymbol symbol, int index)
        {
            var field = symbol?.Fields[index];

            return(field?.Context == null && field?.PreviousValue == null);
        }
Ejemplo n.º 25
0
        public bool TryAddSymbolToOutputMatchingTableDefinitions(IntermediateSection section, IntermediateSymbol symbol, WindowsInstallerData output, TableDefinitionCollection tableDefinitions)
        {
            var tableDefinition = tableDefinitions.FirstOrDefault(t => t.SymbolDefinition?.Name == symbol.Definition.Name);
            if (tableDefinition == null)
            {
                return false;
            }

            var row = this.CreateRow(section, symbol, output, tableDefinition);
            var rowOffset = 0;

            if (tableDefinition.SymbolIdIsPrimaryKey)
            {
                row[0] = symbol.Id.Id;
                rowOffset = 1;
            }

            for (var i = 0; i < symbol.Fields.Length; ++i)
            {
                if (i < tableDefinition.Columns.Length)
                {
                    var column = tableDefinition.Columns[i + rowOffset];

                    switch (column.Type)
                    {
                    case ColumnType.Number:
                        row[i + rowOffset] = column.Nullable ? symbol.AsNullableNumber(i) : symbol.AsNumber(i);
                        break;

                    default:
                        row[i + rowOffset] = symbol.AsString(i);
                        break;
                    }
                }
            }

            return true;
        }
 public static int?AsNullableNumber(this IntermediateSymbol symbol, int index) => symbol?.Fields[index].AsNullableNumber();
Ejemplo n.º 27
0
        public void AddBundleExtensionData(string extensionId, IntermediateSymbol symbol, bool symbolIdIsIdAttribute = false)
        {
            var manifestData = this.GetBundleExtensionManifestData(extensionId);

            manifestData.AddSymbol(symbol, symbolIdIsIdAttribute, BurnCommon.BundleExtensionDataNamespace);
        }
 public LegacySearchFacade(WixSearchSymbol searchSymbol, IntermediateSymbol searchSpecificSymbol)
 {
     this.SearchSymbol         = searchSymbol;
     this.SearchSpecificSymbol = searchSpecificSymbol;
 }