From bac3d761d99fb7ae1012f3591baee2dbec115b28 Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Mon, 11 May 2020 17:09:47 -0400 Subject: Fix named bind paths. --- src/WixToolset.Core/Bind/FileResolver.cs | 42 +++++++++++++++------- src/WixToolset.Core/CommandLine/CommandLine.cs | 2 -- .../TestData/WixlibWithBinaries/Package.en-us.wxl | 11 ++++++ .../TestData/WixlibWithBinaries/Package.wxs | 21 +++++++++++ .../WixlibWithBinaries/PackageComponents.wxs | 26 ++++++++++++++ .../TestData/WixlibWithBinaries/data/alpha/foo.dll | 1 + .../TestData/WixlibWithBinaries/data/mips/foo.dll | 1 + .../WixlibWithBinaries/data/powerpc/foo.dll | 1 + .../TestData/WixlibWithBinaries/data/test.txt | 1 + .../WixToolsetTest.CoreIntegration.csproj | 7 ++++ .../WixlibFixture.cs | 36 +++++++++++++++++++ 11 files changed, 134 insertions(+), 15 deletions(-) create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/Package.en-us.wxl create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/Package.wxs create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/PackageComponents.wxs create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/alpha/foo.dll create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/mips/foo.dll create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/powerpc/foo.dll create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/test.txt diff --git a/src/WixToolset.Core/Bind/FileResolver.cs b/src/WixToolset.Core/Bind/FileResolver.cs index b1676fad..6bc5a676 100644 --- a/src/WixToolset.Core/Bind/FileResolver.cs +++ b/src/WixToolset.Core/Bind/FileResolver.cs @@ -115,7 +115,7 @@ namespace WixToolset.Core.Bind } else // not a rooted path so let's try applying all the different source resolution options. { - string bindName = String.Empty; + string bindName = null; var path = source; string pathWithoutSourceDir = null; @@ -138,25 +138,41 @@ namespace WixToolset.Core.Bind foreach (var bindPath in bindPaths) { - if (!String.IsNullOrEmpty(pathWithoutSourceDir)) + if (!String.IsNullOrEmpty(bindName) && !String.IsNullOrEmpty(bindPath.Name)) { - var filePath = Path.Combine(bindPath.Path, pathWithoutSourceDir); - - checkedPaths.Add(filePath); - if (CheckFileExists(filePath)) + if (String.Equals(bindName, bindPath.Name, StringComparison.OrdinalIgnoreCase) && String.IsNullOrEmpty(resolved)) { - resolved = filePath; + var filePath = Path.Combine(bindPath.Path, path); + + checkedPaths.Add(filePath); + if (CheckFileExists(filePath)) + { + resolved = filePath; + } } } - - if (String.IsNullOrEmpty(resolved)) + else { - var filePath = Path.Combine(bindPath.Path, path); + if (!String.IsNullOrEmpty(pathWithoutSourceDir)) + { + var filePath = Path.Combine(bindPath.Path, pathWithoutSourceDir); - checkedPaths.Add(filePath); - if (CheckFileExists(filePath)) + checkedPaths.Add(filePath); + if (CheckFileExists(filePath)) + { + resolved = filePath; + } + } + + if (String.IsNullOrEmpty(resolved)) { - resolved = filePath; + var filePath = Path.Combine(bindPath.Path, path); + + checkedPaths.Add(filePath); + if (CheckFileExists(filePath)) + { + resolved = filePath; + } } } } diff --git a/src/WixToolset.Core/CommandLine/CommandLine.cs b/src/WixToolset.Core/CommandLine/CommandLine.cs index 683d1f5a..79f5d5bc 100644 --- a/src/WixToolset.Core/CommandLine/CommandLine.cs +++ b/src/WixToolset.Core/CommandLine/CommandLine.cs @@ -21,8 +21,6 @@ namespace WixToolset.Core.CommandLine internal class CommandLine : ICommandLine { - private static readonly char[] BindPathSplit = { '=' }; - public CommandLine(IWixToolsetServiceProvider serviceProvider) { this.ServiceProvider = serviceProvider; diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/Package.en-us.wxl b/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/Package.en-us.wxl new file mode 100644 index 00000000..38c12ac1 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/Package.en-us.wxl @@ -0,0 +1,11 @@ + + + + + + A newer version of [ProductName] is already installed. + MsiPackage + + diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/Package.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/Package.wxs new file mode 100644 index 00000000..85dcb695 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/Package.wxs @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/PackageComponents.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/PackageComponents.wxs new file mode 100644 index 00000000..7d1a4ae1 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/PackageComponents.wxs @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/alpha/foo.dll b/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/alpha/foo.dll new file mode 100644 index 00000000..cd0db0e1 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/alpha/foo.dll @@ -0,0 +1 @@ +This is test.txt. \ No newline at end of file diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/mips/foo.dll b/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/mips/foo.dll new file mode 100644 index 00000000..cd0db0e1 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/mips/foo.dll @@ -0,0 +1 @@ +This is test.txt. \ No newline at end of file diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/powerpc/foo.dll b/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/powerpc/foo.dll new file mode 100644 index 00000000..cd0db0e1 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/powerpc/foo.dll @@ -0,0 +1 @@ +This is test.txt. \ No newline at end of file diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/test.txt b/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/test.txt new file mode 100644 index 00000000..cd0db0e1 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/test.txt @@ -0,0 +1 @@ +This is test.txt. \ No newline at end of file diff --git a/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj b/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj index 60cbde85..3989699d 100644 --- a/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj +++ b/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj @@ -172,6 +172,13 @@ + + + + + + + diff --git a/src/test/WixToolsetTest.CoreIntegration/WixlibFixture.cs b/src/test/WixToolsetTest.CoreIntegration/WixlibFixture.cs index f63d1144..63771248 100644 --- a/src/test/WixToolsetTest.CoreIntegration/WixlibFixture.cs +++ b/src/test/WixToolsetTest.CoreIntegration/WixlibFixture.cs @@ -52,6 +52,42 @@ namespace WixToolsetTest.CoreIntegration } } + [Fact] + public void CanBuildWixlibWithBinariesFromNamedBindPaths() + { + var folder = TestData.Get(@"TestData\WixlibWithBinaries"); + + using (var fs = new DisposableFileSystem()) + { + var baseFolder = fs.GetFolder(); + var intermediateFolder = Path.Combine(baseFolder, "obj"); + var wixlibPath = Path.Combine(intermediateFolder, @"test.wixlib"); + + var result = WixRunner.Execute(new[] + { + "build", + Path.Combine(folder, "PackageComponents.wxs"), + "-bf", + "-bindpath", Path.Combine(folder, "data"), + // Use names that aren't excluded in default .gitignores. + "-bindpath", $"AlphaBits={Path.Combine(folder, "data", "alpha")}", + "-bindpath", $"MipsBits={Path.Combine(folder, "data", "mips")}", + "-bindpath", $"PowerBits={Path.Combine(folder, "data", "powerpc")}", + "-intermediateFolder", intermediateFolder, + "-o", wixlibPath, + }); + + result.AssertSuccess(); + + var wixlib = Intermediate.Load(wixlibPath); + var binaryTuples = wixlib.Sections.SelectMany(s => s.Tuples).OfType().ToList(); + Assert.Equal(3, binaryTuples.Count); + Assert.Single(binaryTuples.Where(t => t.Data.Path == "wix-ir/foo.dll")); + Assert.Single(binaryTuples.Where(t => t.Data.Path == "wix-ir/foo.dll-1")); + Assert.Single(binaryTuples.Where(t => t.Data.Path == "wix-ir/foo.dll-2")); + } + } + [Fact] public void CanBuildSingleFileUsingWixlib() { -- cgit v1.2.3-55-g6feb