diff options
| author | Rob Mensching <rob@firegiant.com> | 2018-07-27 00:35:52 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2018-07-27 11:31:18 -0700 |
| commit | c8c73ccddedcb64f9989e3d5a9f15240b476b551 (patch) | |
| tree | 099f35daf71912b211223abcefafc97068971217 /src/WixToolset.Core/Bind | |
| parent | 854e616eb3516c7405691b679617aa08c1dd1cdd (diff) | |
| download | wix-c8c73ccddedcb64f9989e3d5a9f15240b476b551.tar.gz wix-c8c73ccddedcb64f9989e3d5a9f15240b476b551.tar.bz2 wix-c8c73ccddedcb64f9989e3d5a9f15240b476b551.zip | |
Remove WixFileNotFoundException, report checked paths and improve bind path command-line parsing
Diffstat (limited to 'src/WixToolset.Core/Bind')
| -rw-r--r-- | src/WixToolset.Core/Bind/FileResolver.cs | 36 | ||||
| -rw-r--r-- | src/WixToolset.Core/Bind/ResolveFieldsCommand.cs | 5 | ||||
| -rw-r--r-- | src/WixToolset.Core/Bind/TransferFilesCommand.cs | 2 |
3 files changed, 29 insertions, 14 deletions
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 | { |
