diff options
author | Bob Arnson <bob@firegiant.com> | 2024-09-27 18:12:11 -0400 |
---|---|---|
committer | Rob Mensching <rob@firegiant.com> | 2024-10-04 13:31:17 -0700 |
commit | 72085cbf1e359428457f82f84c2e19ed37b10aec (patch) | |
tree | 988171b1c062a0736d527f4ed0e7ab9ae477aea2 | |
parent | ae879a638643fd34bd1917160f94268930e15b7d (diff) | |
download | wix-72085cbf1e359428457f82f84c2e19ed37b10aec.tar.gz wix-72085cbf1e359428457f82f84c2e19ed37b10aec.tar.bz2 wix-72085cbf1e359428457f82f84c2e19ed37b10aec.zip |
Fix crash when adding file in patch when filtering
10 files changed, 91 insertions, 10 deletions
diff --git a/src/wix/WixToolset.Core.WindowsInstaller/Bind/PatchFilterMap.cs b/src/wix/WixToolset.Core.WindowsInstaller/Bind/PatchFilterMap.cs index 4822f3a5..fe4dfde4 100644 --- a/src/wix/WixToolset.Core.WindowsInstaller/Bind/PatchFilterMap.cs +++ b/src/wix/WixToolset.Core.WindowsInstaller/Bind/PatchFilterMap.cs | |||
@@ -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 | 2 | ||
3 | namespace WixToolset.Core.WindowsInstaller.Bind | 3 | namespace WixToolset.Core.WindowsInstaller.Bind |
4 | { | 4 | { |
@@ -53,6 +53,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
53 | 53 | ||
54 | targetFilterId = patchFilter?.TargetFilterId; | 54 | targetFilterId = patchFilter?.TargetFilterId; |
55 | updatedFilterId = patchFilter?.UpdatedFilterId; | 55 | updatedFilterId = patchFilter?.UpdatedFilterId; |
56 | |||
56 | return patchFilter != null; | 57 | return patchFilter != null; |
57 | } | 58 | } |
58 | 59 | ||
diff --git a/src/wix/WixToolset.Core.WindowsInstaller/Bind/ReduceTransformCommand.cs b/src/wix/WixToolset.Core.WindowsInstaller/Bind/ReduceTransformCommand.cs index e7d93660..f1013480 100644 --- a/src/wix/WixToolset.Core.WindowsInstaller/Bind/ReduceTransformCommand.cs +++ b/src/wix/WixToolset.Core.WindowsInstaller/Bind/ReduceTransformCommand.cs | |||
@@ -101,11 +101,10 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
101 | continue; | 101 | continue; |
102 | } | 102 | } |
103 | 103 | ||
104 | // Differ.sectionDelimiter | ||
105 | if (this.PatchFilterMap.TryGetPatchFiltersForRow(row, out var targetFilterId, out var updatedFilterId)) | 104 | if (this.PatchFilterMap.TryGetPatchFiltersForRow(row, out var targetFilterId, out var updatedFilterId)) |
106 | { | 105 | { |
107 | targetFilterIdsToKeep[targetFilterId] = row; | 106 | targetFilterIdsToKeep[targetFilterId ?? String.Empty] = row; |
108 | updatedFilterIdsToKeep[updatedFilterId] = row; | 107 | updatedFilterIdsToKeep[updatedFilterId ?? String.Empty] = row; |
109 | } | 108 | } |
110 | } | 109 | } |
111 | 110 | ||
@@ -251,7 +250,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
251 | } | 250 | } |
252 | } | 251 | } |
253 | 252 | ||
254 | keptRows += ReduceTransformSequenceTable(sequenceList, targetFilterIdsToKeep, updatedFilterIdsToKeep, customActionTable); | 253 | keptRows += this.ReduceTransformSequenceTable(sequenceList, targetFilterIdsToKeep, updatedFilterIdsToKeep, customActionTable); |
255 | 254 | ||
256 | if (null != directoryTable) | 255 | if (null != directoryTable) |
257 | { | 256 | { |
@@ -333,7 +332,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
333 | } | 332 | } |
334 | } | 333 | } |
335 | 334 | ||
336 | keptRows += ReduceTransformSequenceTable(sequenceList, targetFilterIdsToKeep, updatedFilterIdsToKeep, customActionTable); | 335 | keptRows += this.ReduceTransformSequenceTable(sequenceList, targetFilterIdsToKeep, updatedFilterIdsToKeep, customActionTable); |
337 | 336 | ||
338 | // Delete tables that are empty. | 337 | // Delete tables that are empty. |
339 | var tablesToDelete = transform.Tables.Where(t => t.Rows.Count == 0).Select(t => t.Name).ToList(); | 338 | var tablesToDelete = transform.Tables.Where(t => t.Rows.Count == 0).Select(t => t.Name).ToList(); |
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/PatchFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/PatchFixture.cs index 82dfc7e5..8cbacc39 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/PatchFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/PatchFixture.cs | |||
@@ -44,9 +44,9 @@ namespace WixToolsetTest.CoreIntegration | |||
44 | var tempFolderUpdate = Path.Combine(this.tempBaseFolder, "PatchTemplatePackage", "update"); | 44 | var tempFolderUpdate = Path.Combine(this.tempBaseFolder, "PatchTemplatePackage", "update"); |
45 | var tempFolderUpdateNoFileChanges = Path.Combine(this.tempBaseFolder, "PatchTemplatePackage", "updatewithoutfilechanges"); | 45 | var tempFolderUpdateNoFileChanges = Path.Combine(this.tempBaseFolder, "PatchTemplatePackage", "updatewithoutfilechanges"); |
46 | 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") }); | 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", new[] { Path.Combine(this.templateSourceFolder, ".update-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", new[] { Path.Combine(this.templateSourceFolder, ".baseline-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 | } | 50 | } |
51 | 51 | ||
52 | public void Dispose() | 52 | public void Dispose() |
@@ -82,6 +82,33 @@ namespace WixToolsetTest.CoreIntegration | |||
82 | } | 82 | } |
83 | 83 | ||
84 | [Fact] | 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] | ||
85 | public void CanBuildSimplePatchWithFileChangesUsingMsi() | 112 | public void CanBuildSimplePatchWithFileChangesUsingMsi() |
86 | { | 113 | { |
87 | var sourceFolder = TestData.Get(@"TestData", "PatchWithFileChangesUsingMsi"); | 114 | var sourceFolder = TestData.Get(@"TestData", "PatchWithFileChangesUsingMsi"); |
@@ -452,7 +479,7 @@ namespace WixToolsetTest.CoreIntegration | |||
452 | } | 479 | } |
453 | } | 480 | } |
454 | 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) |
456 | { | 483 | { |
457 | var outputPath = Path.Combine(baseFolder, Path.Combine("bin", outputName)); | 484 | var outputPath = Path.Combine(baseFolder, Path.Combine("bin", outputName)); |
458 | 485 | ||
@@ -463,6 +490,7 @@ namespace WixToolsetTest.CoreIntegration | |||
463 | "-d", "V=" + defineV, | 490 | "-d", "V=" + defineV, |
464 | "-d", "A=" + defineA, | 491 | "-d", "A=" + defineA, |
465 | "-d", "B=" + defineB, | 492 | "-d", "B=" + defineB, |
493 | "-d", "C=" + defineC ?? String.Empty, | ||
466 | "-bindpath", Path.Combine(sourceFolder, ".data"), | 494 | "-bindpath", Path.Combine(sourceFolder, ".data"), |
467 | "-intermediateFolder", Path.Combine(baseFolder, "obj"), | 495 | "-intermediateFolder", Path.Combine(baseFolder, "obj"), |
468 | "-o", outputPath, | 496 | "-o", outputPath, |
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithAddedFile/.data/Av1.0.0.txt b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithAddedFile/.data/Av1.0.0.txt new file mode 100644 index 00000000..6fd385bd --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithAddedFile/.data/Av1.0.0.txt | |||
@@ -0,0 +1 @@ | |||
This is A v1.0.0 | |||
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithAddedFile/.data/Av1.0.1.txt b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithAddedFile/.data/Av1.0.1.txt new file mode 100644 index 00000000..b1f0bc01 --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithAddedFile/.data/Av1.0.1.txt | |||
@@ -0,0 +1 @@ | |||
This ia A v1.0.1 | |||
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithAddedFile/.data/Bv1.0.0.txt b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithAddedFile/.data/Bv1.0.0.txt new file mode 100644 index 00000000..ece55fec --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithAddedFile/.data/Bv1.0.0.txt | |||
@@ -0,0 +1 @@ | |||
This is B v1.0.0 | |||
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithAddedFile/.data/Bv1.0.1.txt b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithAddedFile/.data/Bv1.0.1.txt new file mode 100644 index 00000000..cf3372fd --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithAddedFile/.data/Bv1.0.1.txt | |||
@@ -0,0 +1 @@ | |||
This ia B v1.0.1 | |||
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithAddedFile/.data/C.txt b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithAddedFile/.data/C.txt new file mode 100644 index 00000000..da7bfac1 --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithAddedFile/.data/C.txt | |||
@@ -0,0 +1 @@ | |||
This is C, unversioned. | |||
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithAddedFile/Package.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithAddedFile/Package.wxs new file mode 100644 index 00000000..2a970193 --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithAddedFile/Package.wxs | |||
@@ -0,0 +1,30 @@ | |||
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 | <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." /> | ||
5 | |||
6 | <StandardDirectory Id="ProgramFilesFolder"> | ||
7 | <Directory Id="INSTALLFOLDER" Name="~Test Package" /> | ||
8 | </StandardDirectory> | ||
9 | |||
10 | <Feature Id="ProductFeature"> | ||
11 | <ComponentGroupRef Id="Components" /> | ||
12 | </Feature> | ||
13 | |||
14 | <ComponentGroup Id="Components" Directory="INSTALLFOLDER"> | ||
15 | <Component Id="CA"> | ||
16 | <File Id="a.txt" Name="a.txt" Source="Av$(var.A).txt" /> | ||
17 | </Component> | ||
18 | |||
19 | <Component Id="CB"> | ||
20 | <File Id="b.txt" Name="b.txt" Source="Bv$(var.B).txt" /> | ||
21 | </Component> | ||
22 | |||
23 | <?if $(C) == "TRUE" ?> | ||
24 | <Component Id="CC"> | ||
25 | <File Id="c.txt" Name="c.txt" Source="C.txt" /> | ||
26 | </Component> | ||
27 | <?endif?> | ||
28 | </ComponentGroup> | ||
29 | </Package> | ||
30 | </Wix> | ||
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithAddedFile/Patch.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithAddedFile/Patch.wxs new file mode 100644 index 00000000..679f0c10 --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithAddedFile/Patch.wxs | |||
@@ -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> | ||