From aa33b92c7a2e6b699a11532056485143b0edf4a3 Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Thu, 27 Sep 2018 20:10:30 -0400 Subject: Report preprocessor exceptions as errors. Fixes wixtoolset/issues#5881. --- src/WixToolset.Core/CommandLine/BuildCommand.cs | 12 ++++++++++- src/WixToolset.Core/CommandLine/CompileCommand.cs | 25 ++++++++++++++++++++--- 2 files changed, 33 insertions(+), 4 deletions(-) (limited to 'src/WixToolset.Core') 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 using System.Collections.Generic; using System.IO; using System.Linq; + using System.Xml.Linq; using WixToolset.Data; using WixToolset.Extensibility.Data; using WixToolset.Extensibility.Services; @@ -173,7 +174,16 @@ namespace WixToolset.Core.CommandLine preprocessor.Platform = Platform.X86; // TODO: set this correctly preprocessor.SourcePath = sourceFile.SourcePath; preprocessor.Variables = this.PreprocessorVariables; - var document = preprocessor.Execute(); + + XDocument document = null; + try + { + document = preprocessor.Execute(); + } + catch (WixException e) + { + this.Messaging.Write(e.Error); + } if (this.Messaging.EncounteredError) { 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 { using System; using System.Collections.Generic; + using System.Xml.Linq; using WixToolset.Data; using WixToolset.Extensibility.Data; + using WixToolset.Extensibility.Services; internal class CompileCommand : ICommandLineCommand { public CompileCommand(IServiceProvider serviceProvider, IEnumerable sources, IDictionary preprocessorVariables) { - this.PreprocessorVariables = preprocessorVariables; this.ServiceProvider = serviceProvider; + this.Messaging = serviceProvider.GetService(); this.SourceFiles = sources; + this.PreprocessorVariables = preprocessorVariables; } private IServiceProvider ServiceProvider { get; } - public IEnumerable IncludeSearchPaths { get; } + public IMessaging Messaging { get; } private IEnumerable SourceFiles { get; } private IDictionary PreprocessorVariables { get; } + public IEnumerable IncludeSearchPaths { get; } + public int Execute() { foreach (var sourceFile in this.SourceFiles) @@ -33,7 +38,21 @@ namespace WixToolset.Core.CommandLine preprocessor.Platform = Platform.X86; // TODO: set this correctly preprocessor.SourcePath = sourceFile.SourcePath; preprocessor.Variables = new Dictionary(this.PreprocessorVariables); - var document = preprocessor.Execute(); + + XDocument document = null; + try + { + document = preprocessor.Execute(); + } + catch (WixException e) + { + this.Messaging.Write(e.Error); + } + + if (this.Messaging.EncounteredError) + { + continue; + } var compiler = new Compiler(this.ServiceProvider); compiler.OutputPath = sourceFile.OutputPath; -- cgit v1.2.3-55-g6feb