Example #1
0
        public Task <int> ExecuteAsync(CancellationToken _)
        {
            foreach (var sourceFile in this.SourceFiles)
            {
                var context = this.ServiceProvider.GetService <IPreprocessContext>();
                context.Extensions         = this.ExtensionManager.GetServices <IPreprocessorExtension>();
                context.Platform           = this.Platform;
                context.IncludeSearchPaths = this.IncludeSearchPaths;
                context.SourcePath         = sourceFile.SourcePath;
                context.Variables          = this.PreprocessorVariables;

                IPreprocessResult result = null;
                try
                {
                    var preprocessor = this.ServiceProvider.GetService <IPreprocessor>();
                    result = preprocessor.Preprocess(context);
                }
                catch (WixException e)
                {
                    this.Messaging.Write(e.Error);
                }

                if (this.Messaging.EncounteredError)
                {
                    continue;
                }

                var compileContext = this.ServiceProvider.GetService <ICompileContext>();
                compileContext.Extensions = this.ExtensionManager.GetServices <ICompilerExtension>();
                compileContext.Platform   = this.Platform;
                compileContext.Source     = result?.Document;

                var compiler     = this.ServiceProvider.GetService <ICompiler>();
                var intermediate = compiler.Compile(compileContext);

                intermediate.Save(sourceFile.OutputPath);
            }

            return(Task.FromResult(0));
        }
Example #2
0
 /// <summary>
 /// Called at the end of the preprocessing of a source file.
 /// </summary>
 public virtual void PostPreprocess(IPreprocessResult result)
 {
 }