From 8b5505cd13367d48bce4ec8a6018e370ed3755b1 Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Fri, 23 Oct 2020 17:32:44 -0400 Subject: Reorganize Product/Package to Package/SummaryInformation. --- .../Bind/BindSummaryInfoCommand.cs | 23 +++-- .../Decompile/Decompiler.cs | 99 ++++++++++++---------- .../Decompile/Names.cs | 7 +- 3 files changed, 72 insertions(+), 57 deletions(-) (limited to 'src/WixToolset.Core.WindowsInstaller') diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/BindSummaryInfoCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/BindSummaryInfoCommand.cs index 6af2dc7a..a496c7ce 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/BindSummaryInfoCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/BindSummaryInfoCommand.cs @@ -46,9 +46,10 @@ namespace WixToolset.Core.WindowsInstaller.Bind this.InstallerVersion = 0; this.ModularizationSuffix = null; - var foundCreateDataTime = false; + var foundCreateDateTime = false; var foundLastSaveDataTime = false; var foundCreatingApplication = false; + var foundPackageCode = false; var now = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss", CultureInfo.InvariantCulture); foreach (var summaryInformationSymbol in this.Section.Symbols.OfType()) @@ -73,20 +74,16 @@ namespace WixToolset.Core.WindowsInstaller.Bind break; case SummaryInformationType.PackageCode: // PID_REVNUMBER + foundPackageCode = true; var packageCode = summaryInformationSymbol.Value; if (SectionType.Module == this.Section.Type) { this.ModularizationSuffix = "." + packageCode.Substring(1, 36).Replace('-', '_'); } - else if ("*" == packageCode) - { - // set the revision number (package/patch code) if it should be automatically generated - summaryInformationSymbol.Value = Common.GenerateGuid(); - } break; case SummaryInformationType.Created: - foundCreateDataTime = true; + foundCreateDateTime = true; break; case SummaryInformationType.LastSaved: foundLastSaveDataTime = true; @@ -113,8 +110,18 @@ namespace WixToolset.Core.WindowsInstaller.Bind } } + // set the revision number (package/patch code) if it should be automatically generated + if (!foundPackageCode) + { + this.Section.AddSymbol(new SummaryInformationSymbol(null) + { + PropertyId = SummaryInformationType.PackageCode, + Value = Common.GenerateGuid(), + }); + } + // add a summary information row for the create time/date property if its not already set - if (!foundCreateDataTime) + if (!foundCreateDateTime) { this.Section.AddSymbol(new SummaryInformationSymbol(null) { diff --git a/src/WixToolset.Core.WindowsInstaller/Decompile/Decompiler.cs b/src/WixToolset.Core.WindowsInstaller/Decompile/Decompiler.cs index a0146fda..80ee75a5 100644 --- a/src/WixToolset.Core.WindowsInstaller/Decompile/Decompiler.cs +++ b/src/WixToolset.Core.WindowsInstaller/Decompile/Decompiler.cs @@ -160,7 +160,7 @@ namespace WixToolset.Core.WindowsInstaller this.RootElement = new XElement(Names.PatchCreationElement); break; case OutputType.Product: - this.RootElement = new XElement(Names.ProductElement); + this.RootElement = new XElement(Names.PackageElement); break; default: throw new InvalidOperationException("Unknown output type."); @@ -669,6 +669,7 @@ namespace WixToolset.Core.WindowsInstaller } else { + this.FinalizeSummaryInformationStream(tables); this.FinalizeCheckBoxTable(tables); this.FinalizeComponentTable(tables); this.FinalizeDialogTable(tables); @@ -2548,7 +2549,7 @@ namespace WixToolset.Core.WindowsInstaller switch (table.Name) { case "_SummaryInformation": - this.Decompile_SummaryInformationTable(table); + // handled in FinalizeDecompile break; case "AdminExecuteSequence": case "AdminUISequence": @@ -2976,11 +2977,13 @@ namespace WixToolset.Core.WindowsInstaller /// Decompile the _SummaryInformation table. /// /// The table to decompile. - private void Decompile_SummaryInformationTable(Table table) + private void FinalizeSummaryInformationStream(TableIndexedCollection tables) { + var table = tables["_SummaryInformation"]; + if (OutputType.Module == this.OutputType || OutputType.Product == this.OutputType) { - var xPackage = new XElement(Names.PackageElement); + var xSummaryInformation = new XElement(Names.SummaryInformationElement); foreach (var row in table.Rows) { @@ -2993,56 +2996,63 @@ namespace WixToolset.Core.WindowsInstaller case 1: if ("1252" != value) { - xPackage.SetAttributeValue("SummaryCodepage", value); + xSummaryInformation.SetAttributeValue("Codepage", value); } break; case 3: - xPackage.SetAttributeValue("Description", value); + { + var productName = this.RootElement.Attribute("Name")?.Value; + if (value != productName) + { + xSummaryInformation.SetAttributeValue("Description", value); + } break; + } case 4: - xPackage.SetAttributeValue("Manufacturer", value); - break; - case 5: - if ("Installer" != value) + { + var productManufacturer = this.RootElement.Attribute("Manufacturer")?.Value; + if (value != productManufacturer) { - xPackage.SetAttributeValue("Keywords", value); + xSummaryInformation.SetAttributeValue("Manufacturer", value); } break; - case 6: - if (!value.StartsWith("This installer database contains the logic and data required to install ")) + } + case 5: + if ("Installer" != value) { - xPackage.SetAttributeValue("Comments", value); + xSummaryInformation.SetAttributeValue("Keywords", value); } break; case 7: var template = value.Split(';'); if (0 < template.Length && 0 < template[template.Length - 1].Length) { - xPackage.SetAttributeValue("Languages", template[template.Length - 1]); - } - - var platform = GetPlatformFromTemplateSummaryInformation(template).ToString().ToLowerInvariant(); - if (!String.IsNullOrEmpty(platform)) - { - xPackage.SetAttributeValue("Platform", platform); + this.RootElement.SetAttributeValue("Language", template[template.Length - 1]); } break; case 9: if (OutputType.Module == this.OutputType) { this.ModularizationGuid = value; - xPackage.SetAttributeValue("Id", value); } break; case 14: - xPackage.SetAttributeValue("InstallerVersion", row.FieldAsInteger(1)); + var installerVersion = row.FieldAsInteger(1); + // Default InstallerVersion. + if (installerVersion != 500) + { + this.RootElement.SetAttributeValue("InstallerVersion", installerVersion); + } break; case 15: var wordCount = row.FieldAsInteger(1); if (0x1 == (wordCount & 0x1)) { this.ShortNames = true; - xPackage.SetAttributeValue("ShortNames", "yes"); + if (OutputType.Product == this.OutputType) + { + this.RootElement.SetAttributeValue("ShortNames", "yes"); + } } if (0x2 == (wordCount & 0x2)) @@ -3051,38 +3061,35 @@ namespace WixToolset.Core.WindowsInstaller if (OutputType.Product == this.OutputType) { - xPackage.SetAttributeValue("Compressed", "yes"); + this.RootElement.SetAttributeValue("Compressed", "yes"); } } - if (0x4 == (wordCount & 0x4)) + if (OutputType.Product == this.OutputType) { - xPackage.SetAttributeValue("AdminImage", "yes"); - } - - if (0x8 == (wordCount & 0x8)) - { - xPackage.SetAttributeValue("InstallPrivileges", "limited"); + if (0x8 == (wordCount & 0x8)) + { + this.RootElement.SetAttributeValue("Scope", "perUser"); + } + else + { + var xAllUsers = this.RootElement.Elements(Names.PropertyElement).SingleOrDefault(p => p.Attribute("Id")?.Value == "ALLUSERS"); + if (xAllUsers?.Attribute("Value")?.Value == "1") + { + xAllUsers?.Remove(); + } + } } - break; - case 19: - var security = row.FieldAsInteger(1); - switch (security) - { - case 0: - xPackage.SetAttributeValue("ReadOnly", "no"); - break; - case 4: - xPackage.SetAttributeValue("ReadOnly", "yes"); - break; - } break; } } } - this.RootElement.Add(xPackage); + if (xSummaryInformation.HasAttributes) + { + this.RootElement.Add(xSummaryInformation); + } } else { @@ -6204,7 +6211,7 @@ namespace WixToolset.Core.WindowsInstaller this.RootElement.SetAttributeValue("Manufacturer", value); continue; case "ProductCode": - this.RootElement.SetAttributeValue("Id", value.ToUpper(CultureInfo.InvariantCulture)); + this.RootElement.SetAttributeValue("ProductCode", value.ToUpper(CultureInfo.InvariantCulture)); continue; case "ProductLanguage": this.RootElement.SetAttributeValue("Language", value); diff --git a/src/WixToolset.Core.WindowsInstaller/Decompile/Names.cs b/src/WixToolset.Core.WindowsInstaller/Decompile/Names.cs index 63ab5cd3..82258c57 100644 --- a/src/WixToolset.Core.WindowsInstaller/Decompile/Names.cs +++ b/src/WixToolset.Core.WindowsInstaller/Decompile/Names.cs @@ -8,10 +8,12 @@ namespace WixToolset.Core.WindowsInstaller.Decompile public static readonly XName WixElement = WxsNamespace + "Wix"; - public static readonly XName ProductElement = WxsNamespace + "Product"; + public static readonly XName PackageElement = WxsNamespace + "Package"; public static readonly XName ModuleElement = WxsNamespace + "Module"; public static readonly XName PatchCreationElement = WxsNamespace + "PatchCreation"; + public static readonly XName SummaryInformationElement = WxsNamespace + "SummaryInformation"; + public static readonly XName CustomElement = WxsNamespace + "Custom"; public static readonly XName AdminExecuteSequenceElement = WxsNamespace + "AdminExecuteSequence"; @@ -30,9 +32,8 @@ namespace WixToolset.Core.WindowsInstaller.Decompile public static readonly XName FileElement = WxsNamespace + "File"; public static readonly XName EnsureTableElement = WxsNamespace + "EnsureTable"; - public static readonly XName PackageElement = WxsNamespace + "Package"; public static readonly XName PatchInformationElement = WxsNamespace + "PatchInformation"; - + public static readonly XName ProgressTextElement = WxsNamespace + "ProgressText"; public static readonly XName UIElement = WxsNamespace + "UI"; -- cgit v1.2.3-55-g6feb