From 678c92c50c6fb7aa9a093f0d74d4f92742abd5e8 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Mon, 15 Jun 2020 16:07:45 -0700 Subject: Reorganize media assignment to correctly place facade order optimization --- .../WixToolsetTest.CoreIntegration/CabFixture.cs | 71 ++++++++++++++++++++++ .../MultiFileCompressed/PackageComponents.wxs | 4 +- 2 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 src/test/WixToolsetTest.CoreIntegration/CabFixture.cs (limited to 'src/test/WixToolsetTest.CoreIntegration') diff --git a/src/test/WixToolsetTest.CoreIntegration/CabFixture.cs b/src/test/WixToolsetTest.CoreIntegration/CabFixture.cs new file mode 100644 index 00000000..79471554 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/CabFixture.cs @@ -0,0 +1,71 @@ +// 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 Xunit; + + public class CabFixture + { + [Fact] + public void CabinetFilesSequencedCorrectly() + { + var folder = TestData.Get(@"TestData\MultiFileCompressed"); + + 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"), + Path.Combine(folder, "PackageComponents.wxs"), + "-d", "MediaTemplateCompressionLevel", + "-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, 2 }, fileRows.Select(f => f.Sequence).ToArray()); + Assert.Equal(new[] { "test.txt", "Notepad.exe" }, 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) + { + row = row.Substring("File:".Length); + + var split = row.Split('\t'); + this.Id = split[0]; + this.Name = split[2]; + this.Sequence = Convert.ToInt32(split[7]); + } + + public string Id { get; set; } + + public string Name { get; set; } + + public int Sequence { get; set; } + } + } +} diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/MultiFileCompressed/PackageComponents.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/MultiFileCompressed/PackageComponents.wxs index d65a07df..82797ebe 100644 --- a/src/test/WixToolsetTest.CoreIntegration/TestData/MultiFileCompressed/PackageComponents.wxs +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/MultiFileCompressed/PackageComponents.wxs @@ -3,10 +3,10 @@ - + - + -- cgit v1.2.3-55-g6feb