From 3eb3c26c796984b64365fda077f173af8bf31559 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Mon, 1 Mar 2021 10:14:38 -0800 Subject: Fix handling of suppress modularization Partially fixes wixtoolset/issues#5944 --- .../Bind/ModularizeCommand.cs | 2 +- src/WixToolset.Core/Compiler.cs | 12 ++- src/WixToolset.Core/Compiler_Package.cs | 5 +- .../ModuleFixture.cs | 108 +++++++++++++++++++++ .../WixToolsetTest.CoreIntegration/MsiFixture.cs | 50 ---------- .../SuppressModularization/Module.en-us.wxl | 10 ++ .../TestData/SuppressModularization/Module.wxs | 10 ++ .../TestData/SuppressModularization/data/test.txt | 1 + 8 files changed, 143 insertions(+), 55 deletions(-) create mode 100644 src/test/WixToolsetTest.CoreIntegration/ModuleFixture.cs create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/SuppressModularization/Module.en-us.wxl create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/SuppressModularization/Module.wxs create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/SuppressModularization/data/test.txt 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 this.ModularizationSuffix = modularizationSuffix; // Gather all the unique suppress modularization identifiers. - this.SuppressModularizationIdentifiers = new HashSet(suppressSymbols.Select(s => s.Id.Id)); + this.SuppressModularizationIdentifiers = new HashSet(suppressSymbols.Select(s => s.SuppressIdentifier)); } 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 if (!this.Core.EncounteredError) { - var symbol = this.Core.AddSymbol(new BinarySymbol(sourceLineNumbers, id) + this.Core.AddSymbol(new BinarySymbol(sourceLineNumbers, id) { Data = new IntermediateFieldPathValue { Path = sourceFile } }); if (YesNoType.Yes == suppressModularization) { - this.Core.AddSymbol(new WixSuppressModularizationSymbol(sourceLineNumbers, id)); + this.Core.AddSymbol(new WixSuppressModularizationSymbol(sourceLineNumbers) + { + SuppressIdentifier = id.Id + }); } } @@ -3502,7 +3505,10 @@ namespace WixToolset.Core if (YesNoType.Yes == suppressModularization) { - this.Core.AddSymbol(new WixSuppressModularizationSymbol(sourceLineNumbers, id)); + this.Core.AddSymbol(new WixSuppressModularizationSymbol(sourceLineNumbers) + { + SuppressIdentifier = id.Id + }); } } } 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 { this.Core.Write(WarningMessages.PropertyModularizationSuppressed(sourceLineNumbers)); - this.Core.AddSymbol(new WixSuppressModularizationSymbol(sourceLineNumbers, id)); + this.Core.AddSymbol(new WixSuppressModularizationSymbol(sourceLineNumbers) + { + SuppressIdentifier = id.Id + }); } } 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 @@ +// 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. + +namespace WixToolsetTest.CoreIntegration +{ + using System; + using System.IO; + using System.Linq; + using WixBuildTools.TestSupport; + using WixToolset.Core.TestPackage; + using WixToolset.Data; + using WixToolset.Data.Symbols; + using WixToolset.Data.WindowsInstaller; + using Xunit; + + public class ModuleFixture + { + [Fact] + public void CanBuildSimpleModule() + { + var folder = TestData.Get(@"TestData\SimpleModule"); + + using (var fs = new DisposableFileSystem()) + { + var intermediateFolder = fs.GetFolder(); + + var result = WixRunner.Execute(new[] + { + "build", + Path.Combine(folder, "Module.wxs"), + "-loc", Path.Combine(folder, "Module.en-us.wxl"), + "-bindpath", Path.Combine(folder, "data"), + "-intermediateFolder", intermediateFolder, + "-o", Path.Combine(intermediateFolder, @"bin\test.msm") + }); + + result.AssertSuccess(); + + var msmPath = Path.Combine(intermediateFolder, @"bin\test.msm"); + Assert.True(File.Exists(msmPath)); + Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\test.wixpdb"))); + + var intermediate = Intermediate.Load(Path.Combine(intermediateFolder, @"bin\test.wixpdb")); + var section = intermediate.Sections.Single(); + + var dirSymbols = section.Symbols.OfType().OrderBy(d => d.Id.Id).ToList(); + WixAssert.CompareLineByLine(new[] + { + "MergeRedirectFolder\tTARGETDIR\t.", + "TARGETDIR\t\tSourceDir" + }, dirSymbols.Select(d => String.Join("\t", d.Id.Id, d.ParentDirectoryRef, d.Name)).ToArray()); + + var fileSymbol = section.Symbols.OfType().Single(); + Assert.Equal("filyIq8rqcxxf903Hsn5K9L0SWV73g", fileSymbol.Id.Id); + Assert.Equal(Path.Combine(folder, @"data\test.txt"), fileSymbol[FileSymbolFields.Source].AsPath().Path); + Assert.Equal(@"test.txt", fileSymbol[FileSymbolFields.Source].PreviousValue.AsPath().Path); + + var data = WindowsInstallerData.Load(Path.Combine(intermediateFolder, @"bin\test.wixpdb")); + var fileRows = data.Tables["File"].Rows; + Assert.Equal(new[] + { + "filyIq8rqcxxf903Hsn5K9L0SWV73g.243FB739_4D05_472F_9CFB_EF6B1017B6DE" + }, fileRows.Select(r => r.FieldAsString(0)).ToArray()); + + var cabPath = Path.Combine(intermediateFolder, "msm-test.cab"); + Query.ExtractStream(msmPath, "MergeModule.CABinet", cabPath); + var files = Query.GetCabinetFiles(cabPath); + Assert.Equal(new[] + { + "filyIq8rqcxxf903Hsn5K9L0SWV73g.243FB739_4D05_472F_9CFB_EF6B1017B6DE" + }, files.Select(f => Path.Combine(f.Path, f.Name)).ToArray()); + } + } + + [Fact] + public void CanSuppressModularization() + { + var folder = TestData.Get(@"TestData\SuppressModularization"); + + using (var fs = new DisposableFileSystem()) + { + var intermediateFolder = fs.GetFolder(); + + var result = WixRunner.Execute(new[] + { + "build", + Path.Combine(folder, "Module.wxs"), + "-loc", Path.Combine(folder, "Module.en-us.wxl"), + "-bindpath", Path.Combine(folder, "data"), + "-intermediateFolder", intermediateFolder, + "-sw1079", + "-sw1086", + "-o", Path.Combine(intermediateFolder, @"bin\test.msm") + }); + + result.AssertSuccess(); + + var msmPath = Path.Combine(intermediateFolder, @"bin\test.msm"); + + var rows = Query.QueryDatabase(msmPath, new[] { "CustomAction", "Property" }); + WixAssert.CompareLineByLine(new[] + { + "CustomAction:Test\t11265\tFakeCA.243FB739_4D05_472F_9CFB_EF6B1017B6DE\tTestEntry\t", + "Property:MsiHiddenProperties\tTest" + }, rows); + } + } + } +} 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 @@ -326,56 +326,6 @@ namespace WixToolsetTest.CoreIntegration } } - [Fact] - public void CanBuildSimpleModule() - { - var folder = TestData.Get(@"TestData\SimpleModule"); - - using (var fs = new DisposableFileSystem()) - { - var intermediateFolder = fs.GetFolder(); - - var result = WixRunner.Execute(new[] - { - "build", - Path.Combine(folder, "Module.wxs"), - "-loc", Path.Combine(folder, "Module.en-us.wxl"), - "-bindpath", Path.Combine(folder, "data"), - "-intermediateFolder", intermediateFolder, - "-o", Path.Combine(intermediateFolder, @"bin\test.msm") - }); - - result.AssertSuccess(); - - var msmPath = Path.Combine(intermediateFolder, @"bin\test.msm"); - Assert.True(File.Exists(msmPath)); - Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\test.wixpdb"))); - - var intermediate = Intermediate.Load(Path.Combine(intermediateFolder, @"bin\test.wixpdb")); - var section = intermediate.Sections.Single(); - - var fileSymbol = section.Symbols.OfType().Single(); - Assert.Equal("filyIq8rqcxxf903Hsn5K9L0SWV73g", fileSymbol.Id.Id); - Assert.Equal(Path.Combine(folder, @"data\test.txt"), fileSymbol[FileSymbolFields.Source].AsPath().Path); - Assert.Equal(@"test.txt", fileSymbol[FileSymbolFields.Source].PreviousValue.AsPath().Path); - - var data = WindowsInstallerData.Load(Path.Combine(intermediateFolder, @"bin\test.wixpdb")); - var fileRows = data.Tables["File"].Rows; - Assert.Equal(new[] - { - "filyIq8rqcxxf903Hsn5K9L0SWV73g.243FB739_4D05_472F_9CFB_EF6B1017B6DE" - }, fileRows.Select(r => r.FieldAsString(0)).ToArray()); - - var cabPath = Path.Combine(intermediateFolder, "msm-test.cab"); - Query.ExtractStream(msmPath, "MergeModule.CABinet", cabPath); - var files = Query.GetCabinetFiles(cabPath); - Assert.Equal(new[] - { - "filyIq8rqcxxf903Hsn5K9L0SWV73g.243FB739_4D05_472F_9CFB_EF6B1017B6DE" - }, files.Select(f => Path.Combine(f.Path, f.Name)).ToArray()); - } - } - [Fact] public void CanBuildManualUpgrade() { 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 @@ + + + + + + Example Company + + 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 @@ + + + + + + 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 -- cgit v1.2.3-55-g6feb