@joebigelow / wix / commits / 9a6688a8

Add patch test from old repo and get it passing.

Fixes #6341.

Sean Hall committed Jan 27, 2021 at 20:06 UTC 9a6688a8d6ec05817451dc8706a0bc9db82b9d36
9 files changed +188 -3
src/WixToolset.Core.WindowsInstaller/Bind/CalculateComponentGuids.cs
+1 -1
@@ -67,7 +67,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
67 if (registryKeyRows.TryGetValue(componentSymbol.KeyPath, out var foundRow))
68 {
69 var bitness = componentSymbol.Win64 ? "64" : String.Empty;
70 - var regkey = String.Concat(bitness, foundRow.AsString(1), "\\", foundRow.AsString(2), "\\", foundRow.AsString(3));
70 + var regkey = String.Concat(bitness, foundRow.Root, "\\", foundRow.Key, "\\", foundRow.Name);
71 componentSymbol.ComponentId = this.BackendHelper.CreateGuid(BindDatabaseCommand.WixComponentGuidNamespace, regkey.ToLowerInvariant());
72 }
73 }
src/test/WixToolsetTest.CoreIntegration/PatchFixture.cs
+77 -2
@@ -2,14 +2,18 @@
2
3 namespace WixToolsetTest.CoreIntegration
4 {
5 + using System.Collections.Generic;
6 using System.ComponentModel;
7 using System.IO;
8 using System.Linq;
9 using System.Runtime.InteropServices;
10 using System.Text;
11 + using System.Xml;
12 using System.Xml.Linq;
13 using WixBuildTools.TestSupport;
14 using WixToolset.Core.TestPackage;
15 + using WixToolset.Data;
16 + using WixToolset.Data.Burn;
17 using Xunit;
18
19 public class PatchFixture
@@ -28,7 +32,6 @@ namespace WixToolsetTest.CoreIntegration
32 var baselinePdb = BuildMsi("Baseline.msi", folder, tempFolder, "1.0.0", "1.0.0", "1.0.0");
33 var update1Pdb = BuildMsi("Update.msi", folder, tempFolder, "1.0.1", "1.0.1", "1.0.1");
34 var patchPdb = BuildMsp("Patch1.msp", folder, tempFolder, "1.0.1");
31 - var baselinePath = Path.ChangeExtension(baselinePdb, ".msp");
35 var patchPath = Path.ChangeExtension(patchPdb, ".msp");
36
37 Assert.True(File.Exists(baselinePdb));
@@ -49,6 +52,57 @@ namespace WixToolsetTest.CoreIntegration
52 }
53 }
54
55 + [Fact]
56 + public void CanBuildBundleWithNonSpecificPatches()
57 + {
58 + var folder = TestData.Get(@"TestData\PatchNonSpecific");
59 +
60 + using (var fs = new DisposableFileSystem())
61 + {
62 + var tempFolder = fs.GetFolder();
63 +
64 + var baselinePdb = BuildMsi("Baseline.msi", Path.Combine(folder, "PackageA"), tempFolder, "1.0.0", "A", "B");
65 + var updatePdb = BuildMsi("Update.msi", Path.Combine(folder, "PackageA"), tempFolder, "1.0.1", "A", "B");
66 + var patchAPdb = BuildMsp("PatchA.msp", Path.Combine(folder, "PatchA"), tempFolder, "1.0.1", true);
67 + var patchBPdb = BuildMsp("PatchB.msp", Path.Combine(folder, "PatchB"), tempFolder, "1.0.1", true);
68 + var patchCPdb = BuildMsp("PatchC.msp", Path.Combine(folder, "PatchC"), tempFolder, "1.0.1", true);
69 + var bundleAPdb = BuildBundle("BundleA.exe", Path.Combine(folder, "BundleA"), tempFolder);
70 + var bundleBPdb = BuildBundle("BundleB.exe", Path.Combine(folder, "BundleB"), tempFolder);
71 + var bundleCPdb = BuildBundle("BundleC.exe", Path.Combine(folder, "BundleC"), tempFolder);
72 +
73 + VerifyPatchTargetCodes(bundleAPdb, new[]
74 + {
75 + "<PatchTargetCode TargetCode='{26309973-0A5E-4979-B142-98A6E064EDC0}' Product='yes' />",
76 + });
77 + VerifyPatchTargetCodes(bundleBPdb, new[]
78 + {
79 + "<PatchTargetCode TargetCode='{26309973-0A5E-4979-B142-98A6E064EDC0}' Product='yes' />",
80 + "<PatchTargetCode TargetCode='{32B0396A-CE36-4570-B16E-F88FA42DC409}' Product='no' />",
81 + });
82 + VerifyPatchTargetCodes(bundleCPdb, new string[0]);
83 + }
84 + }
85 +
86 + private static void VerifyPatchTargetCodes(string pdbPath, string[] expected)
87 + {
88 + using (var wixOutput = WixOutput.Read(pdbPath))
89 + {
90 + var manifestData = wixOutput.GetData(BurnConstants.BurnManifestWixOutputStreamName);
91 + var doc = new XmlDocument();
92 + doc.LoadXml(manifestData);
93 + var nsmgr = BundleExtractor.GetBurnNamespaceManager(doc, "w");
94 + var patchTargetCodes = doc.SelectNodes("/w:BurnManifest/w:PatchTargetCode", nsmgr);
95 +
96 + var actual = new List<string>();
97 + foreach (XmlNode patchTargetCodeNode in patchTargetCodes)
98 + {
99 + actual.Add(patchTargetCodeNode.GetTestXml());
100 + }
101 +
102 + WixAssert.CompareLineByLine(expected, actual.ToArray());
103 + }
104 + }
105 +
106 private static string BuildMsi(string outputName, string sourceFolder, string baseFolder, string defineV, string defineA, string defineB)
107 {
108 var outputPath = Path.Combine(baseFolder, Path.Combine("bin", outputName));
@@ -70,13 +124,14 @@ namespace WixToolsetTest.CoreIntegration
124 return Path.ChangeExtension(outputPath, ".wixpdb");
125 }
126
73 - private static string BuildMsp(string outputName, string sourceFolder, string baseFolder, string defineV)
127 + private static string BuildMsp(string outputName, string sourceFolder, string baseFolder, string defineV, bool hasNoFiles = false)
128 {
129 var outputPath = Path.Combine(baseFolder, Path.Combine("bin", outputName));
130
131 var result = WixRunner.Execute(new[]
132 {
133 "build",
134 + hasNoFiles ? "-sw1079" : " ",
135 Path.Combine(sourceFolder, @"Patch.wxs"),
136 "-d", "V=" + defineV,
137 "-bindpath", Path.Combine(baseFolder, "bin"),
@@ -89,6 +144,26 @@ namespace WixToolsetTest.CoreIntegration
144 return Path.ChangeExtension(outputPath, ".wixpdb");
145 }
146
147 + private static string BuildBundle(string outputName, string sourceFolder, string baseFolder)
148 + {
149 + var outputPath = Path.Combine(baseFolder, Path.Combine("bin", outputName));
150 +
151 + var result = WixRunner.Execute(new[]
152 + {
153 + "build",
154 + Path.Combine(sourceFolder, @"Bundle.wxs"),
155 + Path.Combine(sourceFolder, "..", "..", "BundleWithPackageGroupRef", "Bundle.wxs"),
156 + "-bindpath", Path.Combine(sourceFolder, "..", "..", "SimpleBundle", "data"),
157 + "-bindpath", Path.Combine(baseFolder, "bin"),
158 + "-intermediateFolder", Path.Combine(baseFolder, "obj"),
159 + "-o", outputPath
160 + });
161 +
162 + result.AssertSuccess();
163 +
164 + return Path.ChangeExtension(outputPath, ".wixpdb");
165 + }
166 +
167 private static XDocument GetExtractPatchXml(string path)
168 {
169 var buffer = new StringBuilder(65535);
src/test/WixToolsetTest.CoreIntegration/TestData/PatchNonSpecific/BundleA/Bundle.wxs new
+7
@@ -0,0 +1,7 @@
1 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
2 + <Fragment>
3 + <PackageGroup Id="BundlePackages">
4 + <MspPackage Id="PatchA" SourceFile="PatchA.msp" PerMachine="yes" />
5 + </PackageGroup>
6 + </Fragment>
7 +</Wix>
src/test/WixToolsetTest.CoreIntegration/TestData/PatchNonSpecific/BundleB/Bundle.wxs new
+8
@@ -0,0 +1,8 @@
1 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
2 + <Fragment>
3 + <PackageGroup Id="BundlePackages">
4 + <MspPackage Id="PatchA" SourceFile="PatchA.msp" PerMachine="yes" />
5 + <MspPackage Id="PatchB" SourceFile="PatchB.msp" PerMachine="yes" />
6 + </PackageGroup>
7 + </Fragment>
8 +</Wix>
src/test/WixToolsetTest.CoreIntegration/TestData/PatchNonSpecific/BundleC/Bundle.wxs new
+9
@@ -0,0 +1,9 @@
1 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
2 + <Fragment>
3 + <PackageGroup Id="BundlePackages">
4 + <MspPackage Id="PatchA" SourceFile="PatchA.msp" PerMachine="yes" />
5 + <MspPackage Id="PatchB" SourceFile="PatchB.msp" PerMachine="yes" />
6 + <MspPackage Id="PatchC" SourceFile="PatchC.msp" PerMachine="yes" />
7 + </PackageGroup>
8 + </Fragment>
9 +</Wix>
src/test/WixToolsetTest.CoreIntegration/TestData/PatchNonSpecific/PackageA/Package.wxs new
+46
@@ -0,0 +1,46 @@
1 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
2 + <Package ProductCode="26309973-0A5E-4979-B142-98A6E064EDC0" Name="PackageA" Language="1033" Version="$(var.V)" Manufacturer="Example Corporation"
3 + UpgradeCode="32B0396A-CE36-4570-B16E-F88FA42DC409" Scope="perMachine" Compressed="yes">
4 +
5 + <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
6 + <MediaTemplate EmbedCab="yes" />
7 +
8 + <PropertyRef Id="TestVersion"/>
9 +
10 + <Feature Id="Complete" Level="1">
11 + <ComponentRef Id="FileComponent"/>
12 + <ComponentRef Id="RegistryComponent"/>
13 + <ComponentRef Id="RegistryComponent2" />
14 + </Feature>
15 + </Package>
16 +
17 + <Fragment>
18 + <Directory Id="TARGETDIR" Name="SourceDir">
19 + <Directory Id="ProgramFilesFolder">
20 + <Directory Id="INSTALLFOLDER" Name="~Test A" />
21 + </Directory>
22 + </Directory>
23 + </Fragment>
24 +
25 + <Fragment>
26 + <Component Id="FileComponent" Directory="INSTALLFOLDER">
27 + <File Source="$(sys.SOURCEFILEPATH)"/>
28 + </Component>
29 + </Fragment>
30 +
31 + <Fragment>
32 + <Component Id="RegistryComponent" Directory="INSTALLFOLDER">
33 + <RegistryValue Root="HKLM" Key="Software\WiX\Tests\$(var.A)" Name="A" Value="!(bind.Property.TestVersion)" Type="string" />
34 + </Component>
35 + </Fragment>
36 +
37 + <Fragment>
38 + <Component Id="RegistryComponent2" Directory="INSTALLFOLDER">
39 + <RegistryValue Root="HKLM" Key="Software\WiX\Tests\$(var.B)" Name="A2" Value="!(bind.Property.TestVersion)" Type="string" />
40 + </Component>
41 + </Fragment>
42 +
43 + <Fragment>
44 + <Property Id="TestVersion" Value="$(var.V)"/>
45 + </Fragment>
46 +</Wix>
src/test/WixToolsetTest.CoreIntegration/TestData/PatchNonSpecific/PatchA/Patch.wxs new
+12
@@ -0,0 +1,12 @@
1 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
2 + <Patch AllowRemoval="yes" Classification="Update" ClientPatchId="PatchA" Description="Patch A" DisplayName="Patch A" Manufacturer="Example Corporation" MinorUpdateTargetRTM="yes">
3 + <Media Id="100" Cabinet="A" EmbedCab="yes">
4 + <PatchBaseline Id="PatchA" BaselineFile="Baseline.wixpdb" UpdateFile="Update.wixpdb" />
5 + </Media>
6 +
7 + <PatchFamily Id="A" Version="$(var.V)" Supersede="yes">
8 + <ComponentRef Id="RegistryComponent" />
9 + <PropertyRef Id="TestVersion" />
10 + </PatchFamily>
11 + </Patch>
12 +</Wix>
src/test/WixToolsetTest.CoreIntegration/TestData/PatchNonSpecific/PatchB/Patch.wxs new
+14
@@ -0,0 +1,14 @@
1 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
2 + <Patch AllowRemoval="yes" Classification="Update" ClientPatchId="PatchB" Description="Patch B" DisplayName="Patch B" Manufacturer="Example Corporation" MinorUpdateTargetRTM="yes">
3 + <Media Id="100" Cabinet="B" EmbedCab="yes">
4 + <PatchBaseline Id="PatchB" BaselineFile="Baseline.wixpdb" UpdateFile="Update.wixpdb">
5 + <Validate ProductId="no" />
6 + </PatchBaseline>
7 + </Media>
8 +
9 + <PatchFamily Id="B" Version="$(var.V)" Supersede="yes">
10 + <ComponentRef Id="RegistryComponent" />
11 + <PropertyRef Id="TestVersion" />
12 + </PatchFamily>
13 + </Patch>
14 +</Wix>
src/test/WixToolsetTest.CoreIntegration/TestData/PatchNonSpecific/PatchC/Patch.wxs new
+14
@@ -0,0 +1,14 @@
1 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
2 + <Patch AllowRemoval="yes" Classification="Update" ClientPatchId="PatchC" Description="Patch C" DisplayName="Patch C" Manufacturer="Example Corporation" MinorUpdateTargetRTM="yes">
3 + <Media Id="100" Cabinet="C" EmbedCab="yes">
4 + <PatchBaseline Id="PatchC" BaselineFile="Baseline.wixpdb" UpdateFile="Update.wixpdb">
5 + <Validate ProductId="no" UpgradeCode="no" />
6 + </PatchBaseline>
7 + </Media>
8 +
9 + <PatchFamily Id="C" Version="$(var.V)" Supersede="yes">
10 + <ComponentRef Id="RegistryComponent" />
11 + <PropertyRef Id="TestVersion" />
12 + </PatchFamily>
13 + </Patch>
14 +</Wix>