aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2021-03-01 10:14:38 -0800
committerRob Mensching <rob@firegiant.com>2021-03-01 12:23:34 -0800
commit3eb3c26c796984b64365fda077f173af8bf31559 (patch)
tree0912d69363973bc8db704a18b1b4bcede6a84360
parent697f2cdbdcd8198d06ebf14fc2b65f0ce3fa5a94 (diff)
downloadwix-3eb3c26c796984b64365fda077f173af8bf31559.tar.gz
wix-3eb3c26c796984b64365fda077f173af8bf31559.tar.bz2
wix-3eb3c26c796984b64365fda077f173af8bf31559.zip
Fix handling of suppress modularization
Partially fixes wixtoolset/issues#5944
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/ModularizeCommand.cs2
-rw-r--r--src/WixToolset.Core/Compiler.cs12
-rw-r--r--src/WixToolset.Core/Compiler_Package.cs5
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/ModuleFixture.cs108
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/MsiFixture.cs50
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/TestData/SuppressModularization/Module.en-us.wxl10
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/TestData/SuppressModularization/Module.wxs10
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/TestData/SuppressModularization/data/test.txt1
8 files changed, 143 insertions, 55 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/ModularizeCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/ModularizeCommand.cs
index 66ca502d..49ef1adf 100644
--- a/src/WixToolset.Core.WindowsInstaller/Bind/ModularizeCommand.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Bind/ModularizeCommand.cs
@@ -21,7 +21,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
21 this.ModularizationSuffix = modularizationSuffix; 21 this.ModularizationSuffix = modularizationSuffix;
22 22
23 // Gather all the unique suppress modularization identifiers. 23 // Gather all the unique suppress modularization identifiers.
24 this.SuppressModularizationIdentifiers = new HashSet<string>(suppressSymbols.Select(s => s.Id.Id)); 24 this.SuppressModularizationIdentifiers = new HashSet<string>(suppressSymbols.Select(s => s.SuppressIdentifier));
25 } 25 }
26 26
27 private WindowsInstallerData Output { get; } 27 private WindowsInstallerData Output { get; }
diff --git a/src/WixToolset.Core/Compiler.cs b/src/WixToolset.Core/Compiler.cs
index 384f8795..7113c3b5 100644
--- a/src/WixToolset.Core/Compiler.cs
+++ b/src/WixToolset.Core/Compiler.cs
@@ -728,14 +728,17 @@ namespace WixToolset.Core
728 728
729 if (!this.Core.EncounteredError) 729 if (!this.Core.EncounteredError)
730 { 730 {
731 var symbol = this.Core.AddSymbol(new BinarySymbol(sourceLineNumbers, id) 731 this.Core.AddSymbol(new BinarySymbol(sourceLineNumbers, id)
732 { 732 {
733 Data = new IntermediateFieldPathValue { Path = sourceFile } 733 Data = new IntermediateFieldPathValue { Path = sourceFile }
734 }); 734 });
735 735
736 if (YesNoType.Yes == suppressModularization) 736 if (YesNoType.Yes == suppressModularization)
737 { 737 {
738 this.Core.AddSymbol(new WixSuppressModularizationSymbol(sourceLineNumbers, id)); 738 this.Core.AddSymbol(new WixSuppressModularizationSymbol(sourceLineNumbers)
739 {
740 SuppressIdentifier = id.Id
741 });
739 } 742 }
740 } 743 }
741 744
@@ -3502,7 +3505,10 @@ namespace WixToolset.Core
3502 3505
3503 if (YesNoType.Yes == suppressModularization) 3506 if (YesNoType.Yes == suppressModularization)
3504 { 3507 {
3505 this.Core.AddSymbol(new WixSuppressModularizationSymbol(sourceLineNumbers, id)); 3508 this.Core.AddSymbol(new WixSuppressModularizationSymbol(sourceLineNumbers)
3509 {
3510 SuppressIdentifier = id.Id
3511 });
3506 } 3512 }
3507 } 3513 }
3508 } 3514 }
diff --git a/src/WixToolset.Core/Compiler_Package.cs b/src/WixToolset.Core/Compiler_Package.cs
index d2728e9c..7a842ef0 100644
--- a/src/WixToolset.Core/Compiler_Package.cs
+++ b/src/WixToolset.Core/Compiler_Package.cs
@@ -1515,7 +1515,10 @@ namespace WixToolset.Core
1515 { 1515 {
1516 this.Core.Write(WarningMessages.PropertyModularizationSuppressed(sourceLineNumbers)); 1516 this.Core.Write(WarningMessages.PropertyModularizationSuppressed(sourceLineNumbers));
1517 1517
1518 this.Core.AddSymbol(new WixSuppressModularizationSymbol(sourceLineNumbers, id)); 1518 this.Core.AddSymbol(new WixSuppressModularizationSymbol(sourceLineNumbers)
1519 {
1520 SuppressIdentifier = id.Id
1521 });
1519 } 1522 }
1520 } 1523 }
1521 1524
diff --git a/src/test/WixToolsetTest.CoreIntegration/ModuleFixture.cs b/src/test/WixToolsetTest.CoreIntegration/ModuleFixture.cs
new file mode 100644
index 00000000..349bad2c
--- /dev/null
+++ b/src/test/WixToolsetTest.CoreIntegration/ModuleFixture.cs
@@ -0,0 +1,108 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolsetTest.CoreIntegration
4{
5 using System;
6 using System.IO;
7 using System.Linq;
8 using WixBuildTools.TestSupport;
9 using WixToolset.Core.TestPackage;
10 using WixToolset.Data;
11 using WixToolset.Data.Symbols;
12 using WixToolset.Data.WindowsInstaller;
13 using Xunit;
14
15 public class ModuleFixture
16 {
17 [Fact]
18 public void CanBuildSimpleModule()
19 {
20 var folder = TestData.Get(@"TestData\SimpleModule");
21
22 using (var fs = new DisposableFileSystem())
23 {
24 var intermediateFolder = fs.GetFolder();
25
26 var result = WixRunner.Execute(new[]
27 {
28 "build",
29 Path.Combine(folder, "Module.wxs"),
30 "-loc", Path.Combine(folder, "Module.en-us.wxl"),
31 "-bindpath", Path.Combine(folder, "data"),
32 "-intermediateFolder", intermediateFolder,
33 "-o", Path.Combine(intermediateFolder, @"bin\test.msm")
34 });
35
36 result.AssertSuccess();
37
38 var msmPath = Path.Combine(intermediateFolder, @"bin\test.msm");
39 Assert.True(File.Exists(msmPath));
40 Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\test.wixpdb")));
41
42 var intermediate = Intermediate.Load(Path.Combine(intermediateFolder, @"bin\test.wixpdb"));
43 var section = intermediate.Sections.Single();
44
45 var dirSymbols = section.Symbols.OfType<DirectorySymbol>().OrderBy(d => d.Id.Id).ToList();
46 WixAssert.CompareLineByLine(new[]
47 {
48 "MergeRedirectFolder\tTARGETDIR\t.",
49 "TARGETDIR\t\tSourceDir"
50 }, dirSymbols.Select(d => String.Join("\t", d.Id.Id, d.ParentDirectoryRef, d.Name)).ToArray());
51
52 var fileSymbol = section.Symbols.OfType<FileSymbol>().Single();
53 Assert.Equal("filyIq8rqcxxf903Hsn5K9L0SWV73g", fileSymbol.Id.Id);
54 Assert.Equal(Path.Combine(folder, @"data\test.txt"), fileSymbol[FileSymbolFields.Source].AsPath().Path);
55 Assert.Equal(@"test.txt", fileSymbol[FileSymbolFields.Source].PreviousValue.AsPath().Path);
56
57 var data = WindowsInstallerData.Load(Path.Combine(intermediateFolder, @"bin\test.wixpdb"));
58 var fileRows = data.Tables["File"].Rows;
59 Assert.Equal(new[]
60 {
61 "filyIq8rqcxxf903Hsn5K9L0SWV73g.243FB739_4D05_472F_9CFB_EF6B1017B6DE"
62 }, fileRows.Select(r => r.FieldAsString(0)).ToArray());
63
64 var cabPath = Path.Combine(intermediateFolder, "msm-test.cab");
65 Query.ExtractStream(msmPath, "MergeModule.CABinet", cabPath);
66 var files = Query.GetCabinetFiles(cabPath);
67 Assert.Equal(new[]
68 {
69 "filyIq8rqcxxf903Hsn5K9L0SWV73g.243FB739_4D05_472F_9CFB_EF6B1017B6DE"
70 }, files.Select(f => Path.Combine(f.Path, f.Name)).ToArray());
71 }
72 }
73
74 [Fact]
75 public void CanSuppressModularization()
76 {
77 var folder = TestData.Get(@"TestData\SuppressModularization");
78
79 using (var fs = new DisposableFileSystem())
80 {
81 var intermediateFolder = fs.GetFolder();
82
83 var result = WixRunner.Execute(new[]
84 {
85 "build",
86 Path.Combine(folder, "Module.wxs"),
87 "-loc", Path.Combine(folder, "Module.en-us.wxl"),
88 "-bindpath", Path.Combine(folder, "data"),
89 "-intermediateFolder", intermediateFolder,
90 "-sw1079",
91 "-sw1086",
92 "-o", Path.Combine(intermediateFolder, @"bin\test.msm")
93 });
94
95 result.AssertSuccess();
96
97 var msmPath = Path.Combine(intermediateFolder, @"bin\test.msm");
98
99 var rows = Query.QueryDatabase(msmPath, new[] { "CustomAction", "Property" });
100 WixAssert.CompareLineByLine(new[]
101 {
102 "CustomAction:Test\t11265\tFakeCA.243FB739_4D05_472F_9CFB_EF6B1017B6DE\tTestEntry\t",
103 "Property:MsiHiddenProperties\tTest"
104 }, rows);
105 }
106 }
107 }
108}
diff --git a/src/test/WixToolsetTest.CoreIntegration/MsiFixture.cs b/src/test/WixToolsetTest.CoreIntegration/MsiFixture.cs
index e26e197f..a8ea0a18 100644
--- a/src/test/WixToolsetTest.CoreIntegration/MsiFixture.cs
+++ b/src/test/WixToolsetTest.CoreIntegration/MsiFixture.cs
@@ -327,56 +327,6 @@ namespace WixToolsetTest.CoreIntegration
327 } 327 }
328 328
329 [Fact] 329 [Fact]
330 public void CanBuildSimpleModule()
331 {
332 var folder = TestData.Get(@"TestData\SimpleModule");
333
334 using (var fs = new DisposableFileSystem())
335 {
336 var intermediateFolder = fs.GetFolder();
337
338 var result = WixRunner.Execute(new[]
339 {
340 "build",
341 Path.Combine(folder, "Module.wxs"),
342 "-loc", Path.Combine(folder, "Module.en-us.wxl"),
343 "-bindpath", Path.Combine(folder, "data"),
344 "-intermediateFolder", intermediateFolder,
345 "-o", Path.Combine(intermediateFolder, @"bin\test.msm")
346 });
347
348 result.AssertSuccess();
349
350 var msmPath = Path.Combine(intermediateFolder, @"bin\test.msm");
351 Assert.True(File.Exists(msmPath));
352 Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\test.wixpdb")));
353
354 var intermediate = Intermediate.Load(Path.Combine(intermediateFolder, @"bin\test.wixpdb"));
355 var section = intermediate.Sections.Single();
356
357 var fileSymbol = section.Symbols.OfType<FileSymbol>().Single();
358 Assert.Equal("filyIq8rqcxxf903Hsn5K9L0SWV73g", fileSymbol.Id.Id);
359 Assert.Equal(Path.Combine(folder, @"data\test.txt"), fileSymbol[FileSymbolFields.Source].AsPath().Path);
360 Assert.Equal(@"test.txt", fileSymbol[FileSymbolFields.Source].PreviousValue.AsPath().Path);
361
362 var data = WindowsInstallerData.Load(Path.Combine(intermediateFolder, @"bin\test.wixpdb"));
363 var fileRows = data.Tables["File"].Rows;
364 Assert.Equal(new[]
365 {
366 "filyIq8rqcxxf903Hsn5K9L0SWV73g.243FB739_4D05_472F_9CFB_EF6B1017B6DE"
367 }, fileRows.Select(r => r.FieldAsString(0)).ToArray());
368
369 var cabPath = Path.Combine(intermediateFolder, "msm-test.cab");
370 Query.ExtractStream(msmPath, "MergeModule.CABinet", cabPath);
371 var files = Query.GetCabinetFiles(cabPath);
372 Assert.Equal(new[]
373 {
374 "filyIq8rqcxxf903Hsn5K9L0SWV73g.243FB739_4D05_472F_9CFB_EF6B1017B6DE"
375 }, files.Select(f => Path.Combine(f.Path, f.Name)).ToArray());
376 }
377 }
378
379 [Fact]
380 public void CanBuildManualUpgrade() 330 public void CanBuildManualUpgrade()
381 { 331 {
382 var folder = TestData.Get(@"TestData\ManualUpgrade"); 332 var folder = TestData.Get(@"TestData\ManualUpgrade");
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/SuppressModularization/Module.en-us.wxl b/src/test/WixToolsetTest.CoreIntegration/TestData/SuppressModularization/Module.en-us.wxl
new file mode 100644
index 00000000..c74e86a7
--- /dev/null
+++ b/src/test/WixToolsetTest.CoreIntegration/TestData/SuppressModularization/Module.en-us.wxl
@@ -0,0 +1,10 @@
1<?xml version="1.0" encoding="utf-8"?>
2
3<!--
4This 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">Example Company</String>
9
10</WixLocalization>
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/SuppressModularization/Module.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/SuppressModularization/Module.wxs
new file mode 100644
index 00000000..f4ce9c48
--- /dev/null
+++ b/src/test/WixToolsetTest.CoreIntegration/TestData/SuppressModularization/Module.wxs
@@ -0,0 +1,10 @@
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="Test" Hidden="true" SuppressModularization="true" />
6 <CustomAction Id="Test" DllEntry="TestEntry" Execute="deferred" Return="check" Impersonate="no" HideTarget="yes" SuppressModularization="yes" BinaryRef="FakeCA" />
7
8 <Binary Id="FakeCA" SourceFile="test.txt" />
9 </Module>
10</Wix>
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/SuppressModularization/data/test.txt b/src/test/WixToolsetTest.CoreIntegration/TestData/SuppressModularization/data/test.txt
new file mode 100644
index 00000000..cd0db0e1
--- /dev/null
+++ b/src/test/WixToolsetTest.CoreIntegration/TestData/SuppressModularization/data/test.txt
@@ -0,0 +1 @@
This is test.txt. \ No newline at end of file