diff options
author | Bob Arnson <bob@firegiant.com> | 2024-12-22 22:44:20 -0500 |
---|---|---|
committer | Bob Arnson <bob@firegiant.com> | 2024-12-22 22:44:20 -0500 |
commit | ca9f6ae3b0f6a8fd882ca6fe43ad8d4ae7b53435 (patch) | |
tree | 2b83d7b69b678425a702e8cfc3835f8d07844cc9 | |
parent | f440fb317c630e7bc6d4ee4d657a200654e2f876 (diff) | |
download | wix-bob/MagicFilesinRootModules8860.tar.gz wix-bob/MagicFilesinRootModules8860.tar.bz2 wix-bob/MagicFilesinRootModules8860.zip |
Magicked files in modules need complex references.bob/MagicFilesinRootModules8860
Magic files (naked `File`s and `Files`) that are direct children of a
`Module` need complex references from the generated component to that
module, to ensure that they're wired up correctly as module components.
Fixes https://github.com/wixtoolset/issues/issues/8860
5 files changed, 64 insertions, 10 deletions
diff --git a/src/api/wix/WixToolset.Data/Symbols/HarvestFilesSymbol.cs b/src/api/wix/WixToolset.Data/Symbols/HarvestFilesSymbol.cs index a3123fc1..6b56625e 100644 --- a/src/api/wix/WixToolset.Data/Symbols/HarvestFilesSymbol.cs +++ b/src/api/wix/WixToolset.Data/Symbols/HarvestFilesSymbol.cs | |||
@@ -16,6 +16,7 @@ namespace WixToolset.Data | |||
16 | new IntermediateFieldDefinition(nameof(HarvestFilesSymbolFields.ComplexReferenceParentType), IntermediateFieldType.String), | 16 | new IntermediateFieldDefinition(nameof(HarvestFilesSymbolFields.ComplexReferenceParentType), IntermediateFieldType.String), |
17 | new IntermediateFieldDefinition(nameof(HarvestFilesSymbolFields.ParentId), IntermediateFieldType.String), | 17 | new IntermediateFieldDefinition(nameof(HarvestFilesSymbolFields.ParentId), IntermediateFieldType.String), |
18 | new IntermediateFieldDefinition(nameof(HarvestFilesSymbolFields.SourcePath), IntermediateFieldType.String), | 18 | new IntermediateFieldDefinition(nameof(HarvestFilesSymbolFields.SourcePath), IntermediateFieldType.String), |
19 | new IntermediateFieldDefinition(nameof(HarvestFilesSymbolFields.ModuleLanguage), IntermediateFieldType.String), | ||
19 | }, | 20 | }, |
20 | typeof(HarvestFilesSymbol)); | 21 | typeof(HarvestFilesSymbol)); |
21 | } | 22 | } |
@@ -31,6 +32,7 @@ namespace WixToolset.Data.Symbols | |||
31 | ComplexReferenceParentType, | 32 | ComplexReferenceParentType, |
32 | ParentId, | 33 | ParentId, |
33 | SourcePath, | 34 | SourcePath, |
35 | ModuleLanguage, | ||
34 | } | 36 | } |
35 | 37 | ||
36 | public class HarvestFilesSymbol : IntermediateSymbol | 38 | public class HarvestFilesSymbol : IntermediateSymbol |
@@ -80,5 +82,11 @@ namespace WixToolset.Data.Symbols | |||
80 | get => (string)this.Fields[(int)HarvestFilesSymbolFields.SourcePath]; | 82 | get => (string)this.Fields[(int)HarvestFilesSymbolFields.SourcePath]; |
81 | set => this.Set((int)HarvestFilesSymbolFields.SourcePath, value); | 83 | set => this.Set((int)HarvestFilesSymbolFields.SourcePath, value); |
82 | } | 84 | } |
85 | |||
86 | public string ModuleLanguage | ||
87 | { | ||
88 | get => (string)this.Fields[(int)HarvestFilesSymbolFields.ModuleLanguage]; | ||
89 | set => this.Set((int)HarvestFilesSymbolFields.ModuleLanguage, value); | ||
90 | } | ||
83 | } | 91 | } |
84 | } | 92 | } |
diff --git a/src/wix/WixToolset.Core/Compiler.cs b/src/wix/WixToolset.Core/Compiler.cs index d13f1a68..410e3c16 100644 --- a/src/wix/WixToolset.Core/Compiler.cs +++ b/src/wix/WixToolset.Core/Compiler.cs | |||
@@ -5689,7 +5689,12 @@ namespace WixToolset.Core | |||
5689 | 5689 | ||
5690 | this.ParseFileElementChildren(node, fileSymbol, keyPath, win64); | 5690 | this.ParseFileElementChildren(node, fileSymbol, keyPath, win64); |
5691 | 5691 | ||
5692 | if (ComplexReferenceParentType.Unknown != parentType && null != parentId) // if parent was provided, add a complex reference to that. | 5692 | // if this is a module, automatically add this component to the references to ensure it gets in the ModuleComponents table |
5693 | if (this.compilingModule) | ||
5694 | { | ||
5695 | this.Core.CreateComplexReference(sourceLineNumbers, ComplexReferenceParentType.Module, this.activeName, this.activeLanguage, ComplexReferenceChildType.Component, fileSymbol.Id.Id, false); | ||
5696 | } | ||
5697 | else if (ComplexReferenceParentType.Unknown != parentType && null != parentId) // if parent was provided, add a complex reference to that. | ||
5693 | { | 5698 | { |
5694 | // If the naked file's component is defined directly under a feature, then mark the complex reference primary. | 5699 | // If the naked file's component is defined directly under a feature, then mark the complex reference primary. |
5695 | this.Core.CreateComplexReference(sourceLineNumbers, parentType, parentId, null, ComplexReferenceChildType.Component, fileSymbol.Id.Id, ComplexReferenceParentType.Feature == parentType); | 5700 | this.Core.CreateComplexReference(sourceLineNumbers, parentType, parentId, null, ComplexReferenceChildType.Component, fileSymbol.Id.Id, ComplexReferenceParentType.Feature == parentType); |
@@ -5790,6 +5795,7 @@ namespace WixToolset.Core | |||
5790 | ComplexReferenceParentType = parentType.ToString(), | 5795 | ComplexReferenceParentType = parentType.ToString(), |
5791 | ParentId = parentId, | 5796 | ParentId = parentId, |
5792 | SourcePath = sourcePath, | 5797 | SourcePath = sourcePath, |
5798 | ModuleLanguage = this.compilingModule ? this.activeLanguage : null, | ||
5793 | }); | 5799 | }); |
5794 | } | 5800 | } |
5795 | 5801 | ||
diff --git a/src/wix/WixToolset.Core/HarvestFilesCommand.cs b/src/wix/WixToolset.Core/HarvestFilesCommand.cs index a8c716d0..760e0018 100644 --- a/src/wix/WixToolset.Core/HarvestFilesCommand.cs +++ b/src/wix/WixToolset.Core/HarvestFilesCommand.cs | |||
@@ -116,10 +116,15 @@ namespace WixToolset.Core | |||
116 | Win64 = this.Context.Platform == Platform.ARM64 || this.Context.Platform == Platform.X64, | 116 | Win64 = this.Context.Platform == Platform.ARM64 || this.Context.Platform == Platform.X64, |
117 | }); | 117 | }); |
118 | 118 | ||
119 | if (Enum.TryParse<ComplexReferenceParentType>(harvestFile.ComplexReferenceParentType, out var parentType) | 119 | // if this is a module, automatically add this component to the references to ensure it gets in the ModuleComponents table |
120 | if (!String.IsNullOrEmpty(harvestFile.ModuleLanguage)) | ||
121 | { | ||
122 | this.ParseHelper.CreateComplexReference(section, harvestFile.SourceLineNumbers, ComplexReferenceParentType.Module, harvestFile.ParentId, harvestFile.ModuleLanguage, ComplexReferenceChildType.Component, id.Id, false); | ||
123 | } | ||
124 | else if (Enum.TryParse<ComplexReferenceParentType>(harvestFile.ComplexReferenceParentType, out var parentType) | ||
120 | && ComplexReferenceParentType.Unknown != parentType && null != harvestFile.ParentId) | 125 | && ComplexReferenceParentType.Unknown != parentType && null != harvestFile.ParentId) |
121 | { | 126 | { |
122 | // If the parent was provided, add a complex reference to that, and, if | 127 | // If the parent was provided, add a complex reference to that, and, if |
123 | // the Files is under a feature, then mark the complex reference primary. | 128 | // the Files is under a feature, then mark the complex reference primary. |
124 | this.ParseHelper.CreateComplexReference(section, harvestFile.SourceLineNumbers, parentType, harvestFile.ParentId, null, ComplexReferenceChildType.Component, id.Id, ComplexReferenceParentType.Feature == parentType); | 129 | this.ParseHelper.CreateComplexReference(section, harvestFile.SourceLineNumbers, parentType, harvestFile.ParentId, null, ComplexReferenceChildType.Component, id.Id, ComplexReferenceParentType.Feature == parentType); |
125 | } | 130 | } |
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs index 7da47f6b..54afcc34 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs | |||
@@ -9,6 +9,7 @@ namespace WixToolsetTest.CoreIntegration | |||
9 | using System.Linq; | 9 | using System.Linq; |
10 | using WixInternal.Core.TestPackage; | 10 | using WixInternal.Core.TestPackage; |
11 | using WixInternal.TestSupport; | 11 | using WixInternal.TestSupport; |
12 | using WixToolset.Data.WindowsInstaller; | ||
12 | using Xunit; | 13 | using Xunit; |
13 | 14 | ||
14 | public class HarvestFilesFixture | 15 | public class HarvestFilesFixture |
@@ -223,16 +224,34 @@ namespace WixToolsetTest.CoreIntegration | |||
223 | [Fact] | 224 | [Fact] |
224 | public void CanHarvestFilesInModules() | 225 | public void CanHarvestFilesInModules() |
225 | { | 226 | { |
226 | var expected = new[] | 227 | var expectedFilesAndTargetPaths = new[] |
227 | { | 228 | { |
228 | @"flsgrgAVAsCQ8tCCxfnbBNis66623c.E535B765_1019_4A4F_B3EA_AE28870E6D73=PFiles\MergeModule\test1.txt", | 229 | @"flsBvxG729t7hKBa4KOmfvNMPptZkM.E535B765_1019_4A4F_B3EA_AE28870E6D73=PFiles\MergeModule\test4.txt", |
229 | @"flsDBWSWjpVSU3Zs33bREsJa2ygSQM.E535B765_1019_4A4F_B3EA_AE28870E6D73=PFiles\MergeModule\test2.txt", | 230 | @"flsDBWSWjpVSU3Zs33bREsJa2ygSQM.E535B765_1019_4A4F_B3EA_AE28870E6D73=PFiles\MergeModule\test2.txt", |
230 | @"flsehdwEdXusUijRShuTszSxwf8joA.E535B765_1019_4A4F_B3EA_AE28870E6D73=PFiles\MergeModule\test3.txt", | 231 | @"flsehdwEdXusUijRShuTszSxwf8joA.E535B765_1019_4A4F_B3EA_AE28870E6D73=PFiles\MergeModule\test3.txt", |
231 | @"flsBvxG729t7hKBa4KOmfvNMPptZkM.E535B765_1019_4A4F_B3EA_AE28870E6D73=PFiles\MergeModule\test4.txt", | 232 | @"flsgrgAVAsCQ8tCCxfnbBNis66623c.E535B765_1019_4A4F_B3EA_AE28870E6D73=PFiles\MergeModule\test1.txt", |
232 | @"flskqOUVMfAE13k2h.ZkPhurwO4Y1c.E535B765_1019_4A4F_B3EA_AE28870E6D73=PFiles\MergeModule\notatest.txt", | 233 | @"flskqOUVMfAE13k2h.ZkPhurwO4Y1c.E535B765_1019_4A4F_B3EA_AE28870E6D73=PFiles\MergeModule\notatest.txt", |
233 | }; | 234 | }; |
234 | 235 | ||
235 | Build("Module.wxs", (msiPath, _) => AssertFileIdsAndTargetPaths(msiPath, expected), isPackage: false); | 236 | var expectedModuleComponents = new[] |
237 | { | ||
238 | "ModuleComponents:flsBvxG729t7hKBa4KOmfvNMPptZkM.E535B765_1019_4A4F_B3EA_AE28870E6D73\tMergeModule.E535B765_1019_4A4F_B3EA_AE28870E6D73\t1033", | ||
239 | "ModuleComponents:flsDBWSWjpVSU3Zs33bREsJa2ygSQM.E535B765_1019_4A4F_B3EA_AE28870E6D73\tMergeModule.E535B765_1019_4A4F_B3EA_AE28870E6D73\t1033", | ||
240 | "ModuleComponents:flsehdwEdXusUijRShuTszSxwf8joA.E535B765_1019_4A4F_B3EA_AE28870E6D73\tMergeModule.E535B765_1019_4A4F_B3EA_AE28870E6D73\t1033", | ||
241 | "ModuleComponents:flsgrgAVAsCQ8tCCxfnbBNis66623c.E535B765_1019_4A4F_B3EA_AE28870E6D73\tMergeModule.E535B765_1019_4A4F_B3EA_AE28870E6D73\t1033", | ||
242 | "ModuleComponents:flskqOUVMfAE13k2h.ZkPhurwO4Y1c.E535B765_1019_4A4F_B3EA_AE28870E6D73\tMergeModule.E535B765_1019_4A4F_B3EA_AE28870E6D73\t1033", | ||
243 | }; | ||
244 | |||
245 | Build("Module.wxs", (msiPath, _) => AssertModuleComponentsFileIdsAndTargetPaths(msiPath, expectedFilesAndTargetPaths, expectedModuleComponents), isMsi: false); | ||
246 | |||
247 | static void AssertModuleComponentsFileIdsAndTargetPaths(string msiPath, string[] expectedFilesAndTargetPaths, string[] expectedModuleComponents) | ||
248 | { | ||
249 | AssertFileIdsAndTargetPaths(msiPath, expectedFilesAndTargetPaths); | ||
250 | |||
251 | var query = Query.QueryDatabase(msiPath, new[] { "ModuleComponents" }); | ||
252 | |||
253 | Assert.Equal(expectedModuleComponents, query); | ||
254 | } | ||
236 | } | 255 | } |
237 | 256 | ||
238 | [Fact] | 257 | [Fact] |
@@ -319,7 +338,7 @@ namespace WixToolsetTest.CoreIntegration | |||
319 | Assert.Equal(sortedExpected, actual); | 338 | Assert.Equal(sortedExpected, actual); |
320 | } | 339 | } |
321 | 340 | ||
322 | private static void Build(string file, Action<string, WixRunnerResult> tester, bool isPackage = true, params string[] additionalCommandLineArguments) | 341 | private static void Build(string file, Action<string, WixRunnerResult> tester, bool isMsi = true, params string[] additionalCommandLineArguments) |
323 | { | 342 | { |
324 | var folder = TestData.Get("TestData", "HarvestFiles"); | 343 | var folder = TestData.Get("TestData", "HarvestFiles"); |
325 | 344 | ||
@@ -328,7 +347,7 @@ namespace WixToolsetTest.CoreIntegration | |||
328 | var baseFolder = fs.GetFolder(); | 347 | var baseFolder = fs.GetFolder(); |
329 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | 348 | var intermediateFolder = Path.Combine(baseFolder, "obj"); |
330 | var binFolder = Path.Combine(baseFolder, "bin"); | 349 | var binFolder = Path.Combine(baseFolder, "bin"); |
331 | var msiPath = Path.Combine(binFolder, isPackage ? "test.msi" : "test.msm"); | 350 | var msiPath = Path.Combine(binFolder, isMsi ? "test.msi" : "test.msm"); |
332 | 351 | ||
333 | var arguments = new List<string>() | 352 | var arguments = new List<string>() |
334 | { | 353 | { |
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/NakedFileFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/NakedFileFixture.cs index 6d874ff0..ae13421d 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/NakedFileFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/NakedFileFixture.cs | |||
@@ -2,6 +2,7 @@ | |||
2 | 2 | ||
3 | namespace WixToolsetTest.CoreIntegration | 3 | namespace WixToolsetTest.CoreIntegration |
4 | { | 4 | { |
5 | using System.Collections.Generic; | ||
5 | using System.Data; | 6 | using System.Data; |
6 | using System.IO; | 7 | using System.IO; |
7 | using System.Linq; | 8 | using System.Linq; |
@@ -82,6 +83,14 @@ namespace WixToolsetTest.CoreIntegration | |||
82 | var rows = BuildAndQueryComponentAndFileTables("Module.wxs", isPackage: false); | 83 | var rows = BuildAndQueryComponentAndFileTables("Module.wxs", isPackage: false); |
83 | 84 | ||
84 | AssertFileComponentIds(2, rows); | 85 | AssertFileComponentIds(2, rows); |
86 | |||
87 | var expectedModuleComponents = new[] | ||
88 | { | ||
89 | "ModuleComponents:FILE1.E535B765_1019_4A4F_B3EA_AE28870E6D73\tMergeModule.E535B765_1019_4A4F_B3EA_AE28870E6D73\t1033", | ||
90 | "ModuleComponents:FILE2.E535B765_1019_4A4F_B3EA_AE28870E6D73\tMergeModule.E535B765_1019_4A4F_B3EA_AE28870E6D73\t1033", | ||
91 | }; | ||
92 | |||
93 | Assert.Equal(expectedModuleComponents, rows.Where(row => row.StartsWith("ModuleComponents:"))); | ||
85 | } | 94 | } |
86 | 95 | ||
87 | [Fact] | 96 | [Fact] |
@@ -215,7 +224,14 @@ namespace WixToolsetTest.CoreIntegration | |||
215 | { | 224 | { |
216 | result.AssertSuccess(); | 225 | result.AssertSuccess(); |
217 | 226 | ||
218 | return Query.QueryDatabase(msiPath, new[] { "Component", "File" }) | 227 | var tables = new List<string> { "Component", "File" }; |
228 | |||
229 | if (!isPackage) | ||
230 | { | ||
231 | tables.Add("ModuleComponents"); | ||
232 | } | ||
233 | |||
234 | return Query.QueryDatabase(msiPath, tables.ToArray()) | ||
219 | .OrderBy(s => s) | 235 | .OrderBy(s => s) |
220 | .ToArray(); | 236 | .ToArray(); |
221 | } | 237 | } |