Fix merged ProductCode from mergemod.cub and...
...work around other bugs in mergemod.cub. Fixes https://github.com/wixtoolset/issues/issues/7413.
Bob Arnson committed
Apr 20, 2023 at 18:23 UTC
eadea8a97bd69fa553abcebce644d4f770a94c3b
7 files changed
+86
-54
src/wix/WixToolset.Core.Native/WindowsInstallerValidator.cs
+6
-3
@@ -190,14 +190,17 @@ namespace WixToolset.Core.Native
190
191
using (var session = new Session(database))
192
{
193
- // Add the product code back into the database.
194
- if (null != productCode)
193
+ // Some CUBs erroneously have a ProductCode property, so delete it if we just picked one up.
194
+ if (propertyTableExists)
195
{
196
- // Some CUBs erroneously have a ProductCode property, so delete it if we just picked one up.
196
using (var dropProductCodeView = database.OpenExecuteView("DELETE FROM `Property` WHERE `Property` = 'ProductCode'"))
197
{
198
}
199
+ }
200
201
+ // Add the product code back into the database.
202
+ if (null != productCode)
203
+ {
204
using (var view = database.OpenExecuteView($"INSERT INTO `Property` (`Property`, `Value`) VALUES ('ProductCode', '{productCode}')"))
205
{
206
}
src/wix/WixToolset.Core.WindowsInstaller/Validate/ValidateDatabaseCommand.cs
+10
@@ -102,6 +102,16 @@ namespace WixToolset.Core.WindowsInstaller.Validate
102
messageSourceLineNumbers = this.GetSourceLineNumbers(message.Table, message.PrimaryKeys);
103
}
104
105
+ // Sigh. These are bad messages we get from the poorly-built mergemod.cub that supports Arm64.
106
+ // TODO: Re-evaluate mergemod.cub that's current for the next version of WiX.
107
+ if (message.IceName == "ICE03"
108
+ && (message.Table == "File" && message.Description.Contains("_ICEM07CAB Missing specifications"))
109
+ || (message.Table == "Component" && message.Description.Contains("_IceM05Mark Missing specifications"))
110
+ )
111
+ {
112
+ return;
113
+ }
114
+
115
switch (message.Type)
116
{
117
case ValidationMessageType.InternalFailure:
src/wix/test/WixToolsetTest.CoreIntegration/TestData/SimpleModule/Module.wixproj
deleted
-48
@@ -1,48 +0,0 @@
1
-<?xml version="1.0" encoding="utf-8"?>
2
-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
- <PropertyGroup>
4
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5
- <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
6
- <ProductVersion>0.9</ProductVersion>
7
- <ProjectGuid>27df04c6-3cef-4b9a-bac6-4e78d188384f</ProjectGuid>
8
- <OutputName>MergeModule1</OutputName>
9
- <OutputType>Module</OutputType>
10
- <Name>MergeModule1</Name>
11
- <RootNamespace>MergeModule1</RootNamespace>
12
- </PropertyGroup>
13
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
14
- <PlatformName>$(Platform)</PlatformName>
15
- <OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
16
- <DefineConstants>Debug</DefineConstants>
17
- </PropertyGroup>
18
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
19
- <PlatformName>$(Platform)</PlatformName>
20
- <OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
21
- </PropertyGroup>
22
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
23
- <PlatformName>$(Platform)</PlatformName>
24
- <OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
25
- <DefineConstants>Debug</DefineConstants>
26
- </PropertyGroup>
27
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
28
- <PlatformName>$(Platform)</PlatformName>
29
- <OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
30
- </PropertyGroup>
31
- <ItemGroup>
32
- <Compile Include="MergeModule.wxs" />
33
- </ItemGroup>
34
- <ItemGroup>
35
- <EmbeddedResource Include="MergeModule.en-us.wxl" />
36
- </ItemGroup>
37
- <ItemGroup>
38
- <WixExtension Include="FgwepExtension.wixext">
39
- <Name>FgwepExtension.wixext</Name>
40
- <HintPath>$(WixExtDir)\FgwepExtension.wixext.dll</HintPath>
41
- </WixExtension>
42
- </ItemGroup>
43
- <Import Project="$(WixTargetsPath)" Condition=" '$(WixTargetsPath)' != '' " />
44
- <Import Project="$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\wix.targets" Condition=" '$(WixTargetsPath)' == '' AND Exists('$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\wix.targets') " />
45
- <Target Name="EnsureWixToolsetInstalled" Condition=" '$(WixTargetsImported)' != 'true' ">
46
- <Error Text="FG-WiX or WiX Toolset build tools (v3.11 or later) must be installed to build this project. To download FG-WiX, go to https://www.firegiant.com/downloads/. To download the WiX Toolset, go to http://wixtoolset.org/releases/." />
47
- </Target>
48
-</Project>
\ No newline at end of file
src/wix/test/WixToolsetTest.CoreIntegration/TestData/SimpleModuleWithProperty/Module.en-us.wxl
new
+10
@@ -0,0 +1,10 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+
3
+<!--
4
+This file contains the declaration of all the localizable strings.
5
+-->
6
+<WixLocalization xmlns="http://wixtoolset.org/schemas/v4/wxl" Culture="en-US">
7
+
8
+ <String Id="Manufacturer" Value="Example Company" />
9
+
10
+</WixLocalization>
src/wix/test/WixToolsetTest.CoreIntegration/TestData/SimpleModuleWithProperty/Module.wxs
new
+19
@@ -0,0 +1,19 @@
1
+<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
2
+ <Module Id="MergeModule1" Language="1033" Version="1.0.0.0" Guid="243FB739-4D05-472F-9CFB-EF6B1017B6DE">
3
+ <SummaryInformation Manufacturer="!(loc.Manufacturer)" />
4
+
5
+ <Property Id="MERGEMODULEPROPERTY" Value="1" />
6
+
7
+ <Directory Id="MergeRedirectFolder">
8
+ <Component Id="ModuleComponent1" Guid="A04E61B2-3ED4-4803-B2EB-4B773576FA45">
9
+ <File Id="File1" Name="file1.txt" Source="test.txt" />
10
+ </Component>
11
+ </Directory>
12
+
13
+ <Directory Id="NotTheMergeRedirectFolder">
14
+ <Component Id="ModuleComponent2" Guid="EADB3047-BD32-417B-AABF-B8D9CCDC22DA">
15
+ <File Id="File2" Name="file2.txt" Source="test.txt" />
16
+ </Component>
17
+ </Directory>
18
+ </Module>
19
+</Wix>
src/wix/test/WixToolsetTest.CoreIntegration/TestData/SimpleModuleWithProperty/data/test.txt
new
+1
@@ -0,0 +1 @@
1
+This is test.txt.
\ No newline at end of file
src/wix/test/WixToolsetTest.CoreIntegration/ValidationFixture.cs
+40
-3
@@ -35,6 +35,7 @@ namespace WixToolsetTest.CoreIntegration
35
var result = WixRunner.Execute(new[]
36
{
37
"build",
38
+ "-arch", "arm64",
39
Path.Combine(folder, "Module.wxs"),
40
"-loc", Path.Combine(folder, "Module.en-us.wxl"),
41
"-bindpath", Path.Combine(folder, "data"),
@@ -91,7 +92,7 @@ namespace WixToolsetTest.CoreIntegration
92
"_SummaryInformation:Author\tExample Company",
93
"_SummaryInformation:Keywords\tMergeModule, MSI, database",
94
"_SummaryInformation:Comments\tThis merge module contains the logic and data required to install MergeModule1.",
94
- "_SummaryInformation:Template\tIntel;1033",
95
+ "_SummaryInformation:Template\tArm64;1033",
96
"_SummaryInformation:CodePage\t1252",
97
"_SummaryInformation:PageCount\t500",
98
"_SummaryInformation:WordCount\t0",
@@ -109,6 +110,42 @@ namespace WixToolsetTest.CoreIntegration
110
}
111
}
112
113
+ [Fact]
114
+ public void CanBuildAndValidateSimpleModuleWithProperty()
115
+ {
116
+ var folder = TestData.Get(@"TestData\SimpleModuleWithProperty");
117
+
118
+ using (var fs = new DisposableFileSystem())
119
+ {
120
+ var intermediateFolder = fs.GetFolder();
121
+
122
+ var result = WixRunner.Execute(new[]
123
+ {
124
+ "build",
125
+ "-arch", "arm64",
126
+ Path.Combine(folder, "Module.wxs"),
127
+ "-loc", Path.Combine(folder, "Module.en-us.wxl"),
128
+ "-bindpath", Path.Combine(folder, "data"),
129
+ "-intermediateFolder", intermediateFolder,
130
+ "-o", Path.Combine(intermediateFolder, @"bin\test.msm")
131
+ });
132
+
133
+ result.AssertSuccess();
134
+
135
+ var msmPath = Path.Combine(intermediateFolder, @"bin\test.msm");
136
+ Assert.True(File.Exists(msmPath));
137
+ Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\test.wixpdb")));
138
+
139
+ var validationResult = WixRunner.Execute(new[]
140
+ {
141
+ "msi", "validate",
142
+ "-intermediateFolder", intermediateFolder,
143
+ msmPath
144
+ });
145
+ validationResult.AssertSuccess();
146
+ }
147
+ }
148
+
149
[Fact]
150
public void CanMergeModuleAndValidate()
151
{
@@ -342,14 +379,14 @@ namespace WixToolsetTest.CoreIntegration
379
msiPath
380
});
381
345
- Assert.Equal(1076, validationResult.ExitCode);
346
-
382
var messages = validationResult.Messages.Select(m => m.ToString()).ToArray();
383
WixAssert.CompareLineByLine(new[]
384
{
385
"ICE12: CustomAction: CausesICE12Error is of type: 35. Therefore it must come after CostFinalize @ 1000 in Seq Table: InstallExecuteSequence. CA Seq#: 49",
386
"ICE46: Property 'Myproperty' referenced in column 'LaunchCondition'.'Condition' of row 'Myproperty' differs from a defined property by case only.",
387
}, messages);
388
+
389
+ Assert.Equal(1076, validationResult.ExitCode);
390
}
391
}
392