diff options
| author | Sean Hall <r.sean.hall@gmail.com> | 2021-01-27 20:06:23 -0600 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2021-01-27 20:45:17 -0600 |
| commit | 9a6688a8d6ec05817451dc8706a0bc9db82b9d36 (patch) | |
| tree | c3b8347c32a4b6986ace5da37866e3c47d175662 /src | |
| parent | 8eed3c02afb5883bc4e3bb45ab1f9b6da5a65476 (diff) | |
| download | wix-9a6688a8d6ec05817451dc8706a0bc9db82b9d36.tar.gz wix-9a6688a8d6ec05817451dc8706a0bc9db82b9d36.tar.bz2 wix-9a6688a8d6ec05817451dc8706a0bc9db82b9d36.zip | |
Add patch test from old repo and get it passing.
Fixes #6341.
Diffstat (limited to 'src')
9 files changed, 188 insertions, 3 deletions
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 | |||
| 67 | if (registryKeyRows.TryGetValue(componentSymbol.KeyPath, out var foundRow)) | 67 | if (registryKeyRows.TryGetValue(componentSymbol.KeyPath, out var foundRow)) |
| 68 | { | 68 | { |
| 69 | var bitness = componentSymbol.Win64 ? "64" : String.Empty; | 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()); | 71 | componentSymbol.ComponentId = this.BackendHelper.CreateGuid(BindDatabaseCommand.WixComponentGuidNamespace, regkey.ToLowerInvariant()); |
| 72 | } | 72 | } |
| 73 | } | 73 | } |
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 @@ | |||
| 2 | 2 | ||
| 3 | namespace WixToolsetTest.CoreIntegration | 3 | namespace WixToolsetTest.CoreIntegration |
| 4 | { | 4 | { |
| 5 | using System.Collections.Generic; | ||
| 5 | using System.ComponentModel; | 6 | using System.ComponentModel; |
| 6 | using System.IO; | 7 | using System.IO; |
| 7 | using System.Linq; | 8 | using System.Linq; |
| 8 | using System.Runtime.InteropServices; | 9 | using System.Runtime.InteropServices; |
| 9 | using System.Text; | 10 | using System.Text; |
| 11 | using System.Xml; | ||
| 10 | using System.Xml.Linq; | 12 | using System.Xml.Linq; |
| 11 | using WixBuildTools.TestSupport; | 13 | using WixBuildTools.TestSupport; |
| 12 | using WixToolset.Core.TestPackage; | 14 | using WixToolset.Core.TestPackage; |
| 15 | using WixToolset.Data; | ||
| 16 | using WixToolset.Data.Burn; | ||
| 13 | using Xunit; | 17 | using Xunit; |
| 14 | 18 | ||
| 15 | public class PatchFixture | 19 | public class PatchFixture |
| @@ -28,7 +32,6 @@ namespace WixToolsetTest.CoreIntegration | |||
| 28 | var baselinePdb = BuildMsi("Baseline.msi", folder, tempFolder, "1.0.0", "1.0.0", "1.0.0"); | 32 | var baselinePdb = BuildMsi("Baseline.msi", folder, tempFolder, "1.0.0", "1.0.0", "1.0.0"); |
| 29 | var update1Pdb = BuildMsi("Update.msi", folder, tempFolder, "1.0.1", "1.0.1", "1.0.1"); | 33 | var update1Pdb = BuildMsi("Update.msi", folder, tempFolder, "1.0.1", "1.0.1", "1.0.1"); |
| 30 | var patchPdb = BuildMsp("Patch1.msp", folder, tempFolder, "1.0.1"); | 34 | var patchPdb = BuildMsp("Patch1.msp", folder, tempFolder, "1.0.1"); |
| 31 | var baselinePath = Path.ChangeExtension(baselinePdb, ".msp"); | ||
| 32 | var patchPath = Path.ChangeExtension(patchPdb, ".msp"); | 35 | var patchPath = Path.ChangeExtension(patchPdb, ".msp"); |
| 33 | 36 | ||
| 34 | Assert.True(File.Exists(baselinePdb)); | 37 | Assert.True(File.Exists(baselinePdb)); |
| @@ -49,6 +52,57 @@ namespace WixToolsetTest.CoreIntegration | |||
| 49 | } | 52 | } |
| 50 | } | 53 | } |
| 51 | 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 | |||
| 52 | private static string BuildMsi(string outputName, string sourceFolder, string baseFolder, string defineV, string defineA, string defineB) | 106 | private static string BuildMsi(string outputName, string sourceFolder, string baseFolder, string defineV, string defineA, string defineB) |
| 53 | { | 107 | { |
| 54 | var outputPath = Path.Combine(baseFolder, Path.Combine("bin", outputName)); | 108 | var outputPath = Path.Combine(baseFolder, Path.Combine("bin", outputName)); |
| @@ -70,13 +124,14 @@ namespace WixToolsetTest.CoreIntegration | |||
| 70 | return Path.ChangeExtension(outputPath, ".wixpdb"); | 124 | return Path.ChangeExtension(outputPath, ".wixpdb"); |
| 71 | } | 125 | } |
| 72 | 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) |
| 74 | { | 128 | { |
| 75 | var outputPath = Path.Combine(baseFolder, Path.Combine("bin", outputName)); | 129 | var outputPath = Path.Combine(baseFolder, Path.Combine("bin", outputName)); |
| 76 | 130 | ||
| 77 | var result = WixRunner.Execute(new[] | 131 | var result = WixRunner.Execute(new[] |
| 78 | { | 132 | { |
| 79 | "build", | 133 | "build", |
| 134 | hasNoFiles ? "-sw1079" : " ", | ||
| 80 | Path.Combine(sourceFolder, @"Patch.wxs"), | 135 | Path.Combine(sourceFolder, @"Patch.wxs"), |
| 81 | "-d", "V=" + defineV, | 136 | "-d", "V=" + defineV, |
| 82 | "-bindpath", Path.Combine(baseFolder, "bin"), | 137 | "-bindpath", Path.Combine(baseFolder, "bin"), |
| @@ -89,6 +144,26 @@ namespace WixToolsetTest.CoreIntegration | |||
| 89 | return Path.ChangeExtension(outputPath, ".wixpdb"); | 144 | return Path.ChangeExtension(outputPath, ".wixpdb"); |
| 90 | } | 145 | } |
| 91 | 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 | |||
| 92 | private static XDocument GetExtractPatchXml(string path) | 167 | private static XDocument GetExtractPatchXml(string path) |
| 93 | { | 168 | { |
| 94 | var buffer = new StringBuilder(65535); | 169 | 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 @@ | |||
| 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> | ||
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 @@ | |||
| 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> | ||
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 @@ | |||
| 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> | ||
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 @@ | |||
| 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> | ||
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 @@ | |||
| 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> | ||
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 @@ | |||
| 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> | ||
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 @@ | |||
| 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> | ||
