@joebigelow / wix-1 / commits / bac3d761

Fix named bind paths.

Bob Arnson committed May 11, 2020 at 17:09 UTC bac3d761d99fb7ae1012f3591baee2dbec115b28
11 files changed +134 -15
src/WixToolset.Core/Bind/FileResolver.cs
+29 -13
@@ -115,7 +115,7 @@ namespace WixToolset.Core.Bind
115 }
116 else // not a rooted path so let's try applying all the different source resolution options.
117 {
118 - string bindName = String.Empty;
118 + string bindName = null;
119 var path = source;
120 string pathWithoutSourceDir = null;
121
@@ -138,25 +138,41 @@ namespace WixToolset.Core.Bind
138
139 foreach (var bindPath in bindPaths)
140 {
141 - if (!String.IsNullOrEmpty(pathWithoutSourceDir))
141 + if (!String.IsNullOrEmpty(bindName) && !String.IsNullOrEmpty(bindPath.Name))
142 {
143 - var filePath = Path.Combine(bindPath.Path, pathWithoutSourceDir);
144 -
145 - checkedPaths.Add(filePath);
146 - if (CheckFileExists(filePath))
143 + if (String.Equals(bindName, bindPath.Name, StringComparison.OrdinalIgnoreCase) && String.IsNullOrEmpty(resolved))
144 {
148 - resolved = filePath;
145 + var filePath = Path.Combine(bindPath.Path, path);
146 +
147 + checkedPaths.Add(filePath);
148 + if (CheckFileExists(filePath))
149 + {
150 + resolved = filePath;
151 + }
152 }
153 }
151 -
152 - if (String.IsNullOrEmpty(resolved))
154 + else
155 {
154 - var filePath = Path.Combine(bindPath.Path, path);
156 + if (!String.IsNullOrEmpty(pathWithoutSourceDir))
157 + {
158 + var filePath = Path.Combine(bindPath.Path, pathWithoutSourceDir);
159
156 - checkedPaths.Add(filePath);
157 - if (CheckFileExists(filePath))
160 + checkedPaths.Add(filePath);
161 + if (CheckFileExists(filePath))
162 + {
163 + resolved = filePath;
164 + }
165 + }
166 +
167 + if (String.IsNullOrEmpty(resolved))
168 {
159 - resolved = filePath;
169 + var filePath = Path.Combine(bindPath.Path, path);
170 +
171 + checkedPaths.Add(filePath);
172 + if (CheckFileExists(filePath))
173 + {
174 + resolved = filePath;
175 + }
176 }
177 }
178 }
src/WixToolset.Core/CommandLine/CommandLine.cs
-2
@@ -21,8 +21,6 @@ namespace WixToolset.Core.CommandLine
21
22 internal class CommandLine : ICommandLine
23 {
24 - private static readonly char[] BindPathSplit = { '=' };
25 -
24 public CommandLine(IWixToolsetServiceProvider serviceProvider)
25 {
26 this.ServiceProvider = serviceProvider;
src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/Package.en-us.wxl new
+11
@@ -0,0 +1,11 @@
1 +<?xml version="1.0" encoding="utf-8"?>
2 +
3 +<!--
4 +This 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="DowngradeError">A newer version of [ProductName] is already installed.</String>
9 + <String Id="FeatureTitle">MsiPackage</String>
10 +
11 +</WixLocalization>
src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/Package.wxs new
+21
@@ -0,0 +1,21 @@
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
3 + <Product Id="*" Name="MsiPackage" Codepage="1252" Language="1033" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a">
4 + <Package InstallerVersion="200" Compressed="no" InstallScope="perMachine" />
5 +
6 + <MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeError)" />
7 + <MediaTemplate />
8 +
9 + <Feature Id="ProductFeature" Title="!(loc.FeatureTitle)">
10 + <ComponentGroupRef Id="ProductComponents" />
11 + </Feature>
12 + </Product>
13 +
14 + <Fragment>
15 + <Directory Id="TARGETDIR" Name="SourceDir">
16 + <Directory Id="ProgramFilesFolder">
17 + <Directory Id="INSTALLFOLDER" Name="MsiPackage" />
18 + </Directory>
19 + </Directory>
20 + </Fragment>
21 +</Wix>
src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/PackageComponents.wxs new
+26
@@ -0,0 +1,26 @@
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
3 + <Fragment>
4 + <Binary Id="FooAlpha" SourceFile="!(bindpath.AlphaBits)foo.dll" />
5 + </Fragment>
6 +
7 + <Fragment>
8 + <Binary Id="FooMips" SourceFile="!(bindpath.MipsBits)foo.dll" />
9 + </Fragment>
10 +
11 + <Fragment>
12 + <Binary Id="FooPowerPC" SourceFile="!(bindpath.PowerBits)foo.dll" />
13 + </Fragment>
14 +
15 + <Fragment>
16 + <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
17 + <Component>
18 + <File Source="test.txt" />
19 + </Component>
20 +
21 + <Component Id="Shared.dll" Shared="yes">
22 + <File Name="Shared.dll" Source="test.txt" />
23 + </Component>
24 + </ComponentGroup>
25 + </Fragment>
26 +</Wix>
src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/alpha/foo.dll new
+1
@@ -0,0 +1 @@
1 +This is test.txt.
\ No newline at end of file
src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/mips/foo.dll new
+1
@@ -0,0 +1 @@
1 +This is test.txt.
\ No newline at end of file
src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/powerpc/foo.dll new
+1
@@ -0,0 +1 @@
1 +This is test.txt.
\ No newline at end of file
src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/test.txt new
+1
@@ -0,0 +1 @@
1 +This is test.txt.
\ No newline at end of file
src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj
+7
@@ -172,6 +172,13 @@
172 <Content Include="TestData\Components\Package.en-us.wxl" CopyToOutputDirectory="PreserveNewest" />
173 <Content Include="TestData\Components\Package.wxs" CopyToOutputDirectory="PreserveNewest" />
174 <Content Include="TestData\Components\PackageComponents.wxs" CopyToOutputDirectory="PreserveNewest" />
175 + <Content Include="TestData\WixlibWithBinaries\data\test.txt" CopyToOutputDirectory="PreserveNewest" />
176 + <Content Include="TestData\WixlibWithBinaries\data\alpha\foo.dll" CopyToOutputDirectory="PreserveNewest" />
177 + <Content Include="TestData\WixlibWithBinaries\data\mips\foo.dll" CopyToOutputDirectory="PreserveNewest" />
178 + <Content Include="TestData\WixlibWithBinaries\data\powerpc\foo.dll" CopyToOutputDirectory="PreserveNewest" />
179 + <Content Include="TestData\WixlibWithBinaries\Package.en-us.wxl" CopyToOutputDirectory="PreserveNewest" />
180 + <Content Include="TestData\WixlibWithBinaries\Package.wxs" CopyToOutputDirectory="PreserveNewest" />
181 + <Content Include="TestData\WixlibWithBinaries\PackageComponents.wxs" CopyToOutputDirectory="PreserveNewest" />
182 </ItemGroup>
183
184 <ItemGroup>
src/test/WixToolsetTest.CoreIntegration/WixlibFixture.cs
+36
@@ -52,6 +52,42 @@ namespace WixToolsetTest.CoreIntegration
52 }
53 }
54
55 + [Fact]
56 + public void CanBuildWixlibWithBinariesFromNamedBindPaths()
57 + {
58 + var folder = TestData.Get(@"TestData\WixlibWithBinaries");
59 +
60 + using (var fs = new DisposableFileSystem())
61 + {
62 + var baseFolder = fs.GetFolder();
63 + var intermediateFolder = Path.Combine(baseFolder, "obj");
64 + var wixlibPath = Path.Combine(intermediateFolder, @"test.wixlib");
65 +
66 + var result = WixRunner.Execute(new[]
67 + {
68 + "build",
69 + Path.Combine(folder, "PackageComponents.wxs"),
70 + "-bf",
71 + "-bindpath", Path.Combine(folder, "data"),
72 + // Use names that aren't excluded in default .gitignores.
73 + "-bindpath", $"AlphaBits={Path.Combine(folder, "data", "alpha")}",
74 + "-bindpath", $"MipsBits={Path.Combine(folder, "data", "mips")}",
75 + "-bindpath", $"PowerBits={Path.Combine(folder, "data", "powerpc")}",
76 + "-intermediateFolder", intermediateFolder,
77 + "-o", wixlibPath,
78 + });
79 +
80 + result.AssertSuccess();
81 +
82 + var wixlib = Intermediate.Load(wixlibPath);
83 + var binaryTuples = wixlib.Sections.SelectMany(s => s.Tuples).OfType<BinaryTuple>().ToList();
84 + Assert.Equal(3, binaryTuples.Count);
85 + Assert.Single(binaryTuples.Where(t => t.Data.Path == "wix-ir/foo.dll"));
86 + Assert.Single(binaryTuples.Where(t => t.Data.Path == "wix-ir/foo.dll-1"));
87 + Assert.Single(binaryTuples.Where(t => t.Data.Path == "wix-ir/foo.dll-2"));
88 + }
89 + }
90 +
91 [Fact]
92 public void CanBuildSingleFileUsingWixlib()
93 {