diff options
6 files changed, 68 insertions, 62 deletions
diff --git a/src/WixToolset.Core/Bind/FileResolver.cs b/src/WixToolset.Core/Bind/FileResolver.cs index d11fcadc..ba71c6c9 100644 --- a/src/WixToolset.Core/Bind/FileResolver.cs +++ b/src/WixToolset.Core/Bind/FileResolver.cs | |||
@@ -115,13 +115,14 @@ namespace WixToolset.Core.Bind | |||
115 | } | 115 | } |
116 | else // not a rooted path so let's try applying all the different source resolution options. | 116 | else // not a rooted path so let's try applying all the different source resolution options. |
117 | { | 117 | { |
118 | string bindName = null; | 118 | var bindName = String.Empty; |
119 | var path = source; | 119 | var path = source; |
120 | string pathWithoutSourceDir = null; | 120 | var pathWithoutSourceDir = String.Empty; |
121 | 121 | ||
122 | if (source.StartsWith(BindPathOpenString, StringComparison.Ordinal)) | 122 | if (source.StartsWith(BindPathOpenString, StringComparison.Ordinal)) |
123 | { | 123 | { |
124 | int closeParen = source.IndexOf(')', BindPathOpenString.Length); | 124 | var closeParen = source.IndexOf(')', BindPathOpenString.Length); |
125 | |||
125 | if (-1 != closeParen) | 126 | if (-1 != closeParen) |
126 | { | 127 | { |
127 | bindName = source.Substring(BindPathOpenString.Length, closeParen - BindPathOpenString.Length); | 128 | bindName = source.Substring(BindPathOpenString.Length, closeParen - BindPathOpenString.Length); |
@@ -138,43 +139,48 @@ namespace WixToolset.Core.Bind | |||
138 | 139 | ||
139 | foreach (var bindPath in bindPaths) | 140 | foreach (var bindPath in bindPaths) |
140 | { | 141 | { |
141 | if (!String.IsNullOrEmpty(bindName) && !String.IsNullOrEmpty(bindPath.Name)) | 142 | if (String.IsNullOrEmpty(bindName)) |
142 | { | 143 | { |
143 | if (String.Equals(bindName, bindPath.Name, StringComparison.OrdinalIgnoreCase) && String.IsNullOrEmpty(resolved)) | 144 | if (String.IsNullOrEmpty(bindPath.Name)) |
144 | { | 145 | { |
145 | var filePath = Path.Combine(bindPath.Path, path); | 146 | if (!String.IsNullOrEmpty(pathWithoutSourceDir)) |
146 | |||
147 | checkedPaths.Add(filePath); | ||
148 | if (CheckFileExists(filePath)) | ||
149 | { | 147 | { |
150 | resolved = filePath; | 148 | var filePath = Path.Combine(bindPath.Path, pathWithoutSourceDir); |
149 | |||
150 | checkedPaths.Add(filePath); | ||
151 | if (CheckFileExists(filePath)) | ||
152 | { | ||
153 | resolved = filePath; | ||
154 | } | ||
151 | } | 155 | } |
152 | } | ||
153 | } | ||
154 | else | ||
155 | { | ||
156 | if (!String.IsNullOrEmpty(pathWithoutSourceDir)) | ||
157 | { | ||
158 | var filePath = Path.Combine(bindPath.Path, pathWithoutSourceDir); | ||
159 | 156 | ||
160 | checkedPaths.Add(filePath); | 157 | if (String.IsNullOrEmpty(resolved)) |
161 | if (CheckFileExists(filePath)) | ||
162 | { | 158 | { |
163 | resolved = filePath; | 159 | var filePath = Path.Combine(bindPath.Path, path); |
160 | |||
161 | checkedPaths.Add(filePath); | ||
162 | if (CheckFileExists(filePath)) | ||
163 | { | ||
164 | resolved = filePath; | ||
165 | } | ||
164 | } | 166 | } |
165 | } | 167 | } |
168 | } | ||
169 | else if (bindName.Equals(bindPath.Name, StringComparison.OrdinalIgnoreCase)) | ||
170 | { | ||
171 | var filePath = Path.Combine(bindPath.Path, path); | ||
166 | 172 | ||
167 | if (String.IsNullOrEmpty(resolved)) | 173 | checkedPaths.Add(filePath); |
174 | if (CheckFileExists(filePath)) | ||
168 | { | 175 | { |
169 | var filePath = Path.Combine(bindPath.Path, path); | 176 | resolved = filePath; |
170 | |||
171 | checkedPaths.Add(filePath); | ||
172 | if (CheckFileExists(filePath)) | ||
173 | { | ||
174 | resolved = filePath; | ||
175 | } | ||
176 | } | 177 | } |
177 | } | 178 | } |
179 | |||
180 | if (!String.IsNullOrEmpty(resolved)) | ||
181 | { | ||
182 | break; | ||
183 | } | ||
178 | } | 184 | } |
179 | } | 185 | } |
180 | 186 | ||
diff --git a/src/test/WixToolsetTest.CoreIntegration/BindVariablesFixture.cs b/src/test/WixToolsetTest.CoreIntegration/BindVariablesFixture.cs index 3e9c7aa4..857b84cc 100644 --- a/src/test/WixToolsetTest.CoreIntegration/BindVariablesFixture.cs +++ b/src/test/WixToolsetTest.CoreIntegration/BindVariablesFixture.cs | |||
@@ -13,7 +13,7 @@ namespace WixToolsetTest.CoreIntegration | |||
13 | [Fact] | 13 | [Fact] |
14 | public void CanBuildWithDefaultValue() | 14 | public void CanBuildWithDefaultValue() |
15 | { | 15 | { |
16 | var folder = TestData.Get(@"TestData\BindVariables"); | 16 | var folder = TestData.Get(@"TestData", "BindVariables"); |
17 | 17 | ||
18 | using (var fs = new DisposableFileSystem()) | 18 | using (var fs = new DisposableFileSystem()) |
19 | { | 19 | { |
@@ -34,5 +34,35 @@ namespace WixToolsetTest.CoreIntegration | |||
34 | result.AssertSuccess(); | 34 | result.AssertSuccess(); |
35 | } | 35 | } |
36 | } | 36 | } |
37 | |||
38 | [Fact] | ||
39 | public void CannotBuildWixlibWithBinariesFromMissingNamedBindPaths() | ||
40 | { | ||
41 | var folder = TestData.Get(@"TestData", "WixlibWithBinaries"); | ||
42 | |||
43 | using (var fs = new DisposableFileSystem()) | ||
44 | { | ||
45 | var baseFolder = fs.GetFolder(); | ||
46 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
47 | var wixlibPath = Path.Combine(intermediateFolder, @"test.wixlib"); | ||
48 | |||
49 | var result = WixRunner.Execute(new[] | ||
50 | { | ||
51 | "build", | ||
52 | Path.Combine(folder, "PackageComponents.wxs"), | ||
53 | "-bf", | ||
54 | "-bindpath", Path.Combine(folder, "data"), | ||
55 | // Use names that aren't excluded in default .gitignores. | ||
56 | "-bindpath", $"AlphaBits={Path.Combine(folder, "data", "alpha")}", | ||
57 | "-bindpath", $"PowerBits={Path.Combine(folder, "data", "powerpc")}", | ||
58 | "-bindpath", $"{Path.Combine(folder, "data", "alpha")}", | ||
59 | "-bindpath", $"{Path.Combine(folder, "data", "powerpc")}", | ||
60 | "-intermediateFolder", intermediateFolder, | ||
61 | "-o", wixlibPath, | ||
62 | }); | ||
63 | |||
64 | Assert.Equal(103, result.ExitCode); | ||
65 | } | ||
66 | } | ||
37 | } | 67 | } |
38 | } | 68 | } |
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/alpha/foo.dll b/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/alpha/foo.dll index cd0db0e1..fd36c768 100644 --- a/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/alpha/foo.dll +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/alpha/foo.dll | |||
@@ -1 +1 @@ | |||
This is test.txt. \ No newline at end of file | This is alpha\foo.dll. | ||
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/mips/foo.dll b/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/mips/foo.dll index cd0db0e1..292925c7 100644 --- a/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/mips/foo.dll +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/mips/foo.dll | |||
@@ -1 +1 @@ | |||
This is test.txt. \ No newline at end of file | This is mips\foo.dll. | ||
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/powerpc/foo.dll b/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/powerpc/foo.dll index cd0db0e1..663e9d99 100644 --- a/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/powerpc/foo.dll +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/powerpc/foo.dll | |||
@@ -1 +1 @@ | |||
This is test.txt. \ No newline at end of file | This is powerpc\foo.dll. | ||
diff --git a/src/test/WixToolsetTest.CoreIntegration/WixlibFixture.cs b/src/test/WixToolsetTest.CoreIntegration/WixlibFixture.cs index a60169c7..6ae2c0b8 100644 --- a/src/test/WixToolsetTest.CoreIntegration/WixlibFixture.cs +++ b/src/test/WixToolsetTest.CoreIntegration/WixlibFixture.cs | |||
@@ -88,36 +88,6 @@ namespace WixToolsetTest.CoreIntegration | |||
88 | } | 88 | } |
89 | } | 89 | } |
90 | 90 | ||
91 | [Fact(Skip = "Test demonstrates failure")] | ||
92 | public void CantBuildWixlibWithBinariesFromMissingNamedBindPaths() | ||
93 | { | ||
94 | var folder = TestData.Get(@"TestData\WixlibWithBinaries"); | ||
95 | |||
96 | using (var fs = new DisposableFileSystem()) | ||
97 | { | ||
98 | var baseFolder = fs.GetFolder(); | ||
99 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
100 | var wixlibPath = Path.Combine(intermediateFolder, @"test.wixlib"); | ||
101 | |||
102 | var result = WixRunner.Execute(new[] | ||
103 | { | ||
104 | "build", | ||
105 | Path.Combine(folder, "PackageComponents.wxs"), | ||
106 | "-bf", | ||
107 | "-bindpath", Path.Combine(folder, "data"), | ||
108 | // Use names that aren't excluded in default .gitignores. | ||
109 | "-bindpath", $"AlphaBits={Path.Combine(folder, "data", "alpha")}", | ||
110 | "-bindpath", $"PowerBits={Path.Combine(folder, "data", "powerpc")}", | ||
111 | "-bindpath", $"{Path.Combine(folder, "data", "alpha")}", | ||
112 | "-bindpath", $"{Path.Combine(folder, "data", "powerpc")}", | ||
113 | "-intermediateFolder", intermediateFolder, | ||
114 | "-o", wixlibPath, | ||
115 | }); | ||
116 | |||
117 | Assert.InRange(result.ExitCode, 2, int.MaxValue); | ||
118 | } | ||
119 | } | ||
120 | |||
121 | [Fact] | 91 | [Fact] |
122 | public void CanBuildSingleFileUsingWixlib() | 92 | public void CanBuildSingleFileUsingWixlib() |
123 | { | 93 | { |