diff options
author | Bob Arnson <bob@firegiant.com> | 2023-05-17 18:14:59 -0400 |
---|---|---|
committer | Rob Mensching <rob@firegiant.com> | 2023-06-03 01:24:39 -0700 |
commit | ddc79979ced959d8e1b7bd326950a735b73343e5 (patch) | |
tree | 5ddae9872ef25394c0762c8ac8cb394286af35e1 | |
parent | 1da042fc5f6cef4ea3cce10bd8a151f3a3d115cd (diff) | |
download | wix-ddc79979ced959d8e1b7bd326950a735b73343e5.tar.gz wix-ddc79979ced959d8e1b7bd326950a735b73343e5.tar.bz2 wix-ddc79979ced959d8e1b7bd326950a735b73343e5.zip |
Fix duplicate keys from inline subdirectories.
Fixes https://github.com/wixtoolset/issues/issues/7459.
3 files changed, 36 insertions, 11 deletions
diff --git a/src/wix/WixToolset.Core.WindowsInstaller/Bind/CreateWindowsInstallerDataFromIRCommand.cs b/src/wix/WixToolset.Core.WindowsInstaller/Bind/CreateWindowsInstallerDataFromIRCommand.cs index 42493484..f160bff6 100644 --- a/src/wix/WixToolset.Core.WindowsInstaller/Bind/CreateWindowsInstallerDataFromIRCommand.cs +++ b/src/wix/WixToolset.Core.WindowsInstaller/Bind/CreateWindowsInstallerDataFromIRCommand.cs | |||
@@ -1319,6 +1319,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
1319 | { | 1319 | { |
1320 | var directory = symbol.Name.Trim(PathSeparatorChars); | 1320 | var directory = symbol.Name.Trim(PathSeparatorChars); |
1321 | var parentDir = symbol.ParentDirectoryRef ?? (symbol.Id.Id == "TARGETDIR" ? null : "TARGETDIR"); | 1321 | var parentDir = symbol.ParentDirectoryRef ?? (symbol.Id.Id == "TARGETDIR" ? null : "TARGETDIR"); |
1322 | var directoryRows = this.Data.TryGetTable("Directory", out var table) ? table.Rows.ToDictionary(row => row.FieldAsString(0)) : new Dictionary<string, Row>(); | ||
1322 | 1323 | ||
1323 | var start = 0; | 1324 | var start = 0; |
1324 | var end = directory.IndexOfAny(PathSeparatorChars); | 1325 | var end = directory.IndexOfAny(PathSeparatorChars); |
@@ -1335,10 +1336,15 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
1335 | var id = this.BackendHelper.GenerateIdentifier("d", symbol.ParentDirectoryRef, path); | 1336 | var id = this.BackendHelper.GenerateIdentifier("d", symbol.ParentDirectoryRef, path); |
1336 | var shortnameSubdirectory = this.BackendHelper.IsValidShortFilename(subdirectoryName, false) ? null : this.CreateShortName(subdirectoryName, false, "Directory", symbol.ParentDirectoryRef); | 1337 | var shortnameSubdirectory = this.BackendHelper.IsValidShortFilename(subdirectoryName, false) ? null : this.CreateShortName(subdirectoryName, false, "Directory", symbol.ParentDirectoryRef); |
1337 | 1338 | ||
1338 | var subdirectoryRow = this.CreateRow(symbol, "Directory"); | 1339 | if (!directoryRows.ContainsKey(id)) |
1339 | subdirectoryRow[0] = id; | 1340 | { |
1340 | subdirectoryRow[1] = parentDir; | 1341 | var subdirectoryRow = this.CreateRow(symbol, "Directory"); |
1341 | subdirectoryRow[2] = CreateMsiFilename(shortnameSubdirectory, subdirectoryName); | 1342 | subdirectoryRow[0] = id; |
1343 | subdirectoryRow[1] = parentDir; | ||
1344 | subdirectoryRow[2] = CreateMsiFilename(shortnameSubdirectory, subdirectoryName); | ||
1345 | |||
1346 | directoryRows.Add(id, subdirectoryRow); | ||
1347 | } | ||
1342 | 1348 | ||
1343 | parentDir = id; | 1349 | parentDir = id; |
1344 | } | 1350 | } |
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/DirectoryFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/DirectoryFixture.cs index 8e401c40..cacf72bd 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/DirectoryFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/DirectoryFixture.cs | |||
@@ -170,7 +170,8 @@ namespace WixToolsetTest.CoreIntegration | |||
170 | var dirSymbols = section.Symbols.OfType<WixToolset.Data.Symbols.DirectorySymbol>().ToList(); | 170 | var dirSymbols = section.Symbols.OfType<WixToolset.Data.Symbols.DirectorySymbol>().ToList(); |
171 | WixAssert.CompareLineByLine(new[] | 171 | WixAssert.CompareLineByLine(new[] |
172 | { | 172 | { |
173 | "dZsSsu81KcG46xXTwc4mTSZO5Zx4:INSTALLFOLDER:dupe", | 173 | @"d6axmdFGwwNJUBTBpSSKcI7uWXo8:INSTALLFOLDER:path\to\path1", |
174 | @"dQ9mCRk.rZXStHc.ILz66dIhE0FI:INSTALLFOLDER:path\to\path2", | ||
174 | "INSTALLFOLDER:ProgramFiles6432Folder:MsiPackage", | 175 | "INSTALLFOLDER:ProgramFiles6432Folder:MsiPackage", |
175 | "ProgramFiles6432Folder:ProgramFiles64Folder:.", | 176 | "ProgramFiles6432Folder:ProgramFiles64Folder:.", |
176 | "ProgramFiles64Folder:TARGETDIR:PFiles64", | 177 | "ProgramFiles64Folder:TARGETDIR:PFiles64", |
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/DuplicateDir/DuplicateDir.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/DuplicateDir/DuplicateDir.wxs index a58b68c8..6d7b6681 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/DuplicateDir/DuplicateDir.wxs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/DuplicateDir/DuplicateDir.wxs | |||
@@ -2,23 +2,41 @@ | |||
2 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | 2 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> |
3 | <Fragment> | 3 | <Fragment> |
4 | <ComponentGroup Id="ProductComponents"> | 4 | <ComponentGroup Id="ProductComponents"> |
5 | <ComponentGroupRef Id="GroupA" /> | 5 | <ComponentGroupRef Id="GroupA1" /> |
6 | <ComponentGroupRef Id="GroupB" /> | 6 | <ComponentGroupRef Id="GroupA2" /> |
7 | <ComponentGroupRef Id="GroupB1" /> | ||
8 | <ComponentGroupRef Id="GroupB2" /> | ||
7 | </ComponentGroup> | 9 | </ComponentGroup> |
8 | </Fragment> | 10 | </Fragment> |
9 | 11 | ||
10 | <Fragment> | 12 | <Fragment> |
11 | <ComponentGroup Id="GroupA" Directory="INSTALLFOLDER" Subdirectory="dupe"> | 13 | <ComponentGroup Id="GroupA1" Directory="INSTALLFOLDER" Subdirectory="path\to\path1"> |
12 | <Component> | 14 | <Component> |
13 | <File Name="a.txt" Source="test.txt" /> | 15 | <File Name="a1.txt" Source="test.txt" /> |
14 | </Component> | 16 | </Component> |
15 | </ComponentGroup> | 17 | </ComponentGroup> |
16 | </Fragment> | 18 | </Fragment> |
17 | 19 | ||
18 | <Fragment> | 20 | <Fragment> |
19 | <ComponentGroup Id="GroupB" Directory="INSTALLFOLDER" Subdirectory="dupe"> | 21 | <ComponentGroup Id="GroupB1" Directory="INSTALLFOLDER" Subdirectory="path\to\path1"> |
20 | <Component> | 22 | <Component> |
21 | <File Name="b.txt" Source="test.txt" /> | 23 | <File Name="b1.txt" Source="test.txt" /> |
24 | </Component> | ||
25 | </ComponentGroup> | ||
26 | </Fragment> | ||
27 | |||
28 | <Fragment> | ||
29 | <ComponentGroup Id="GroupA2" Directory="INSTALLFOLDER" Subdirectory="path\to\path2"> | ||
30 | <Component> | ||
31 | <File Name="a2.txt" Source="test.txt" /> | ||
32 | </Component> | ||
33 | </ComponentGroup> | ||
34 | </Fragment> | ||
35 | |||
36 | <Fragment> | ||
37 | <ComponentGroup Id="GroupB2" Directory="INSTALLFOLDER" Subdirectory="path\to\path2"> | ||
38 | <Component> | ||
39 | <File Name="b2.txt" Source="test.txt" /> | ||
22 | </Component> | 40 | </Component> |
23 | </ComponentGroup> | 41 | </ComponentGroup> |
24 | </Fragment> | 42 | </Fragment> |