diff options
| author | Bob Arnson <bob@firegiant.com> | 2024-03-14 13:51:07 -0400 |
|---|---|---|
| committer | Bob Arnson <github@bobs.org> | 2024-03-14 15:59:07 -0400 |
| commit | dabcb37846e8f6da9d43984863678e9a4cf57b3e (patch) | |
| tree | 48e28243dfcbc573b69cb27552a63bc2eb355947 /src | |
| parent | 976ac446dcb4aa1bfcbf38e188deb1c3741a2e46 (diff) | |
| download | wix-dabcb37846e8f6da9d43984863678e9a4cf57b3e.tar.gz wix-dabcb37846e8f6da9d43984863678e9a4cf57b3e.tar.bz2 wix-dabcb37846e8f6da9d43984863678e9a4cf57b3e.zip | |
Handle directories a bit better for `Files`.
Fixes https://github.com/wixtoolset/issues/issues/8040.
Diffstat (limited to 'src')
14 files changed, 43 insertions, 15 deletions
diff --git a/src/wix/WixToolset.Core/HarvestFilesCommand.cs b/src/wix/WixToolset.Core/HarvestFilesCommand.cs index c92de516..4f0c2e2a 100644 --- a/src/wix/WixToolset.Core/HarvestFilesCommand.cs +++ b/src/wix/WixToolset.Core/HarvestFilesCommand.cs | |||
| @@ -45,8 +45,6 @@ namespace WixToolset.Core | |||
| 45 | { | 45 | { |
| 46 | var unusedSectionCachedInlinedDirectoryIds = new Dictionary<string, string>(); | 46 | var unusedSectionCachedInlinedDirectoryIds = new Dictionary<string, string>(); |
| 47 | 47 | ||
| 48 | var directoryId = harvestFile.DirectoryRef; | ||
| 49 | |||
| 50 | var inclusions = harvestFile.Inclusions.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); | 48 | var inclusions = harvestFile.Inclusions.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); |
| 51 | var exclusions = harvestFile.Exclusions.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); | 49 | var exclusions = harvestFile.Exclusions.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); |
| 52 | 50 | ||
| @@ -75,6 +73,8 @@ namespace WixToolset.Core | |||
| 75 | 73 | ||
| 76 | foreach (var fileByRecursiveDir in resolvedFiles.GroupBy(resolvedFile => resolvedFile.RecursiveDir, resolvedFile => resolvedFile.Path)) | 74 | foreach (var fileByRecursiveDir in resolvedFiles.GroupBy(resolvedFile => resolvedFile.RecursiveDir, resolvedFile => resolvedFile.Path)) |
| 77 | { | 75 | { |
| 76 | var directoryId = harvestFile.DirectoryRef; | ||
| 77 | |||
| 78 | var recursiveDir = fileByRecursiveDir.Key; | 78 | var recursiveDir = fileByRecursiveDir.Key; |
| 79 | 79 | ||
| 80 | if (!String.IsNullOrEmpty(recursiveDir)) | 80 | if (!String.IsNullOrEmpty(recursiveDir)) |
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs index c9e7fb14..8bf03ebb 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs | |||
| @@ -14,7 +14,7 @@ namespace WixToolsetTest.CoreIntegration | |||
| 14 | [Fact] | 14 | [Fact] |
| 15 | public void MustIncludeSomeFiles() | 15 | public void MustIncludeSomeFiles() |
| 16 | { | 16 | { |
| 17 | var messages = BuildAndQueryComponentAndFileTables("BadAuthoring.wxs", isPackage: true, 10); | 17 | var messages = BuildAndQueryComponentFileDirectoryTables("BadAuthoring.wxs", isPackage: true, 10); |
| 18 | Assert.Equal(new[] | 18 | Assert.Equal(new[] |
| 19 | { | 19 | { |
| 20 | "10", | 20 | "10", |
| @@ -24,7 +24,7 @@ namespace WixToolsetTest.CoreIntegration | |||
| 24 | [Fact] | 24 | [Fact] |
| 25 | public void ZeroFilesHarvestedIsAWarning() | 25 | public void ZeroFilesHarvestedIsAWarning() |
| 26 | { | 26 | { |
| 27 | var messages = BuildAndQueryComponentAndFileTables("ZeroFiles.wxs", isPackage: true, 8600); | 27 | var messages = BuildAndQueryComponentFileDirectoryTables("ZeroFiles.wxs", isPackage: true, 8600); |
| 28 | Assert.Equal(new[] | 28 | Assert.Equal(new[] |
| 29 | { | 29 | { |
| 30 | "8600", | 30 | "8600", |
| @@ -34,7 +34,7 @@ namespace WixToolsetTest.CoreIntegration | |||
| 34 | [Fact] | 34 | [Fact] |
| 35 | public void MissingHarvestDirectoryIsAWarning() | 35 | public void MissingHarvestDirectoryIsAWarning() |
| 36 | { | 36 | { |
| 37 | var messages = BuildAndQueryComponentAndFileTables("BadDirectory.wxs", isPackage: true, 8601); | 37 | var messages = BuildAndQueryComponentFileDirectoryTables("BadDirectory.wxs", isPackage: true, 8601); |
| 38 | Assert.Equal(new[] | 38 | Assert.Equal(new[] |
| 39 | { | 39 | { |
| 40 | "8601", | 40 | "8601", |
| @@ -45,7 +45,7 @@ namespace WixToolsetTest.CoreIntegration | |||
| 45 | [Fact] | 45 | [Fact] |
| 46 | public void DuplicateFilesSomethingSomething() | 46 | public void DuplicateFilesSomethingSomething() |
| 47 | { | 47 | { |
| 48 | var messages = BuildAndQueryComponentAndFileTables("DuplicateFiles.wxs", isPackage: true, 8602); | 48 | var messages = BuildAndQueryComponentFileDirectoryTables("DuplicateFiles.wxs", isPackage: true, 8602); |
| 49 | Assert.Equal(new[] | 49 | Assert.Equal(new[] |
| 50 | { | 50 | { |
| 51 | "8602", | 51 | "8602", |
| @@ -58,7 +58,7 @@ namespace WixToolsetTest.CoreIntegration | |||
| 58 | [Fact] | 58 | [Fact] |
| 59 | public void CanHarvestFilesInComponentGroup() | 59 | public void CanHarvestFilesInComponentGroup() |
| 60 | { | 60 | { |
| 61 | BuildQueryAssertFiles("ComponentGroup.wxs", new[] | 61 | BuildQueryAssertFiles("ComponentGroup.wxs", new[] |
| 62 | { | 62 | { |
| 63 | "FileName.Extension", | 63 | "FileName.Extension", |
| 64 | "test20.txt", | 64 | "test20.txt", |
| @@ -71,7 +71,7 @@ namespace WixToolsetTest.CoreIntegration | |||
| 71 | [Fact] | 71 | [Fact] |
| 72 | public void CanHarvestFilesInDirectory() | 72 | public void CanHarvestFilesInDirectory() |
| 73 | { | 73 | { |
| 74 | BuildQueryAssertFiles("Directory.wxs", new[] | 74 | BuildQueryAssertFiles("Directory.wxs", new[] |
| 75 | { | 75 | { |
| 76 | "test10.txt", | 76 | "test10.txt", |
| 77 | "test120.txt", | 77 | "test120.txt", |
| @@ -101,7 +101,7 @@ namespace WixToolsetTest.CoreIntegration | |||
| 101 | [Fact] | 101 | [Fact] |
| 102 | public void CanHarvestFilesInFeature() | 102 | public void CanHarvestFilesInFeature() |
| 103 | { | 103 | { |
| 104 | var rows = BuildAndQueryComponentAndFileTables("Feature.wxs"); | 104 | var rows = BuildAndQueryComponentFileDirectoryTables("Feature.wxs"); |
| 105 | 105 | ||
| 106 | AssertFileComponentIds(3, rows); | 106 | AssertFileComponentIds(3, rows); |
| 107 | } | 107 | } |
| @@ -124,6 +124,22 @@ namespace WixToolsetTest.CoreIntegration | |||
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | [Fact] | 126 | [Fact] |
| 127 | public void CanHarvestFilesInStraightAndCrookedTrees() | ||
| 128 | { | ||
| 129 | var rows = BuildAndQueryComponentFileDirectoryTables("CrookedTree.wxs"); | ||
| 130 | var directoryRows = rows.Where(row => row.StartsWith("Directory:")).Select(d => d.Substring(10)).ToArray(); | ||
| 131 | |||
| 132 | var rootDirectoryId = directoryRows.Single(r => r.EndsWith("\troot")).Split('\t')[0]; | ||
| 133 | |||
| 134 | foreach (var ch in new[] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'z' }) | ||
| 135 | { | ||
| 136 | var directoryRow = directoryRows.Single(r => r.EndsWith($"\t{ch}")); | ||
| 137 | var parentDirectory = directoryRow.Split('\t')[1]; | ||
| 138 | Assert.Equal(rootDirectoryId, parentDirectory); | ||
| 139 | } | ||
| 140 | } | ||
| 141 | |||
| 142 | [Fact] | ||
| 127 | public void CanHarvestFilesInFeatureRef() | 143 | public void CanHarvestFilesInFeatureRef() |
| 128 | { | 144 | { |
| 129 | BuildQueryAssertFiles("FeatureRef.wxs", new[] | 145 | BuildQueryAssertFiles("FeatureRef.wxs", new[] |
| @@ -186,7 +202,7 @@ namespace WixToolsetTest.CoreIntegration | |||
| 186 | [Fact] | 202 | [Fact] |
| 187 | public void HarvestedFilesUnderPackageWithAuthoredFeatureAreOrphaned() | 203 | public void HarvestedFilesUnderPackageWithAuthoredFeatureAreOrphaned() |
| 188 | { | 204 | { |
| 189 | var messages = BuildAndQueryComponentAndFileTables("PackageWithoutDefaultFeature.wxs", isPackage: true, 267); | 205 | var messages = BuildAndQueryComponentFileDirectoryTables("PackageWithoutDefaultFeature.wxs", isPackage: true, 267); |
| 190 | Assert.Equal(new[] | 206 | Assert.Equal(new[] |
| 191 | { | 207 | { |
| 192 | "267", | 208 | "267", |
| @@ -232,14 +248,23 @@ namespace WixToolsetTest.CoreIntegration | |||
| 232 | 248 | ||
| 233 | private static void BuildQueryAssertFiles(string file, string[] expectedFileNames, bool isPackage = true, int? exitCode = null) | 249 | private static void BuildQueryAssertFiles(string file, string[] expectedFileNames, bool isPackage = true, int? exitCode = null) |
| 234 | { | 250 | { |
| 235 | var rows = BuildAndQueryComponentAndFileTables(file, isPackage, exitCode); | 251 | var rows = BuildAndQueryComponentFileDirectoryTables(file, isPackage, exitCode); |
| 252 | |||
| 253 | var fileNames = AssertFileComponentIds(expectedFileNames.Length, rows); | ||
| 254 | |||
| 255 | Assert.Equal(expectedFileNames, fileNames); | ||
| 256 | } | ||
| 257 | |||
| 258 | private static void BuildQueryDirectoryComponent(string file, string[] expectedFileNames, bool isPackage = true, int? exitCode = null) | ||
| 259 | { | ||
| 260 | var rows = BuildAndQueryComponentFileDirectoryTables(file, isPackage, exitCode); | ||
| 236 | 261 | ||
| 237 | var fileNames = AssertFileComponentIds(expectedFileNames.Length, rows); | 262 | var fileNames = AssertFileComponentIds(expectedFileNames.Length, rows); |
| 238 | 263 | ||
| 239 | Assert.Equal(expectedFileNames, fileNames); | 264 | Assert.Equal(expectedFileNames, fileNames); |
| 240 | } | 265 | } |
| 241 | 266 | ||
| 242 | private static string[] BuildAndQueryComponentAndFileTables(string file, bool isPackage = true, int? exitCode = null) | 267 | private static string[] BuildAndQueryComponentFileDirectoryTables(string file, bool isPackage = true, int? exitCode = null) |
| 243 | { | 268 | { |
| 244 | var folder = TestData.Get("TestData", "HarvestFiles"); | 269 | var folder = TestData.Get("TestData", "HarvestFiles"); |
| 245 | 270 | ||
| @@ -273,7 +298,7 @@ namespace WixToolsetTest.CoreIntegration | |||
| 273 | { | 298 | { |
| 274 | result.AssertSuccess(); | 299 | result.AssertSuccess(); |
| 275 | 300 | ||
| 276 | return Query.QueryDatabase(msiPath, new[] { "Component", "File" }) | 301 | return Query.QueryDatabase(msiPath, new[] { "Component", "File", "Directory" }) |
| 277 | .OrderBy(s => s) | 302 | .OrderBy(s => s) |
| 278 | .ToArray(); | 303 | .ToArray(); |
| 279 | } | 304 | } |
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/ComponentGroup.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/ComponentGroup.wxs index 963f40a5..7755ffb1 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/ComponentGroup.wxs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/ComponentGroup.wxs | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | 1 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> |
| 2 | <Package Name="MsiPackage" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a"> | 2 | <Package Name="MsiPackage" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a"> |
| 3 | <MajorUpgrade DowngradeErrorMessage="Downgrade error message." /> | ||
| 4 | |||
| 5 | <Feature Id="ProductFeature"> | 3 | <Feature Id="ProductFeature"> |
| 6 | <ComponentGroupRef Id="Files" /> | 4 | <ComponentGroupRef Id="Files" /> |
| 7 | </Feature> | 5 | </Feature> |
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/CrookedTree.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/CrookedTree.wxs new file mode 100644 index 00000000..4f46a81a --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/CrookedTree.wxs | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
| 2 | <Package Name="MsiPackage" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a"> | ||
| 3 | <Files Directory="ProgramFiles6432Folder" Subdirectory="root" Include="$(sys.SOURCEFILEDIR)\bigtree\**" /> | ||
| 4 | </Package> | ||
| 5 | </Wix> | ||
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/bigtree/a/file.ext b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/bigtree/a/file.ext new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/bigtree/a/file.ext | |||
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/bigtree/b/file.ext b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/bigtree/b/file.ext new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/bigtree/b/file.ext | |||
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/bigtree/c/file.ext b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/bigtree/c/file.ext new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/bigtree/c/file.ext | |||
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/bigtree/d/file.ext b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/bigtree/d/file.ext new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/bigtree/d/file.ext | |||
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/bigtree/e/file.ext b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/bigtree/e/file.ext new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/bigtree/e/file.ext | |||
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/bigtree/f/file.ext b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/bigtree/f/file.ext new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/bigtree/f/file.ext | |||
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/bigtree/file.ext b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/bigtree/file.ext new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/bigtree/file.ext | |||
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/bigtree/g/file.ext b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/bigtree/g/file.ext new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/bigtree/g/file.ext | |||
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/bigtree/h/file.ext b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/bigtree/h/file.ext new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/bigtree/h/file.ext | |||
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/bigtree/z/y/x/w/v/u/t/s/r/q/file.ext b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/bigtree/z/y/x/w/v/u/t/s/r/q/file.ext new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/bigtree/z/y/x/w/v/u/t/s/r/q/file.ext | |||
