aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/GenerateDatabaseCommand.cs4
-rw-r--r--src/WixToolset.Core/Bind/FileResolver.cs36
-rw-r--r--src/WixToolset.Core/Bind/ResolveFieldsCommand.cs5
-rw-r--r--src/WixToolset.Core/Bind/TransferFilesCommand.cs2
-rw-r--r--src/WixToolset.Core/CommandLine/CommandLineParser.cs18
-rw-r--r--src/WixToolset.Core/Preprocessor.cs2
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/MsiFixture.cs35
7 files changed, 80 insertions, 22 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/GenerateDatabaseCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/GenerateDatabaseCommand.cs
index 1a77b84e..3ab3b601 100644
--- a/src/WixToolset.Core.WindowsInstaller/Bind/GenerateDatabaseCommand.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Bind/GenerateDatabaseCommand.cs
@@ -334,10 +334,10 @@ namespace WixToolset.Core.WindowsInstaller.Bind
334 db.Commit(); 334 db.Commit();
335 } 335 }
336 } 336 }
337 catch (IOException) 337 catch (IOException e)
338 { 338 {
339 // TODO: this error message doesn't seem specific enough 339 // TODO: this error message doesn't seem specific enough
340 throw new WixFileNotFoundException(new SourceLineNumber(this.OutputPath), this.OutputPath); 340 throw new WixException(ErrorMessages.FileNotFound(new SourceLineNumber(this.OutputPath), this.OutputPath), e);
341 } 341 }
342 } 342 }
343 343
diff --git a/src/WixToolset.Core/Bind/FileResolver.cs b/src/WixToolset.Core/Bind/FileResolver.cs
index 86075e46..01dfe36c 100644
--- a/src/WixToolset.Core/Bind/FileResolver.cs
+++ b/src/WixToolset.Core/Bind/FileResolver.cs
@@ -43,17 +43,24 @@ namespace WixToolset.Core.Bind
43 43
44 public string Resolve(SourceLineNumber sourceLineNumbers, IntermediateTupleDefinition tupleDefinition, string source) 44 public string Resolve(SourceLineNumber sourceLineNumbers, IntermediateTupleDefinition tupleDefinition, string source)
45 { 45 {
46 var checkedPaths = new List<string>();
47
46 foreach (var extension in this.LibrarianExtensions) 48 foreach (var extension in this.LibrarianExtensions)
47 { 49 {
48 var resolved = extension.Resolve(sourceLineNumbers, tupleDefinition, source); 50 var resolved = extension.ResolveFile(sourceLineNumbers, tupleDefinition, source);
51
52 if (resolved?.CheckedPaths != null)
53 {
54 checkedPaths.AddRange(resolved.CheckedPaths);
55 }
49 56
50 if (null != resolved) 57 if (!String.IsNullOrEmpty(resolved?.Path))
51 { 58 {
52 return resolved; 59 return resolved?.Path;
53 } 60 }
54 } 61 }
55 62
56 return this.ResolveUsingBindPaths(source, tupleDefinition, sourceLineNumbers, BindStage.Normal); 63 return this.MustResolveUsingBindPaths(source, tupleDefinition, sourceLineNumbers, BindStage.Normal, checkedPaths);
57 } 64 }
58 65
59 /// <summary> 66 /// <summary>
@@ -66,24 +73,32 @@ namespace WixToolset.Core.Bind
66 /// <returns>Should return a valid path for the stream to be imported.</returns> 73 /// <returns>Should return a valid path for the stream to be imported.</returns>
67 public string ResolveFile(string source, IntermediateTupleDefinition tupleDefinition, SourceLineNumber sourceLineNumbers, BindStage bindStage) 74 public string ResolveFile(string source, IntermediateTupleDefinition tupleDefinition, SourceLineNumber sourceLineNumbers, BindStage bindStage)
68 { 75 {
76 var checkedPaths = new List<string>();
77
69 foreach (var extension in this.ResolverExtensions) 78 foreach (var extension in this.ResolverExtensions)
70 { 79 {
71 var resolved = extension.ResolveFile(source, tupleDefinition, sourceLineNumbers, bindStage); 80 var resolved = extension.ResolveFile(source, tupleDefinition, sourceLineNumbers, bindStage);
72 81
73 if (null != resolved) 82 if (resolved?.CheckedPaths != null)
83 {
84 checkedPaths.AddRange(resolved.CheckedPaths);
85 }
86
87 if (!String.IsNullOrEmpty(resolved?.Path))
74 { 88 {
75 return resolved; 89 return resolved?.Path;
76 } 90 }
77 } 91 }
78 92
79 return this.ResolveUsingBindPaths(source, tupleDefinition, sourceLineNumbers, bindStage); 93 return this.MustResolveUsingBindPaths(source, tupleDefinition, sourceLineNumbers, bindStage, checkedPaths);
80 } 94 }
81 95
82 private string ResolveUsingBindPaths(string source, IntermediateTupleDefinition tupleDefinition, SourceLineNumber sourceLineNumbers, BindStage bindStage) 96 private string MustResolveUsingBindPaths(string source, IntermediateTupleDefinition tupleDefinition, SourceLineNumber sourceLineNumbers, BindStage bindStage, List<string> checkedPaths)
83 { 97 {
84 string resolved = null; 98 string resolved = null;
85 99
86 // If the file exists, we're good to go. 100 // If the file exists, we're good to go.
101 checkedPaths.Add(source);
87 if (CheckFileExists(source)) 102 if (CheckFileExists(source))
88 { 103 {
89 resolved = source; 104 resolved = source;
@@ -121,6 +136,7 @@ namespace WixToolset.Core.Bind
121 { 136 {
122 var filePath = Path.Combine(bindPath.Path, pathWithoutSourceDir); 137 var filePath = Path.Combine(bindPath.Path, pathWithoutSourceDir);
123 138
139 checkedPaths.Add(filePath);
124 if (CheckFileExists(filePath)) 140 if (CheckFileExists(filePath))
125 { 141 {
126 resolved = filePath; 142 resolved = filePath;
@@ -131,6 +147,7 @@ namespace WixToolset.Core.Bind
131 { 147 {
132 var filePath = Path.Combine(bindPath.Path, path); 148 var filePath = Path.Combine(bindPath.Path, path);
133 149
150 checkedPaths.Add(filePath);
134 if (CheckFileExists(filePath)) 151 if (CheckFileExists(filePath))
135 { 152 {
136 resolved = filePath; 153 resolved = filePath;
@@ -141,10 +158,9 @@ namespace WixToolset.Core.Bind
141 158
142 if (null == resolved) 159 if (null == resolved)
143 { 160 {
144 throw new WixFileNotFoundException(sourceLineNumbers, source, tupleDefinition.Name); 161 throw new WixException(ErrorMessages.FileNotFound(sourceLineNumbers, source, tupleDefinition.Name, checkedPaths));
145 } 162 }
146 163
147 // Didn't find the file.
148 return resolved; 164 return resolved;
149 } 165 }
150 166
diff --git a/src/WixToolset.Core/Bind/ResolveFieldsCommand.cs b/src/WixToolset.Core/Bind/ResolveFieldsCommand.cs
index 0d5c3142..b7ed8a18 100644
--- a/src/WixToolset.Core/Bind/ResolveFieldsCommand.cs
+++ b/src/WixToolset.Core/Bind/ResolveFieldsCommand.cs
@@ -152,10 +152,9 @@ namespace WixToolset.Core.Bind
152 } 152 }
153#endif 153#endif
154 } 154 }
155 catch (WixFileNotFoundException) 155 catch (WixException e)
156 { 156 {
157 // display the error with source line information 157 this.Messaging.Write(e.Error);
158 this.Messaging.Write(ErrorMessages.FileNotFound(row.SourceLineNumbers, objectField.Path));
159 } 158 }
160 } 159 }
161 160
diff --git a/src/WixToolset.Core/Bind/TransferFilesCommand.cs b/src/WixToolset.Core/Bind/TransferFilesCommand.cs
index b89d3d03..b9c54a14 100644
--- a/src/WixToolset.Core/Bind/TransferFilesCommand.cs
+++ b/src/WixToolset.Core/Bind/TransferFilesCommand.cs
@@ -63,7 +63,7 @@ namespace WixToolset.Core.Bind
63 } 63 }
64 catch (FileNotFoundException e) 64 catch (FileNotFoundException e)
65 { 65 {
66 throw new WixFileNotFoundException(fileTransfer.SourceLineNumbers, e.FileName); 66 throw new WixException(ErrorMessages.FileNotFound(fileTransfer.SourceLineNumbers, e.FileName));
67 } 67 }
68 catch (DirectoryNotFoundException) 68 catch (DirectoryNotFoundException)
69 { 69 {
diff --git a/src/WixToolset.Core/CommandLine/CommandLineParser.cs b/src/WixToolset.Core/CommandLine/CommandLineParser.cs
index 92944ab2..d518931a 100644
--- a/src/WixToolset.Core/CommandLine/CommandLineParser.cs
+++ b/src/WixToolset.Core/CommandLine/CommandLineParser.cs
@@ -22,6 +22,8 @@ namespace WixToolset.Core.CommandLine
22 22
23 internal class CommandLineParser : ICommandLineParser 23 internal class CommandLineParser : ICommandLineParser
24 { 24 {
25 private static readonly char[] BindPathSplit = { '=' };
26
25 public CommandLineParser(IServiceProvider serviceProvider) 27 public CommandLineParser(IServiceProvider serviceProvider)
26 { 28 {
27 this.ServiceProvider = serviceProvider; 29 this.ServiceProvider = serviceProvider;
@@ -380,15 +382,15 @@ namespace WixToolset.Core.CommandLine
380 382
381 foreach (var bindPath in bindPaths) 383 foreach (var bindPath in bindPaths)
382 { 384 {
383 var bp = BindPath.Parse(bindPath); 385 var bp = ParseBindPath(bindPath);
384 386
385 if (Directory.Exists(bp.Path)) 387 if (File.Exists(bp.Path))
386 { 388 {
387 result.Add(bp); 389 this.Messaging.Write(ErrorMessages.ExpectedDirectoryGotFile("-bindpath", bp.Path));
388 } 390 }
389 else if (File.Exists(bp.Path)) 391 else
390 { 392 {
391 this.Messaging.Write(ErrorMessages.ExpectedDirectoryGotFile("-bindpath", bp.Path)); 393 result.Add(bp);
392 } 394 }
393 } 395 }
394 396
@@ -407,5 +409,11 @@ namespace WixToolset.Core.CommandLine
407 409
408 return false; 410 return false;
409 } 411 }
412
413 public static BindPath ParseBindPath(string bindPath)
414 {
415 string[] namedPath = bindPath.Split(BindPathSplit, 2);
416 return (1 == namedPath.Length) ? new BindPath(namedPath[0]) : new BindPath(namedPath[0], namedPath[1]);
417 }
410 } 418 }
411} 419}
diff --git a/src/WixToolset.Core/Preprocessor.cs b/src/WixToolset.Core/Preprocessor.cs
index ac8cefe3..aca954bd 100644
--- a/src/WixToolset.Core/Preprocessor.cs
+++ b/src/WixToolset.Core/Preprocessor.cs
@@ -649,7 +649,7 @@ namespace WixToolset.Core
649 649
650 if (null == includeFile) 650 if (null == includeFile)
651 { 651 {
652 throw new WixFileNotFoundException(sourceLineNumbers, includePath, "include"); 652 throw new WixException(ErrorMessages.FileNotFound(sourceLineNumbers, includePath, "include"));
653 } 653 }
654 654
655 using (XmlReader reader = XmlReader.Create(includeFile, DocumentXmlReaderSettings)) 655 using (XmlReader reader = XmlReader.Create(includeFile, DocumentXmlReaderSettings))
diff --git a/src/test/WixToolsetTest.CoreIntegration/MsiFixture.cs b/src/test/WixToolsetTest.CoreIntegration/MsiFixture.cs
index 7a10f71e..9d46ba98 100644
--- a/src/test/WixToolsetTest.CoreIntegration/MsiFixture.cs
+++ b/src/test/WixToolsetTest.CoreIntegration/MsiFixture.cs
@@ -171,6 +171,41 @@ namespace WixToolsetTest.CoreIntegration
171 } 171 }
172 172
173 [Fact] 173 [Fact]
174 public void CanFailBuildMissingFile()
175 {
176 var folder = TestData.Get(@"TestData\SingleFile");
177
178 using (var fs = new DisposableFileSystem())
179 {
180 var baseFolder = fs.GetFolder();
181 var intermediateFolder = Path.Combine(baseFolder, "obj");
182
183 var result = WixRunner.Execute(new[]
184 {
185 "build",
186 Path.Combine(folder, "Package.wxs"),
187 Path.Combine(folder, "PackageComponents.wxs"),
188 "-loc", Path.Combine(folder, "Package.en-us.wxl"),
189 "-bindpath", Path.Combine(folder, "does-not-exist"),
190 "-bindpath", Path.Combine(folder, "also-does-not-exist"),
191 "-intermediateFolder", intermediateFolder,
192 "-o", Path.Combine(baseFolder, @"bin\test.msi")
193 }, out var messages);
194 Assert.Equal(103, result);
195
196 var error = messages.Single(m => m.Level == MessageLevel.Error);
197 var errorMessage = error.ToString();
198 var checkedPaths = errorMessage.Substring(errorMessage.IndexOf(':') + 1).Split(new[] { ',' }).Select(s => s.Trim()).ToArray();
199 Assert.Equal(new[]
200 {
201 "test.txt",
202 Path.Combine(folder, "does-not-exist", "test.txt"),
203 Path.Combine(folder, "also-does-not-exist", "test.txt"),
204 }, checkedPaths);
205 }
206 }
207
208 [Fact]
174 public void CanLoadPdbGeneratedByBuild() 209 public void CanLoadPdbGeneratedByBuild()
175 { 210 {
176 var folder = TestData.Get(@"TestData\MultiFileCompressed"); 211 var folder = TestData.Get(@"TestData\MultiFileCompressed");