Fix several bugs with Merge Modules
Rob Mensching committed
Feb 6, 2022 at 09:52 UTC
718dce937b6c8aa0abe309364d3f298d206f4aae
7 files changed
+65
-32
src/wix/WixToolset.Core.Native/WixToolset.Core.Native.csproj
+5
-10
@@ -24,16 +24,11 @@
24
<ProjectReference Include="..\wixnative\wixnative.vcxproj" ReferenceOutputAssembly="false" PrivateAssets="All" Properties="Platform=x64" />
25
</ItemGroup>
26
27
- <!-- Copy the x86 binaries for unittests (especially CI) but use x64 binaries when in NCrunch -->
28
- <ItemGroup Condition=" '$(NCrunch)'=='' ">
29
- <None Include="..\wixnative\Win32\mergemod.dll" CopyToOutputDirectory="PreserveNewest" />
30
- <None Include="$(BaseOutputPath)$(Configuration)\x86\wixnative.exe" CopyToOutputDirectory="PreserveNewest" />
31
- <None Include="$(BaseOutputPath)$(Configuration)\x86\wixnative.pdb" CopyToOutputDirectory="PreserveNewest" />
32
- </ItemGroup>
33
- <ItemGroup Condition=" '$(NCrunch)'=='1' ">
34
- <None Include="$(NCrunchOriginalProjectDir)..\wixnative\x64\mergemod.dll" CopyToOutputDirectory="PreserveNewest" />
35
- <None Include="$(NCrunchOriginalProjectDir)..\..\..\build\$(SegmentName)\$(Configuration)\x86\wixnative.exe" CopyToOutputDirectory="PreserveNewest" />
36
- <None Include="$(NCrunchOriginalProjectDir)..\..\..\build\$(SegmentName)\$(Configuration)\x86\wixnative.pdb" CopyToOutputDirectory="PreserveNewest" />
27
+ <!-- Copy the x64 binaries for unittests since we've standardized on VS2022 (which is 64-bit only) -->
28
+ <ItemGroup>
29
+ <None Include="..\wixnative\x64\mergemod.dll" CopyToOutputDirectory="PreserveNewest" />
30
+ <None Include="$(BaseOutputPath)$(Configuration)\x64\wixnative.exe" CopyToOutputDirectory="PreserveNewest" />
31
+ <None Include="$(BaseOutputPath)$(Configuration)\x64\wixnative.pdb" CopyToOutputDirectory="PreserveNewest" />
32
</ItemGroup>
33
34
<ItemGroup>
src/wix/WixToolset.Core.WindowsInstaller/Bind/ExtractMergeModuleFilesCommand.cs
+7
-2
@@ -91,17 +91,22 @@ namespace WixToolset.Core.WindowsInstaller.Bind
91
{
92
var uniqueModuleFileIdentifiers = new Dictionary<string, IFileFacade>(StringComparer.OrdinalIgnoreCase);
93
94
- using (var view = db.OpenExecuteView("SELECT `File`, `Directory_` FROM `File`, `Component` WHERE `Component_`=`Component`"))
94
+ using (var view = db.OpenExecuteView("SELECT `File`, `Component_`, `FileName`, `Directory_` FROM `File`, `Component` WHERE `Component_`=`Component`"))
95
{
96
// add each file row from the merge module into the file row collection (check for errors along the way)
97
foreach (var record in view.Records)
98
{
99
+ var splitFilename = this.BackendHelper.SplitMsiFileName(record[3]);
100
+
101
// NOTE: this is very tricky - the merge module file rows are not added to the
102
// file table because they should not be created via idt import. Instead, these
103
// rows are created by merging in the actual modules.
104
var fileSymbol = new FileSymbol(wixMergeRow.SourceLineNumbers, new Identifier(AccessModifier.Section, record[1]));
105
fileSymbol.Attributes = wixMergeRow.FileAttributes;
104
- fileSymbol.DirectoryRef = record[2];
106
+ fileSymbol.ComponentRef = record[2];
107
+ fileSymbol.Name = splitFilename[1] ?? splitFilename[0];
108
+ fileSymbol.ShortName = splitFilename[1] is null ? null : splitFilename[0];
109
+ fileSymbol.DirectoryRef = record[4];
110
fileSymbol.DiskId = wixMergeRow.DiskId;
111
fileSymbol.Source = new IntermediateFieldPathValue { Path = Path.Combine(this.IntermediateFolder, wixMergeRow.Id.Id, record[1]) };
112
src/wix/WixToolset.Core.WindowsInstaller/Bind/UpdateMediaSequencesCommand.cs
+1
-1
@@ -68,7 +68,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
68
69
patchGroup.Add(facade);
70
}
71
- else if (!facade.FromModule)
71
+ else
72
{
73
facade.Sequence = ++lastSequence;
74
}
src/wix/WixToolset.Core/Compiler_Module.cs
+19
-1
@@ -249,7 +249,7 @@ namespace WixToolset.Core
249
this.Core.AddSymbol(new SummaryInformationSymbol(sourceLineNumbers)
250
{
251
PropertyId = SummaryInformationType.Keywords,
252
- Value = "Installer"
252
+ Value = "MergeModule, MSI, database"
253
});
254
}
255
@@ -266,6 +266,24 @@ namespace WixToolset.Core
266
Value = moduleId
267
});
268
269
+ this.Core.AddSymbol(new SummaryInformationSymbol(sourceLineNumbers)
270
+ {
271
+ PropertyId = SummaryInformationType.Title,
272
+ Value = "Merge Module"
273
+ });
274
+
275
+ this.Core.AddSymbol(new SummaryInformationSymbol(sourceLineNumbers)
276
+ {
277
+ PropertyId = SummaryInformationType.WordCount,
278
+ Value = "0"
279
+ });
280
+
281
+ this.Core.AddSymbol(new SummaryInformationSymbol(sourceLineNumbers)
282
+ {
283
+ PropertyId = SummaryInformationType.Comments,
284
+ Value = String.Format(CultureInfo.InvariantCulture, "This merge module contains the logic and data required to install {0}.", this.activeName)
285
+ });
286
+
287
this.ValidateAndAddCommonSummaryInformationSymbols(sourceLineNumbers, msiVersion, platform, this.activeLanguage);
288
}
289
}
src/wix/WixToolset.Core/Compiler_Package.cs
+12
-12
@@ -182,6 +182,18 @@ namespace WixToolset.Core
182
this.AddProperty(sourceLineNumbers, new Identifier(AccessModifier.Global, "ALLUSERS"), "1", false, false, false, false);
183
}
184
185
+ this.Core.AddSymbol(new SummaryInformationSymbol(sourceLineNumbers)
186
+ {
187
+ PropertyId = SummaryInformationType.Title,
188
+ Value = "Installation Database"
189
+ });
190
+
191
+ this.Core.AddSymbol(new SummaryInformationSymbol(sourceLineNumbers)
192
+ {
193
+ PropertyId = SummaryInformationType.Comments,
194
+ Value = String.Format(CultureInfo.InvariantCulture, "This installer database contains the logic and data required to install {0}.", this.activeName)
195
+ });
196
+
197
this.ValidateAndAddCommonSummaryInformationSymbols(sourceLineNumbers, msiVersion, platform, productLanguage);
198
199
this.Core.AddSymbol(new SummaryInformationSymbol(sourceLineNumbers)
@@ -449,18 +461,6 @@ namespace WixToolset.Core
461
this.Core.Write(WarningMessages.RequiresMsi500forArmPackage(sourceLineNumbers));
462
}
463
452
- this.Core.AddSymbol(new SummaryInformationSymbol(sourceLineNumbers)
453
- {
454
- PropertyId = SummaryInformationType.Comments,
455
- Value = String.Format(CultureInfo.InvariantCulture, "This installer database contains the logic and data required to install {0}.", this.activeName)
456
- });
457
-
458
- this.Core.AddSymbol(new SummaryInformationSymbol(sourceLineNumbers)
459
- {
460
- PropertyId = SummaryInformationType.Title,
461
- Value = "Installation Database"
462
- });
463
-
464
this.Core.AddSymbol(new SummaryInformationSymbol(sourceLineNumbers)
465
{
466
PropertyId = SummaryInformationType.PlatformAndLanguage,
src/wix/test/WixToolsetTest.CoreIntegration/MsiQueryFixture.cs
+19
-4
@@ -834,9 +834,10 @@ namespace WixToolsetTest.CoreIntegration
834
}
835
}
836
837
- [Fact(Skip = "Test fails in new repo")]
837
+ [Fact]
838
public void CanMergeModule()
839
{
840
+ var msmFolder = TestData.Get(@"TestData\SimpleModule");
841
var folder = TestData.Get(@"TestData\SimpleMerge");
842
843
using (var fs = new DisposableFileSystem())
@@ -845,12 +846,24 @@ namespace WixToolsetTest.CoreIntegration
846
var msiPath = Path.Combine(intermediateFolder, @"bin\test.msi");
847
var cabPath = Path.Combine(intermediateFolder, @"bin\cab1.cab");
848
849
+ var msmResult = WixRunner.Execute(new[]
850
+ {
851
+ "build",
852
+ Path.Combine(msmFolder, "Module.wxs"),
853
+ "-loc", Path.Combine(msmFolder, "Module.en-us.wxl"),
854
+ "-bindpath", Path.Combine(msmFolder, "data"),
855
+ "-intermediateFolder", intermediateFolder,
856
+ "-o", Path.Combine(intermediateFolder, "bin", "test", "test.msm")
857
+ });
858
+
859
+ msmResult.AssertSuccess();
860
+
861
var result = WixRunner.Execute(new[]
862
{
863
"build",
864
Path.Combine(folder, "Package.wxs"),
865
"-loc", Path.Combine(folder, "Package.en-us.wxl"),
853
- "-bindpath", Path.Combine(folder, ".data"),
866
+ "-bindpath", Path.Combine(intermediateFolder, "bin", "test"),
867
"-intermediateFolder", intermediateFolder,
868
"-o", msiPath
869
});
@@ -870,13 +883,15 @@ namespace WixToolsetTest.CoreIntegration
883
var results = Query.QueryDatabase(msiPath, new[] { "File" });
884
WixAssert.CompareLineByLine(new[]
885
{
873
- "File:filyIq8rqcxxf903Hsn5K9L0SWV73g.243FB739_4D05_472F_9CFB_EF6B1017B6DE\tModuleComponent.243FB739_4D05_472F_9CFB_EF6B1017B6DE\ttest.txt\t17\t\t\t512\t0"
886
+ "File:File1.243FB739_4D05_472F_9CFB_EF6B1017B6DE\tModuleComponent1.243FB739_4D05_472F_9CFB_EF6B1017B6DE\tfile1.txt\t17\t\t\t512\t1",
887
+ "File:File2.243FB739_4D05_472F_9CFB_EF6B1017B6DE\tModuleComponent2.243FB739_4D05_472F_9CFB_EF6B1017B6DE\tfile2.txt\t17\t\t\t512\t2",
888
}, results);
889
890
var files = Query.GetCabinetFiles(cabPath);
891
WixAssert.CompareLineByLine(new[]
892
{
879
- "filyIq8rqcxxf903Hsn5K9L0SWV73g.243FB739_4D05_472F_9CFB_EF6B1017B6DE"
893
+ "File1.243FB739_4D05_472F_9CFB_EF6B1017B6DE",
894
+ "File2.243FB739_4D05_472F_9CFB_EF6B1017B6DE"
895
}, files.Select(f => f.Name).ToArray());
896
}
897
}
src/wix/test/WixToolsetTest.CoreIntegration/TestData/SimpleModule/Module.wxs
+2
-2
@@ -4,13 +4,13 @@
4
5
<Directory Id="MergeRedirectFolder">
6
<Component Id="ModuleComponent1" Guid="A04E61B2-3ED4-4803-B2EB-4B773576FA45">
7
- <File Id="File1" Source="test.txt" />
7
+ <File Id="File1" Name="file1.txt" Source="test.txt" />
8
</Component>
9
</Directory>
10
11
<Directory Id="NotTheMergeRedirectFolder">
12
<Component Id="ModuleComponent2" Guid="EADB3047-BD32-417B-AABF-B8D9CCDC22DA">
13
- <File Id="File2" Source="test.txt" />
13
+ <File Id="File2" Name="file2.txt" Source="test.txt" />
14
</Component>
15
</Directory>
16
</Module>