aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBob Arnson <bob@firegiant.com>2024-12-22 22:44:20 -0500
committerRob Mensching <rob@firegiant.com>2024-12-27 10:01:53 -0800
commit28a2c0e963897ddc61e6673bcb93e10b9696375f (patch)
treee2490d899f231aadaa48cf029d42b77c0da75f73 /src
parent5dc8c8975b2356654410b2ba4755dfa2c32e7b91 (diff)
downloadwix-28a2c0e963897ddc61e6673bcb93e10b9696375f.tar.gz
wix-28a2c0e963897ddc61e6673bcb93e10b9696375f.tar.bz2
wix-28a2c0e963897ddc61e6673bcb93e10b9696375f.zip
Magicked files in modules need complex references.
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
Diffstat (limited to 'src')
-rw-r--r--src/api/wix/WixToolset.Data/Symbols/HarvestFilesSymbol.cs8
-rw-r--r--src/wix/WixToolset.Core/Compiler.cs8
-rw-r--r--src/wix/WixToolset.Core/HarvestFilesCommand.cs9
-rw-r--r--src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs31
-rw-r--r--src/wix/test/WixToolsetTest.CoreIntegration/NakedFileFixture.cs18
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 84f31344..3b3c62d4 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 4acd9f24..ed78e808 100644
--- a/src/wix/WixToolset.Core/HarvestFilesCommand.cs
+++ b/src/wix/WixToolset.Core/HarvestFilesCommand.cs
@@ -107,10 +107,15 @@ namespace WixToolset.Core
107 Win64 = this.Context.Platform == Platform.ARM64 || this.Context.Platform == Platform.X64, 107 Win64 = this.Context.Platform == Platform.ARM64 || this.Context.Platform == Platform.X64,
108 }); 108 });
109 109
110 if (Enum.TryParse<ComplexReferenceParentType>(harvestFile.ComplexReferenceParentType, out var parentType) 110 // if this is a module, automatically add this component to the references to ensure it gets in the ModuleComponents table
111 if (!String.IsNullOrEmpty(harvestFile.ModuleLanguage))
112 {
113 this.ParseHelper.CreateComplexReference(section, harvestFile.SourceLineNumbers, ComplexReferenceParentType.Module, harvestFile.ParentId, harvestFile.ModuleLanguage, ComplexReferenceChildType.Component, id.Id, false);
114 }
115 else if (Enum.TryParse<ComplexReferenceParentType>(harvestFile.ComplexReferenceParentType, out var parentType)
111 && ComplexReferenceParentType.Unknown != parentType && null != harvestFile.ParentId) 116 && ComplexReferenceParentType.Unknown != parentType && null != harvestFile.ParentId)
112 { 117 {
113 // If the parent was provided, add a complex reference to that, and, if 118 // If the parent was provided, add a complex reference to that, and, if
114 // the Files is under a feature, then mark the complex reference primary. 119 // the Files is under a feature, then mark the complex reference primary.
115 this.ParseHelper.CreateComplexReference(section, harvestFile.SourceLineNumbers, parentType, harvestFile.ParentId, null, ComplexReferenceChildType.Component, id.Id, ComplexReferenceParentType.Feature == parentType); 120 this.ParseHelper.CreateComplexReference(section, harvestFile.SourceLineNumbers, parentType, harvestFile.ParentId, null, ComplexReferenceChildType.Component, id.Id, ComplexReferenceParentType.Feature == parentType);
116 } 121 }
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs
index 2630e295..8e4964de 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
@@ -225,16 +226,34 @@ namespace WixToolsetTest.CoreIntegration
225 [Fact] 226 [Fact]
226 public void CanHarvestFilesInModules() 227 public void CanHarvestFilesInModules()
227 { 228 {
228 var expected = new[] 229 var expectedFilesAndTargetPaths = new[]
229 { 230 {
230 @"flsgrgAVAsCQ8tCCxfnbBNis66623c.E535B765_1019_4A4F_B3EA_AE28870E6D73=PFiles\MergeModule\test1.txt", 231 @"flsBvxG729t7hKBa4KOmfvNMPptZkM.E535B765_1019_4A4F_B3EA_AE28870E6D73=PFiles\MergeModule\test4.txt",
231 @"flsDBWSWjpVSU3Zs33bREsJa2ygSQM.E535B765_1019_4A4F_B3EA_AE28870E6D73=PFiles\MergeModule\test2.txt", 232 @"flsDBWSWjpVSU3Zs33bREsJa2ygSQM.E535B765_1019_4A4F_B3EA_AE28870E6D73=PFiles\MergeModule\test2.txt",
232 @"flsehdwEdXusUijRShuTszSxwf8joA.E535B765_1019_4A4F_B3EA_AE28870E6D73=PFiles\MergeModule\test3.txt", 233 @"flsehdwEdXusUijRShuTszSxwf8joA.E535B765_1019_4A4F_B3EA_AE28870E6D73=PFiles\MergeModule\test3.txt",
233 @"flsBvxG729t7hKBa4KOmfvNMPptZkM.E535B765_1019_4A4F_B3EA_AE28870E6D73=PFiles\MergeModule\test4.txt", 234 @"flsgrgAVAsCQ8tCCxfnbBNis66623c.E535B765_1019_4A4F_B3EA_AE28870E6D73=PFiles\MergeModule\test1.txt",
234 @"flskqOUVMfAE13k2h.ZkPhurwO4Y1c.E535B765_1019_4A4F_B3EA_AE28870E6D73=PFiles\MergeModule\notatest.txt", 235 @"flskqOUVMfAE13k2h.ZkPhurwO4Y1c.E535B765_1019_4A4F_B3EA_AE28870E6D73=PFiles\MergeModule\notatest.txt",
235 }; 236 };
236 237
237 Build("Module.wxs", (msiPath, _) => AssertFileIdsAndTargetPaths(msiPath, expected), isPackage: false); 238 var expectedModuleComponents = new[]
239 {
240 "ModuleComponents:flsBvxG729t7hKBa4KOmfvNMPptZkM.E535B765_1019_4A4F_B3EA_AE28870E6D73\tMergeModule.E535B765_1019_4A4F_B3EA_AE28870E6D73\t1033",
241 "ModuleComponents:flsDBWSWjpVSU3Zs33bREsJa2ygSQM.E535B765_1019_4A4F_B3EA_AE28870E6D73\tMergeModule.E535B765_1019_4A4F_B3EA_AE28870E6D73\t1033",
242 "ModuleComponents:flsehdwEdXusUijRShuTszSxwf8joA.E535B765_1019_4A4F_B3EA_AE28870E6D73\tMergeModule.E535B765_1019_4A4F_B3EA_AE28870E6D73\t1033",
243 "ModuleComponents:flsgrgAVAsCQ8tCCxfnbBNis66623c.E535B765_1019_4A4F_B3EA_AE28870E6D73\tMergeModule.E535B765_1019_4A4F_B3EA_AE28870E6D73\t1033",
244 "ModuleComponents:flskqOUVMfAE13k2h.ZkPhurwO4Y1c.E535B765_1019_4A4F_B3EA_AE28870E6D73\tMergeModule.E535B765_1019_4A4F_B3EA_AE28870E6D73\t1033",
245 };
246
247 Build("Module.wxs", (msiPath, _) => AssertModuleComponentsFileIdsAndTargetPaths(msiPath, expectedFilesAndTargetPaths, expectedModuleComponents), isMsi: false);
248
249 static void AssertModuleComponentsFileIdsAndTargetPaths(string msiPath, string[] expectedFilesAndTargetPaths, string[] expectedModuleComponents)
250 {
251 AssertFileIdsAndTargetPaths(msiPath, expectedFilesAndTargetPaths);
252
253 var query = Query.QueryDatabase(msiPath, new[] { "ModuleComponents" });
254
255 Assert.Equal(expectedModuleComponents, query);
256 }
238 } 257 }
239 258
240 [Fact] 259 [Fact]
@@ -346,7 +365,7 @@ namespace WixToolsetTest.CoreIntegration
346 Assert.Equal(sortedExpected, actual); 365 Assert.Equal(sortedExpected, actual);
347 } 366 }
348 367
349 private static void Build(string file, Action<string, WixRunnerResult> tester, bool isPackage = true, bool warningsAsErrors = true, bool addUnnamedBindPath = false, params string[] additionalCommandLineArguments) 368 private static void Build(string file, Action<string, WixRunnerResult> tester, bool isMsi = true, bool warningsAsErrors = true, bool addUnnamedBindPath = false, params string[] additionalCommandLineArguments)
350 { 369 {
351 var folder = TestData.Get("TestData", "HarvestFiles"); 370 var folder = TestData.Get("TestData", "HarvestFiles");
352 371
@@ -355,7 +374,7 @@ namespace WixToolsetTest.CoreIntegration
355 var baseFolder = fs.GetFolder(); 374 var baseFolder = fs.GetFolder();
356 var intermediateFolder = Path.Combine(baseFolder, "obj"); 375 var intermediateFolder = Path.Combine(baseFolder, "obj");
357 var binFolder = Path.Combine(baseFolder, "bin"); 376 var binFolder = Path.Combine(baseFolder, "bin");
358 var msiPath = Path.Combine(binFolder, isPackage ? "test.msi" : "test.msm"); 377 var msiPath = Path.Combine(binFolder, isMsi ? "test.msi" : "test.msm");
359 378
360 var arguments = new List<string>() 379 var arguments = new List<string>()
361 { 380 {
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
3namespace WixToolsetTest.CoreIntegration 3namespace 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 }