static int Main(params string[] args) { string configPath = args[0]; string file = args.Length > 1 ? args[1] : null; var configs = GetConfigs(configPath, file); if (configs == null) { Console.WriteLine("\x1B[33mNo configurations matched"); return(0); } Telemetry.SetDeviceName("Command line"); ConfigFileProcessor processor = new ConfigFileProcessor(); EventHookups(processor, configPath); var results = processor.Process(configPath, configs); var errorResults = results.Where(r => r.HasErrors); foreach (var result in errorResults) { foreach (var error in result.Errors) { Console.Write("\x1B[31m" + error.Message); } } return(errorResults.Any() ? 1 : 0); }
/// <summary> /// Execute the Clean Task /// </summary> public override bool Execute() { var configFile = new FileInfo(FileName); if (!configFile.Exists) { Log.LogWarning(configFile.FullName + " does not exist"); return(true); } Log.LogMessage(MessageImportance.High, Environment.NewLine + "WebCompiler: Begin cleaning output of " + configFile.Name); Telemetry.SetDeviceName("MSBuild"); try { var processor = new ConfigFileProcessor(); processor.DeleteOutputFiles(configFile.FullName); Log.LogMessage(MessageImportance.High, "WebCompiler: Done cleaning output of " + configFile.Name); return(true); } catch (Exception ex) { Log.LogError(ex.Message); Telemetry.TrackException(ex); return(false); } }
/// <summary> /// Execute the Task /// </summary> public override bool Execute() { FileInfo configFile = new FileInfo(FileName); if (!configFile.Exists) { Log.LogWarning(configFile.FullName + " does not exist"); return(true); } Log.LogMessage(MessageImportance.High, Environment.NewLine + "WebCompiler: Begin compiling " + configFile.Name); Telemetry.SetDeviceName("MSBuild"); ConfigFileProcessor processor = new ConfigFileProcessor(); processor.BeforeProcess += (s, e) => { if (e.ContainsChanges) { FileHelpers.RemoveReadonlyFlagFromFile(e.Config.GetAbsoluteOutputFile()); } }; processor.AfterProcess += Processor_AfterProcess; processor.BeforeWritingSourceMap += (s, e) => { FileHelpers.RemoveReadonlyFlagFromFile(e.ResultFile); }; processor.AfterWritingSourceMap += Processor_AfterWritingSourceMap; FileMinifier.BeforeWritingMinFile += (s, e) => { if (e.ContainsChanges) { FileHelpers.RemoveReadonlyFlagFromFile(e.ResultFile); } }; FileMinifier.AfterWritingMinFile += FileMinifier_AfterWritingMinFile; FileMinifier.BeforeWritingGzipFile += (s, e) => { if (e.ContainsChanges) { FileHelpers.RemoveReadonlyFlagFromFile(e.ResultFile); } }; FileMinifier.AfterWritingGzipFile += FileMinifier_AfterWritingGzipFile; CompilerService.Initializing += (s, e) => { Log.LogMessage(MessageImportance.High, "WebCompiler installing updated versions of the compilers..."); }; try { var results = processor.Process(configFile.FullName); bool isSuccessful = true; foreach (CompilerResult result in results) { if (result.HasErrors) { isSuccessful = false; foreach (var error in result.Errors) { Log.LogError("WebCompiler", "0", "", error.FileName, error.LineNumber, error.ColumnNumber, error.LineNumber, error.ColumnNumber, error.Message, null); } } } Log.LogMessage(MessageImportance.High, "WebCompiler: Done compiling " + configFile.Name); return(isSuccessful); } catch (Exception ex) { Log.LogError(ex.Message); Telemetry.TrackException(ex); return(false); } }