diff options
author | Bob Arnson <bob@firegiant.com> | 2018-09-27 20:10:30 -0400 |
---|---|---|
committer | Bob Arnson <bob@firegiant.com> | 2018-09-27 21:41:19 -0400 |
commit | aa33b92c7a2e6b699a11532056485143b0edf4a3 (patch) | |
tree | 06483f2a90d97ac164d427c57f0cfcd237fdc2c3 /src/WixToolset.Core | |
parent | aed25de217d676bef1559290457b54444714e194 (diff) | |
download | wix-aa33b92c7a2e6b699a11532056485143b0edf4a3.tar.gz wix-aa33b92c7a2e6b699a11532056485143b0edf4a3.tar.bz2 wix-aa33b92c7a2e6b699a11532056485143b0edf4a3.zip |
Report preprocessor exceptions as errors. Fixes wixtoolset/issues#5881.
Diffstat (limited to 'src/WixToolset.Core')
-rw-r--r-- | src/WixToolset.Core/CommandLine/BuildCommand.cs | 12 | ||||
-rw-r--r-- | src/WixToolset.Core/CommandLine/CompileCommand.cs | 25 |
2 files changed, 33 insertions, 4 deletions
diff --git a/src/WixToolset.Core/CommandLine/BuildCommand.cs b/src/WixToolset.Core/CommandLine/BuildCommand.cs index b460e48f..16c98c83 100644 --- a/src/WixToolset.Core/CommandLine/BuildCommand.cs +++ b/src/WixToolset.Core/CommandLine/BuildCommand.cs | |||
@@ -6,6 +6,7 @@ namespace WixToolset.Core.CommandLine | |||
6 | using System.Collections.Generic; | 6 | using System.Collections.Generic; |
7 | using System.IO; | 7 | using System.IO; |
8 | using System.Linq; | 8 | using System.Linq; |
9 | using System.Xml.Linq; | ||
9 | using WixToolset.Data; | 10 | using WixToolset.Data; |
10 | using WixToolset.Extensibility.Data; | 11 | using WixToolset.Extensibility.Data; |
11 | using WixToolset.Extensibility.Services; | 12 | using WixToolset.Extensibility.Services; |
@@ -173,7 +174,16 @@ namespace WixToolset.Core.CommandLine | |||
173 | preprocessor.Platform = Platform.X86; // TODO: set this correctly | 174 | preprocessor.Platform = Platform.X86; // TODO: set this correctly |
174 | preprocessor.SourcePath = sourceFile.SourcePath; | 175 | preprocessor.SourcePath = sourceFile.SourcePath; |
175 | preprocessor.Variables = this.PreprocessorVariables; | 176 | preprocessor.Variables = this.PreprocessorVariables; |
176 | var document = preprocessor.Execute(); | 177 | |
178 | XDocument document = null; | ||
179 | try | ||
180 | { | ||
181 | document = preprocessor.Execute(); | ||
182 | } | ||
183 | catch (WixException e) | ||
184 | { | ||
185 | this.Messaging.Write(e.Error); | ||
186 | } | ||
177 | 187 | ||
178 | if (this.Messaging.EncounteredError) | 188 | if (this.Messaging.EncounteredError) |
179 | { | 189 | { |
diff --git a/src/WixToolset.Core/CommandLine/CompileCommand.cs b/src/WixToolset.Core/CommandLine/CompileCommand.cs index 6bd0f25a..ec1ce602 100644 --- a/src/WixToolset.Core/CommandLine/CompileCommand.cs +++ b/src/WixToolset.Core/CommandLine/CompileCommand.cs | |||
@@ -4,26 +4,31 @@ namespace WixToolset.Core.CommandLine | |||
4 | { | 4 | { |
5 | using System; | 5 | using System; |
6 | using System.Collections.Generic; | 6 | using System.Collections.Generic; |
7 | using System.Xml.Linq; | ||
7 | using WixToolset.Data; | 8 | using WixToolset.Data; |
8 | using WixToolset.Extensibility.Data; | 9 | using WixToolset.Extensibility.Data; |
10 | using WixToolset.Extensibility.Services; | ||
9 | 11 | ||
10 | internal class CompileCommand : ICommandLineCommand | 12 | internal class CompileCommand : ICommandLineCommand |
11 | { | 13 | { |
12 | public CompileCommand(IServiceProvider serviceProvider, IEnumerable<SourceFile> sources, IDictionary<string, string> preprocessorVariables) | 14 | public CompileCommand(IServiceProvider serviceProvider, IEnumerable<SourceFile> sources, IDictionary<string, string> preprocessorVariables) |
13 | { | 15 | { |
14 | this.PreprocessorVariables = preprocessorVariables; | ||
15 | this.ServiceProvider = serviceProvider; | 16 | this.ServiceProvider = serviceProvider; |
17 | this.Messaging = serviceProvider.GetService<IMessaging>(); | ||
16 | this.SourceFiles = sources; | 18 | this.SourceFiles = sources; |
19 | this.PreprocessorVariables = preprocessorVariables; | ||
17 | } | 20 | } |
18 | 21 | ||
19 | private IServiceProvider ServiceProvider { get; } | 22 | private IServiceProvider ServiceProvider { get; } |
20 | 23 | ||
21 | public IEnumerable<string> IncludeSearchPaths { get; } | 24 | public IMessaging Messaging { get; } |
22 | 25 | ||
23 | private IEnumerable<SourceFile> SourceFiles { get; } | 26 | private IEnumerable<SourceFile> SourceFiles { get; } |
24 | 27 | ||
25 | private IDictionary<string, string> PreprocessorVariables { get; } | 28 | private IDictionary<string, string> PreprocessorVariables { get; } |
26 | 29 | ||
30 | public IEnumerable<string> IncludeSearchPaths { get; } | ||
31 | |||
27 | public int Execute() | 32 | public int Execute() |
28 | { | 33 | { |
29 | foreach (var sourceFile in this.SourceFiles) | 34 | foreach (var sourceFile in this.SourceFiles) |
@@ -33,7 +38,21 @@ namespace WixToolset.Core.CommandLine | |||
33 | preprocessor.Platform = Platform.X86; // TODO: set this correctly | 38 | preprocessor.Platform = Platform.X86; // TODO: set this correctly |
34 | preprocessor.SourcePath = sourceFile.SourcePath; | 39 | preprocessor.SourcePath = sourceFile.SourcePath; |
35 | preprocessor.Variables = new Dictionary<string, string>(this.PreprocessorVariables); | 40 | preprocessor.Variables = new Dictionary<string, string>(this.PreprocessorVariables); |
36 | var document = preprocessor.Execute(); | 41 | |
42 | XDocument document = null; | ||
43 | try | ||
44 | { | ||
45 | document = preprocessor.Execute(); | ||
46 | } | ||
47 | catch (WixException e) | ||
48 | { | ||
49 | this.Messaging.Write(e.Error); | ||
50 | } | ||
51 | |||
52 | if (this.Messaging.EncounteredError) | ||
53 | { | ||
54 | continue; | ||
55 | } | ||
37 | 56 | ||
38 | var compiler = new Compiler(this.ServiceProvider); | 57 | var compiler = new Compiler(this.ServiceProvider); |
39 | compiler.OutputPath = sourceFile.OutputPath; | 58 | compiler.OutputPath = sourceFile.OutputPath; |