@joebigelow / wix-1 / commits / 29d555a7

Fix crash when adding file in patch when filtering

Bob Arnson committed Sep 27, 2024 at 18:12 UTC 29d555a7c1f8ca660177035265624644a5c6d374
10 files changed +82 -10
src/wix/WixToolset.Core.WindowsInstaller/Bind/PatchFilterMap.cs
+2 -1
@@ -1,4 +1,4 @@
1 -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
1 +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3 namespace WixToolset.Core.WindowsInstaller.Bind
4 {
@@ -53,6 +53,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
53
54 targetFilterId = patchFilter?.TargetFilterId;
55 updatedFilterId = patchFilter?.UpdatedFilterId;
56 +
57 return patchFilter != null;
58 }
59
src/wix/WixToolset.Core.WindowsInstaller/Bind/ReduceTransformCommand.cs
+4 -5
@@ -101,11 +101,10 @@ namespace WixToolset.Core.WindowsInstaller.Bind
101 continue;
102 }
103
104 - // Differ.sectionDelimiter
104 if (this.PatchFilterMap.TryGetPatchFiltersForRow(row, out var targetFilterId, out var updatedFilterId))
105 {
107 - targetFilterIdsToKeep[targetFilterId] = row;
108 - updatedFilterIdsToKeep[updatedFilterId] = row;
106 + targetFilterIdsToKeep[targetFilterId ?? String.Empty] = row;
107 + updatedFilterIdsToKeep[updatedFilterId ?? String.Empty] = row;
108 }
109 }
110
@@ -251,7 +250,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
250 }
251 }
252
254 - keptRows += ReduceTransformSequenceTable(sequenceList, targetFilterIdsToKeep, updatedFilterIdsToKeep, customActionTable);
253 + keptRows += this.ReduceTransformSequenceTable(sequenceList, targetFilterIdsToKeep, updatedFilterIdsToKeep, customActionTable);
254
255 if (null != directoryTable)
256 {
@@ -333,7 +332,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
332 }
333 }
334
336 - keptRows += ReduceTransformSequenceTable(sequenceList, targetFilterIdsToKeep, updatedFilterIdsToKeep, customActionTable);
335 + keptRows += this.ReduceTransformSequenceTable(sequenceList, targetFilterIdsToKeep, updatedFilterIdsToKeep, customActionTable);
336
337 // Delete tables that are empty.
338 var tablesToDelete = transform.Tables.Where(t => t.Rows.Count == 0).Select(t => t.Name).ToList();
src/wix/test/WixToolsetTest.CoreIntegration/PatchFixture.cs
+32 -4
@@ -44,9 +44,9 @@ namespace WixToolsetTest.CoreIntegration
44 var tempFolderUpdate = Path.Combine(this.tempBaseFolder, "PatchTemplatePackage", "update");
45 var tempFolderUpdateNoFileChanges = Path.Combine(this.tempBaseFolder, "PatchTemplatePackage", "updatewithoutfilechanges");
46
47 - this.templateBaselinePdb = BuildMsi("Baseline.msi", this.templateSourceFolder, tempFolderBaseline, "1.0.0", "1.0.0", "1.0.0", new[] { Path.Combine(this.templateSourceFolder, ".baseline-data") });
48 - this.templateUpdatePdb = BuildMsi("Update.msi", this.templateSourceFolder, tempFolderUpdate, "1.0.1", "1.0.1", "1.0.1", new[] { Path.Combine(this.templateSourceFolder, ".update-data") });
49 - this.templateUpdateNoFilesChangedPdb = BuildMsi("Update.msi", this.templateSourceFolder, tempFolderUpdateNoFileChanges, "1.0.1", "1.0.1", "1.0.1", new[] { Path.Combine(this.templateSourceFolder, ".baseline-data") });
47 + this.templateBaselinePdb = BuildMsi("Baseline.msi", this.templateSourceFolder, tempFolderBaseline, "1.0.0", "1.0.0", "1.0.0", bindpaths: new[] { Path.Combine(this.templateSourceFolder, ".baseline-data") });
48 + this.templateUpdatePdb = BuildMsi("Update.msi", this.templateSourceFolder, tempFolderUpdate, "1.0.1", "1.0.1", "1.0.1", bindpaths: new[] { Path.Combine(this.templateSourceFolder, ".update-data") });
49 + this.templateUpdateNoFilesChangedPdb = BuildMsi("Update.msi", this.templateSourceFolder, tempFolderUpdateNoFileChanges, "1.0.1", "1.0.1", "1.0.1", bindpaths: new[] { Path.Combine(this.templateSourceFolder, ".baseline-data") });
50 }
51
52 public void Dispose()
@@ -81,6 +81,33 @@ namespace WixToolsetTest.CoreIntegration
81 }
82 }
83
84 + [Fact]
85 + public void CanBuildSimplePatchWithNewFileAndFilteringUsingWixpdbs()
86 + {
87 + var folder = TestData.Get(@"TestData", "PatchWithAddedFile");
88 +
89 + using (var fs = new DisposableFileSystem())
90 + {
91 + var tempFolder = fs.GetFolder();
92 +
93 + var baselinePath = BuildMsi("Baseline.msi", folder, tempFolder, "1.0.0", "1.0.0", "1.0.0");
94 + var update1Path = BuildMsi("Update.msi", folder, tempFolder, "1.0.1", "1.0.1", "1.0.1", "TRUE");
95 + var patchPath = BuildMsp("Patch1.msp", folder, tempFolder, "1.0.1", warningsAsErrors: false);
96 +
97 + var doc = GetExtractPatchXml(patchPath);
98 + WixAssert.StringEqual("{7D326855-E790-4A94-8611-5351F8321FCA}", doc.Root.Element(TargetProductCodeName).Value);
99 +
100 + var names = Query.GetSubStorageNames(patchPath);
101 + WixAssert.CompareLineByLine(new[] { "#RTM.1", "RTM.1" }, names);
102 +
103 + var cab = Path.Combine(tempFolder, "foo.cab");
104 + Query.ExtractStream(patchPath, "foo.cab", cab);
105 +
106 + var files = Query.GetCabinetFiles(cab);
107 + WixAssert.CompareLineByLine(new[] { "c.txt" }, files.Select(f => f.Name).ToArray());
108 + }
109 + }
110 +
111 [Fact]
112 public void CanBuildSimplePatchWithFileChangesUsingMsi()
113 {
@@ -452,7 +479,7 @@ namespace WixToolsetTest.CoreIntegration
479 }
480 }
481
455 - private static string BuildMsi(string outputName, string sourceFolder, string baseFolder, string defineV, string defineA, string defineB, IEnumerable<string> bindpaths = null)
482 + private static string BuildMsi(string outputName, string sourceFolder, string baseFolder, string defineV, string defineA, string defineB, string defineC = null, IEnumerable<string> bindpaths = null)
483 {
484 var outputPath = Path.Combine(baseFolder, Path.Combine("bin", outputName));
485
@@ -463,6 +490,7 @@ namespace WixToolsetTest.CoreIntegration
490 "-d", "V=" + defineV,
491 "-d", "A=" + defineA,
492 "-d", "B=" + defineB,
493 + "-d", "C=" + defineC ?? String.Empty,
494 "-bindpath", Path.Combine(sourceFolder, ".data"),
495 "-intermediateFolder", Path.Combine(baseFolder, "obj"),
496 "-o", outputPath,
src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithAddedFile/.data/Av1.0.0.txt new
+1
@@ -0,0 +1 @@
1 +This is A v1.0.0
src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithAddedFile/.data/Av1.0.1.txt new
+1
@@ -0,0 +1 @@
1 +This ia A v1.0.1
src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithAddedFile/.data/Bv1.0.0.txt new
+1
@@ -0,0 +1 @@
1 +This is B v1.0.0
src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithAddedFile/.data/Bv1.0.1.txt new
+1
@@ -0,0 +1 @@
1 +This ia B v1.0.1
src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithAddedFile/.data/C.txt new
+1
@@ -0,0 +1 @@
1 +This is C, unversioned.
src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithAddedFile/Package.wxs new
+21
@@ -0,0 +1,21 @@
1 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
2 + <Package Name="~Test Package" Version="$(var.V)" Manufacturer="Example Corporation" Language="1033" UpgradeCode="7d326855-e790-4a94-8611-5351f8321fca" Compressed="yes" Scope="perMachine" ProductCode="7d326855-e790-4a94-8611-5351f8321fca">
3 + <MediaTemplate EmbedCab="yes" />
4 +
5 + <ComponentGroup Id="Components" Directory="INSTALLFOLDER">
6 + <Component Id="CA">
7 + <File Id="a.txt" Name="a.txt" Source="Av$(var.A).txt" />
8 + </Component>
9 +
10 + <Component Id="CB">
11 + <File Id="b.txt" Name="b.txt" Source="Bv$(var.B).txt" />
12 + </Component>
13 +
14 + <?if $(C) == "TRUE" ?>
15 + <Component Id="CC">
16 + <File Id="c.txt" Name="c.txt" Source="C.txt" />
17 + </Component>
18 + <?endif?>
19 + </ComponentGroup>
20 + </Package>
21 +</Wix>
src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithAddedFile/Patch.wxs new
+18
@@ -0,0 +1,18 @@
1 +<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>
2 + <Patch
3 + AllowRemoval="yes"
4 + DisplayName="~Test Patch v$(var.V)"
5 + Description="~Test Small Update Patch v$(var.V)"
6 + MoreInfoURL="http://www.example.com/"
7 + Manufacturer="Example Corporation"
8 + Classification="Update">
9 +
10 + <Media Id="1" Cabinet="foo.cab">
11 + <PatchBaseline Id="RTM" BaselineFile="Baseline.wixpdb" UpdateFile="Update.wixpdb" />
12 + </Media>
13 +
14 + <PatchFamily Id='SequenceFamily' Version='$(var.V)'>
15 + <ComponentRef Id="CC" />
16 + </PatchFamily>
17 + </Patch>
18 +</Wix>