From 461350c09839f1e59fb3dafe1a67e74bf152f803 Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Mon, 22 Jun 2020 19:35:34 -0400 Subject: If no Media or MediaTemplate is present, default to a MediaTemplate. --- .../Bind/AssignMediaCommand.cs | 12 ++++++++ src/WixToolset.Core/Compiler.cs | 9 ------ src/WixToolset.Core/Linker.cs | 1 - .../WixToolsetTest.CoreIntegration/CabFixture.cs | 36 ++++++++++++++++++++++ .../WixToolsetTest.CoreIntegration/MsiFixture.cs | 4 +-- .../TestData/Assembly/Package.wxs | 1 - .../TestData/BadIf/Package.wxs | 1 - .../TestData/ComplexExampleExtension/Package.wxs | 1 - .../TestData/Components/Package.wxs | 1 - .../TestData/ErrorsInUI/Package.wxs | 1 - .../TestData/ExampleExtension/Package.wxs | 1 - .../TestData/ForEach/Package.wxs | 1 - .../TestData/IncludePath/Package.wxs | 1 - .../TestData/InstanceTransform/Package.wxs | 1 - .../TestData/ManualUpgrade/Package.wxs | 2 -- .../TestData/MultiFileCompressed/Package.wxs | 3 +- .../MultiFileCompressed/PackageComponents.wxs | 4 +-- .../TestData/OverridableActions/Package.wxs | 1 - .../TestData/PatchFamilyFilter/Package.wxs | 1 - .../ProductWithComponentGroupRef/Product.wxs | 1 - .../TestData/ProgId/Package.wxs | 1 - .../TestData/SetProperty/Package.wxs | 1 - .../TestData/SimpleMerge/Package.wxs | 3 +- .../TestData/SingleFile/Package.wxs | 1 - .../TestData/Variables/Package.wxs | 1 - .../TestData/Wixipl/Package.wxs | 1 - .../TestData/WixlibWithBinaries/Package.wxs | 1 - 27 files changed, 55 insertions(+), 37 deletions(-) diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/AssignMediaCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/AssignMediaCommand.cs index b75956b4..773b3225 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/AssignMediaCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/AssignMediaCommand.cs @@ -59,6 +59,18 @@ namespace WixToolset.Core.WindowsInstaller.Bind throw new WixException(ErrorMessages.MediaTableCollision(null)); } + // If neither tuple is authored, default to a media template. + if (SectionType.Product == this.Section.Type && mediaTemplateTuples.Count == 0 && mediaTuples.Count == 0) + { + var mediaTemplate = new WixMediaTemplateTuple() + { + CabinetTemplate = "cab{0}.cab", + }; + + this.Section.AddTuple(mediaTemplate); + mediaTemplateTuples.Add(mediaTemplate); + } + // When building merge module, all the files go to "#MergeModule.CABinet". if (SectionType.Module == this.Section.Type) { diff --git a/src/WixToolset.Core/Compiler.cs b/src/WixToolset.Core/Compiler.cs index 9681cb3f..ae7f7624 100644 --- a/src/WixToolset.Core/Compiler.cs +++ b/src/WixToolset.Core/Compiler.cs @@ -5870,7 +5870,6 @@ namespace WixToolset.Core } } - if (!this.Core.EncounteredError) { var patchAttributes = PatchAttributeType.None; @@ -5957,8 +5956,6 @@ namespace WixToolset.Core } } - this.Core.CreateSimpleReference(sourceLineNumbers, TupleDefinitions.Media, diskId.ToString(CultureInfo.InvariantCulture.NumberFormat)); - // If this component does not have a companion file this file is a possible keypath. possibleKeyPath = null; if (null == companionFile) @@ -7677,12 +7674,6 @@ namespace WixToolset.Core this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "SourceFile")); } - if (CompilerConstants.IntegerNotSet == diskId) - { - this.Core.Write(ErrorMessages.ExpectedAttributeInElementOrParent(sourceLineNumbers, node.Name.LocalName, "DiskId", "Directory")); - diskId = CompilerConstants.IllegalInteger; - } - foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) diff --git a/src/WixToolset.Core/Linker.cs b/src/WixToolset.Core/Linker.cs index fb1b2488..cbdb46d0 100644 --- a/src/WixToolset.Core/Linker.cs +++ b/src/WixToolset.Core/Linker.cs @@ -140,7 +140,6 @@ namespace WixToolset.Core #endif // First find the entry section and while processing all sections load all the symbols from all of the sections. - // sections.FindEntrySectionAndLoadSymbols(false, this, expectedOutputType, out entrySection, out allSymbols); var find = new FindEntrySectionAndLoadSymbolsCommand(this.Messaging, sections, this.Context.ExpectedOutputType); find.Execute(); diff --git a/src/test/WixToolsetTest.CoreIntegration/CabFixture.cs b/src/test/WixToolsetTest.CoreIntegration/CabFixture.cs index 79471554..5aef148e 100644 --- a/src/test/WixToolsetTest.CoreIntegration/CabFixture.cs +++ b/src/test/WixToolsetTest.CoreIntegration/CabFixture.cs @@ -49,6 +49,42 @@ namespace WixToolsetTest.CoreIntegration } } + [Fact(Skip = "Sequence number of file from merge module is 0 but should be 1.")] + public void CabinetFilesSequencedCorrectlyUsingMergeModule() + { + var folder = TestData.Get(@"TestData\SimpleMerge"); + + using (var fs = new DisposableFileSystem()) + { + var baseFolder = fs.GetFolder(); + var intermediateFolder = Path.Combine(baseFolder, "obj"); + var msiPath = Path.Combine(baseFolder, @"bin\test.msi"); + var cabPath = Path.Combine(baseFolder, @"bin\cab1.cab"); + + var result = WixRunner.Execute(new[] + { + "build", + Path.Combine(folder, "Package.wxs"), + "-loc", Path.Combine(folder, "Package.en-us.wxl"), + "-bindpath", Path.Combine(folder, ".data"), + "-intermediateFolder", intermediateFolder, + "-o", msiPath + }); + + result.AssertSuccess(); + Assert.True(File.Exists(cabPath)); + + var fileTable = Query.QueryDatabase(msiPath, new[] { "File" }); + var fileRows = fileTable.Select(r => new FileRow(r)).OrderBy(f => f.Sequence).ToList(); + + Assert.Equal(new[] { 1 }, fileRows.Select(f => f.Sequence).ToArray()); + Assert.Equal(new[] { "test.txt" }, fileRows.Select(f => f.Name).ToArray()); + + var files = Query.GetCabinetFiles(cabPath); + Assert.Equal(fileRows.Select(f => f.Id).ToArray(), files.Select(f => f.Name).ToArray()); + } + } + private class FileRow { public FileRow(string row) diff --git a/src/test/WixToolsetTest.CoreIntegration/MsiFixture.cs b/src/test/WixToolsetTest.CoreIntegration/MsiFixture.cs index 69258ae4..fbfebc5b 100644 --- a/src/test/WixToolsetTest.CoreIntegration/MsiFixture.cs +++ b/src/test/WixToolsetTest.CoreIntegration/MsiFixture.cs @@ -164,7 +164,6 @@ namespace WixToolsetTest.CoreIntegration "build", Path.Combine(folder, "Package.wxs"), Path.Combine(folder, "PackageComponents.wxs"), - "-d", "MediaTemplateCompressionLevel", "-loc", Path.Combine(folder, "Package.en-us.wxl"), "-bindpath", Path.Combine(folder, "data"), "-intermediateFolder", intermediateFolder, @@ -174,7 +173,8 @@ namespace WixToolsetTest.CoreIntegration result.AssertSuccess(); Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\test.msi"))); - Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\cab1.cab"))); + Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\example1.cab"))); + Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\example2.cab"))); Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\test.wixpdb"))); } } diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/Assembly/Package.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/Assembly/Package.wxs index d9a2a34e..dbce4c71 100644 --- a/src/test/WixToolsetTest.CoreIntegration/TestData/Assembly/Package.wxs +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/Assembly/Package.wxs @@ -4,7 +4,6 @@ - diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/BadIf/Package.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/BadIf/Package.wxs index 73577ce5..c1cf55c2 100644 --- a/src/test/WixToolsetTest.CoreIntegration/TestData/BadIf/Package.wxs +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/BadIf/Package.wxs @@ -4,7 +4,6 @@ - diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/ComplexExampleExtension/Package.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/ComplexExampleExtension/Package.wxs index 0e8e9795..f3dd9a02 100644 --- a/src/test/WixToolsetTest.CoreIntegration/TestData/ComplexExampleExtension/Package.wxs +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/ComplexExampleExtension/Package.wxs @@ -4,7 +4,6 @@ - diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/Components/Package.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/Components/Package.wxs index 6da3dcbe..28d564e2 100644 --- a/src/test/WixToolsetTest.CoreIntegration/TestData/Components/Package.wxs +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/Components/Package.wxs @@ -4,7 +4,6 @@ - diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/ErrorsInUI/Package.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/ErrorsInUI/Package.wxs index a4c01d7e..59eeb027 100644 --- a/src/test/WixToolsetTest.CoreIntegration/TestData/ErrorsInUI/Package.wxs +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/ErrorsInUI/Package.wxs @@ -4,7 +4,6 @@ - diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/ExampleExtension/Package.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/ExampleExtension/Package.wxs index bff5f609..f20f5f73 100644 --- a/src/test/WixToolsetTest.CoreIntegration/TestData/ExampleExtension/Package.wxs +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/ExampleExtension/Package.wxs @@ -4,7 +4,6 @@ - diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/ForEach/Package.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/ForEach/Package.wxs index 4bc7e2a4..3bd14fbb 100644 --- a/src/test/WixToolsetTest.CoreIntegration/TestData/ForEach/Package.wxs +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/ForEach/Package.wxs @@ -4,7 +4,6 @@ - diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/IncludePath/Package.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/IncludePath/Package.wxs index 8deab961..59c8b2b3 100644 --- a/src/test/WixToolsetTest.CoreIntegration/TestData/IncludePath/Package.wxs +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/IncludePath/Package.wxs @@ -5,7 +5,6 @@ - diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/InstanceTransform/Package.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/InstanceTransform/Package.wxs index 9c529668..e55b3ec6 100644 --- a/src/test/WixToolsetTest.CoreIntegration/TestData/InstanceTransform/Package.wxs +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/InstanceTransform/Package.wxs @@ -4,7 +4,6 @@ - diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/ManualUpgrade/Package.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/ManualUpgrade/Package.wxs index 38125b57..025aaaa3 100644 --- a/src/test/WixToolsetTest.CoreIntegration/TestData/ManualUpgrade/Package.wxs +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/ManualUpgrade/Package.wxs @@ -12,8 +12,6 @@ - - diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/MultiFileCompressed/Package.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/MultiFileCompressed/Package.wxs index 0b743c81..44b8c2b5 100644 --- a/src/test/WixToolsetTest.CoreIntegration/TestData/MultiFileCompressed/Package.wxs +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/MultiFileCompressed/Package.wxs @@ -6,7 +6,8 @@ - + + diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/MultiFileCompressed/PackageComponents.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/MultiFileCompressed/PackageComponents.wxs index 82797ebe..1a040fa3 100644 --- a/src/test/WixToolsetTest.CoreIntegration/TestData/MultiFileCompressed/PackageComponents.wxs +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/MultiFileCompressed/PackageComponents.wxs @@ -3,10 +3,10 @@ - + - + diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/OverridableActions/Package.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/OverridableActions/Package.wxs index db773d17..cc873a62 100644 --- a/src/test/WixToolsetTest.CoreIntegration/TestData/OverridableActions/Package.wxs +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/OverridableActions/Package.wxs @@ -5,7 +5,6 @@ - diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/PatchFamilyFilter/Package.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/PatchFamilyFilter/Package.wxs index 2657797f..4baeb85b 100644 --- a/src/test/WixToolsetTest.CoreIntegration/TestData/PatchFamilyFilter/Package.wxs +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/PatchFamilyFilter/Package.wxs @@ -5,7 +5,6 @@ - diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/ProductWithComponentGroupRef/Product.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/ProductWithComponentGroupRef/Product.wxs index e0e5345a..b2f22b7d 100644 --- a/src/test/WixToolsetTest.CoreIntegration/TestData/ProductWithComponentGroupRef/Product.wxs +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/ProductWithComponentGroupRef/Product.wxs @@ -4,7 +4,6 @@ - diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/ProgId/Package.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/ProgId/Package.wxs index d4b53cd6..388a271e 100644 --- a/src/test/WixToolsetTest.CoreIntegration/TestData/ProgId/Package.wxs +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/ProgId/Package.wxs @@ -4,7 +4,6 @@ - diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/SetProperty/Package.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/SetProperty/Package.wxs index eb907569..879fad35 100644 --- a/src/test/WixToolsetTest.CoreIntegration/TestData/SetProperty/Package.wxs +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/SetProperty/Package.wxs @@ -4,7 +4,6 @@ - diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/SimpleMerge/Package.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/SimpleMerge/Package.wxs index 303e2ba8..b04c5d1a 100644 --- a/src/test/WixToolsetTest.CoreIntegration/TestData/SimpleMerge/Package.wxs +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/SimpleMerge/Package.wxs @@ -4,7 +4,6 @@ - @@ -16,7 +15,7 @@ - + diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/SingleFile/Package.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/SingleFile/Package.wxs index 6da3dcbe..28d564e2 100644 --- a/src/test/WixToolsetTest.CoreIntegration/TestData/SingleFile/Package.wxs +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/SingleFile/Package.wxs @@ -4,7 +4,6 @@ - diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/Variables/Package.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/Variables/Package.wxs index 57c24f57..8d49c30e 100644 --- a/src/test/WixToolsetTest.CoreIntegration/TestData/Variables/Package.wxs +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/Variables/Package.wxs @@ -17,7 +17,6 @@ - diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/Wixipl/Package.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/Wixipl/Package.wxs index 15807698..00a80fca 100644 --- a/src/test/WixToolsetTest.CoreIntegration/TestData/Wixipl/Package.wxs +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/Wixipl/Package.wxs @@ -4,7 +4,6 @@ - diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/Package.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/Package.wxs index 85dcb695..4c36f3cc 100644 --- a/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/Package.wxs +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/Package.wxs @@ -4,7 +4,6 @@ - -- cgit v1.2.3-55-g6feb