From 9a6688a8d6ec05817451dc8706a0bc9db82b9d36 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Wed, 27 Jan 2021 20:06:23 -0600 Subject: Add patch test from old repo and get it passing. Fixes #6341. --- .../Bind/CalculateComponentGuids.cs | 2 +- .../WixToolsetTest.CoreIntegration/PatchFixture.cs | 79 +++++++++++++++++++++- .../TestData/PatchNonSpecific/BundleA/Bundle.wxs | 7 ++ .../TestData/PatchNonSpecific/BundleB/Bundle.wxs | 8 +++ .../TestData/PatchNonSpecific/BundleC/Bundle.wxs | 9 +++ .../TestData/PatchNonSpecific/PackageA/Package.wxs | 46 +++++++++++++ .../TestData/PatchNonSpecific/PatchA/Patch.wxs | 12 ++++ .../TestData/PatchNonSpecific/PatchB/Patch.wxs | 14 ++++ .../TestData/PatchNonSpecific/PatchC/Patch.wxs | 14 ++++ 9 files changed, 188 insertions(+), 3 deletions(-) create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/PatchNonSpecific/BundleA/Bundle.wxs create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/PatchNonSpecific/BundleB/Bundle.wxs create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/PatchNonSpecific/BundleC/Bundle.wxs create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/PatchNonSpecific/PackageA/Package.wxs create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/PatchNonSpecific/PatchA/Patch.wxs create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/PatchNonSpecific/PatchB/Patch.wxs create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/PatchNonSpecific/PatchC/Patch.wxs diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CalculateComponentGuids.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CalculateComponentGuids.cs index 02336cae..55cda9ea 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/CalculateComponentGuids.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/CalculateComponentGuids.cs @@ -67,7 +67,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind if (registryKeyRows.TryGetValue(componentSymbol.KeyPath, out var foundRow)) { var bitness = componentSymbol.Win64 ? "64" : String.Empty; - var regkey = String.Concat(bitness, foundRow.AsString(1), "\\", foundRow.AsString(2), "\\", foundRow.AsString(3)); + var regkey = String.Concat(bitness, foundRow.Root, "\\", foundRow.Key, "\\", foundRow.Name); componentSymbol.ComponentId = this.BackendHelper.CreateGuid(BindDatabaseCommand.WixComponentGuidNamespace, regkey.ToLowerInvariant()); } } diff --git a/src/test/WixToolsetTest.CoreIntegration/PatchFixture.cs b/src/test/WixToolsetTest.CoreIntegration/PatchFixture.cs index 3616bcab..f1d0ea58 100644 --- a/src/test/WixToolsetTest.CoreIntegration/PatchFixture.cs +++ b/src/test/WixToolsetTest.CoreIntegration/PatchFixture.cs @@ -2,14 +2,18 @@ namespace WixToolsetTest.CoreIntegration { + using System.Collections.Generic; using System.ComponentModel; using System.IO; using System.Linq; using System.Runtime.InteropServices; using System.Text; + using System.Xml; using System.Xml.Linq; using WixBuildTools.TestSupport; using WixToolset.Core.TestPackage; + using WixToolset.Data; + using WixToolset.Data.Burn; using Xunit; public class PatchFixture @@ -28,7 +32,6 @@ namespace WixToolsetTest.CoreIntegration var baselinePdb = BuildMsi("Baseline.msi", folder, tempFolder, "1.0.0", "1.0.0", "1.0.0"); var update1Pdb = BuildMsi("Update.msi", folder, tempFolder, "1.0.1", "1.0.1", "1.0.1"); var patchPdb = BuildMsp("Patch1.msp", folder, tempFolder, "1.0.1"); - var baselinePath = Path.ChangeExtension(baselinePdb, ".msp"); var patchPath = Path.ChangeExtension(patchPdb, ".msp"); Assert.True(File.Exists(baselinePdb)); @@ -49,6 +52,57 @@ namespace WixToolsetTest.CoreIntegration } } + [Fact] + public void CanBuildBundleWithNonSpecificPatches() + { + var folder = TestData.Get(@"TestData\PatchNonSpecific"); + + using (var fs = new DisposableFileSystem()) + { + var tempFolder = fs.GetFolder(); + + var baselinePdb = BuildMsi("Baseline.msi", Path.Combine(folder, "PackageA"), tempFolder, "1.0.0", "A", "B"); + var updatePdb = BuildMsi("Update.msi", Path.Combine(folder, "PackageA"), tempFolder, "1.0.1", "A", "B"); + var patchAPdb = BuildMsp("PatchA.msp", Path.Combine(folder, "PatchA"), tempFolder, "1.0.1", true); + var patchBPdb = BuildMsp("PatchB.msp", Path.Combine(folder, "PatchB"), tempFolder, "1.0.1", true); + var patchCPdb = BuildMsp("PatchC.msp", Path.Combine(folder, "PatchC"), tempFolder, "1.0.1", true); + var bundleAPdb = BuildBundle("BundleA.exe", Path.Combine(folder, "BundleA"), tempFolder); + var bundleBPdb = BuildBundle("BundleB.exe", Path.Combine(folder, "BundleB"), tempFolder); + var bundleCPdb = BuildBundle("BundleC.exe", Path.Combine(folder, "BundleC"), tempFolder); + + VerifyPatchTargetCodes(bundleAPdb, new[] + { + "", + }); + VerifyPatchTargetCodes(bundleBPdb, new[] + { + "", + "", + }); + VerifyPatchTargetCodes(bundleCPdb, new string[0]); + } + } + + private static void VerifyPatchTargetCodes(string pdbPath, string[] expected) + { + using (var wixOutput = WixOutput.Read(pdbPath)) + { + var manifestData = wixOutput.GetData(BurnConstants.BurnManifestWixOutputStreamName); + var doc = new XmlDocument(); + doc.LoadXml(manifestData); + var nsmgr = BundleExtractor.GetBurnNamespaceManager(doc, "w"); + var patchTargetCodes = doc.SelectNodes("/w:BurnManifest/w:PatchTargetCode", nsmgr); + + var actual = new List(); + foreach (XmlNode patchTargetCodeNode in patchTargetCodes) + { + actual.Add(patchTargetCodeNode.GetTestXml()); + } + + WixAssert.CompareLineByLine(expected, actual.ToArray()); + } + } + private static string BuildMsi(string outputName, string sourceFolder, string baseFolder, string defineV, string defineA, string defineB) { var outputPath = Path.Combine(baseFolder, Path.Combine("bin", outputName)); @@ -70,13 +124,14 @@ namespace WixToolsetTest.CoreIntegration return Path.ChangeExtension(outputPath, ".wixpdb"); } - private static string BuildMsp(string outputName, string sourceFolder, string baseFolder, string defineV) + private static string BuildMsp(string outputName, string sourceFolder, string baseFolder, string defineV, bool hasNoFiles = false) { var outputPath = Path.Combine(baseFolder, Path.Combine("bin", outputName)); var result = WixRunner.Execute(new[] { "build", + hasNoFiles ? "-sw1079" : " ", Path.Combine(sourceFolder, @"Patch.wxs"), "-d", "V=" + defineV, "-bindpath", Path.Combine(baseFolder, "bin"), @@ -89,6 +144,26 @@ namespace WixToolsetTest.CoreIntegration return Path.ChangeExtension(outputPath, ".wixpdb"); } + private static string BuildBundle(string outputName, string sourceFolder, string baseFolder) + { + var outputPath = Path.Combine(baseFolder, Path.Combine("bin", outputName)); + + var result = WixRunner.Execute(new[] + { + "build", + Path.Combine(sourceFolder, @"Bundle.wxs"), + Path.Combine(sourceFolder, "..", "..", "BundleWithPackageGroupRef", "Bundle.wxs"), + "-bindpath", Path.Combine(sourceFolder, "..", "..", "SimpleBundle", "data"), + "-bindpath", Path.Combine(baseFolder, "bin"), + "-intermediateFolder", Path.Combine(baseFolder, "obj"), + "-o", outputPath + }); + + result.AssertSuccess(); + + return Path.ChangeExtension(outputPath, ".wixpdb"); + } + private static XDocument GetExtractPatchXml(string path) { var buffer = new StringBuilder(65535); diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/PatchNonSpecific/BundleA/Bundle.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/PatchNonSpecific/BundleA/Bundle.wxs new file mode 100644 index 00000000..4a8f5630 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/PatchNonSpecific/BundleA/Bundle.wxs @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/PatchNonSpecific/BundleB/Bundle.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/PatchNonSpecific/BundleB/Bundle.wxs new file mode 100644 index 00000000..7fb3cb56 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/PatchNonSpecific/BundleB/Bundle.wxs @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/PatchNonSpecific/BundleC/Bundle.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/PatchNonSpecific/BundleC/Bundle.wxs new file mode 100644 index 00000000..201d177b --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/PatchNonSpecific/BundleC/Bundle.wxs @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/PatchNonSpecific/PackageA/Package.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/PatchNonSpecific/PackageA/Package.wxs new file mode 100644 index 00000000..2d5fbc6d --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/PatchNonSpecific/PackageA/Package.wxs @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/PatchNonSpecific/PatchA/Patch.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/PatchNonSpecific/PatchA/Patch.wxs new file mode 100644 index 00000000..1b01774c --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/PatchNonSpecific/PatchA/Patch.wxs @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/PatchNonSpecific/PatchB/Patch.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/PatchNonSpecific/PatchB/Patch.wxs new file mode 100644 index 00000000..f0630ead --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/PatchNonSpecific/PatchB/Patch.wxs @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/PatchNonSpecific/PatchC/Patch.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/PatchNonSpecific/PatchC/Patch.wxs new file mode 100644 index 00000000..f9d2a55a --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/PatchNonSpecific/PatchC/Patch.wxs @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + -- cgit v1.2.3-55-g6feb