private string GetSummary(CompilerResult result, string cwd) { const int n = 75; string header(string title = "", char c = '-') => string.Concat(Enumerable.Repeat(c, n)).Insert(5, $" {title} ").Remove(n); string rel(string x) => (x == null ? null : string.Format("{0}\\{1}", Path.GetDirectoryName(x).Replace(cwd, string.Empty), Path.GetFileName(x)).Trim('\\')); var builder = new StringBuilder(); builder.AppendLine(header($"Build started: {Path.GetFileName(cwd)}")); builder.AppendLine(" Source Files:"); for (int i = 0; i < result.SourceFiles.Length; i++) { builder.AppendLine($" in: {rel(result.SourceFiles[i])}"); } builder.AppendLine(); builder.AppendLine(" Compiled Files:"); for (int i = 0; i < result.GeneratedFiles.Length; i++) { builder.AppendLine($" out: {rel(result.GeneratedFiles[i])}"); } return(builder.AppendLine(header($"errors:{result.Errors.Length} elapse:{result.Elapse.ToString("hh\\:mm\\:ss\\.fff")}", '=')) .AppendLine() .ToString()); }
private async void RunCompiler(string activeFile, IVsHierarchy hierarchy) { string projectFolder = Path.GetDirectoryName(hierarchy.ToProject()?.FullName); string configFile = Compiler.FindConfigurationFile(projectFolder); if (!File.Exists(configFile)) { return; } var options = new Configuration.CompilerOptions( configFile, ConfigurationPage.ShouldMinify, ConfigurationPage.ShouldGenerateSourceMaps ); CompilerResult result = await Compiler.RunAsync(options, projectFolder); await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); ShowErrors(activeFile, hierarchy, result.Errors); _vsOutWindow.Writeline(GetSummary(result, projectFolder)); }