private async void OpenLogFile(string filePath) { if (!File.Exists(filePath)) { return; } DisplayBuild(null); this.logFilePath = filePath; SettingsService.AddRecentLogFile(filePath); UpdateRecentItemsMenu(); Title = filePath + " - " + DefaultTitle; var progress = new BuildProgress(); progress.ProgressText = "Opening " + filePath + "..."; SetContent(progress); bool shouldAnalyze = true; var stopwatch = Stopwatch.StartNew(); Build build = await System.Threading.Tasks.Task.Run(() => { try { return(Serialization.Read(filePath)); } catch (Exception ex) { ex = ExceptionHandler.Unwrap(ex); shouldAnalyze = false; return(GetErrorBuild(filePath, ex.ToString())); } }); if (build == null) { build = GetErrorBuild(filePath, ""); shouldAnalyze = false; } if (shouldAnalyze) { progress.ProgressText = "Analyzing " + filePath + "..."; await System.Threading.Tasks.Task.Run(() => BuildAnalyzer.AnalyzeBuild(build)); } progress.ProgressText = "Rendering tree..."; await Dispatcher.InvokeAsync(() => { }, DispatcherPriority.Loaded); // let the progress message be rendered before we block the UI again DisplayBuild(build); var elapsed = stopwatch.Elapsed; if (currentBuild != null) { currentBuild.UpdateBreadcrumb($"Load time: {elapsed}"); } }
private async void OpenLogFile(string filePath) { if (!File.Exists(filePath)) { return; } DisplayBuild(null); this.xmlLogFilePath = filePath; SettingsService.AddRecentLogFile(filePath); UpdateRecentItemsMenu(); Title = DefaultTitle + " - " + filePath; var progress = new BuildProgress(); progress.ProgressText = "Opening " + filePath + "..."; SetContent(progress); Build build = await System.Threading.Tasks.Task.Run(() => { return(XmlLogReader.ReadFromXml(filePath)); }); progress.ProgressText = "Analyzing " + filePath + "..."; await System.Threading.Tasks.Task.Run(() => BuildAnalyzer.AnalyzeBuild(build)); DisplayBuild(build); }
private static void SearchInFile(string binlogFilePath, string searchText) { var build = Serialization.Read(binlogFilePath); BuildAnalyzer.AnalyzeBuild(build); var search = new Search( new[] { build }, build.StringTable.Instances, 5000, false //, Build.StringTable // disable validation in production ); var results = search.FindNodes(searchText, CancellationToken.None); if (!results.Any()) { return; } Log.WriteLine(binlogFilePath, ConsoleColor.Cyan); var resultTree = ResultTree.BuildResultTree(results); PrintTree(resultTree); Log.WriteLine("====================================", ConsoleColor.Green); Log.WriteLine(""); }
public void TestBuildTreeStructureCount() { var binLog = GetTestFile("1.binlog"); var binaryLogger = new BinaryLogger(); binaryLogger.Parameters = binLog; var buildSuccessful = MSBuild.BuildProjectFromFile(s_testProject, binaryLogger); Assert.True(buildSuccessful); var build = Serialization.Read(binLog); BuildAnalyzer.AnalyzeBuild(build); var projectEvaluations = build.FindChildrenRecursive <ProjectEvaluation>(); Assert.Equal(3, projectEvaluations.Count); Assert.Equal(3, new HashSet <ProjectEvaluation>(projectEvaluations).Count); var projectInvocations = build.FindChildrenRecursive <Project>(); Assert.Equal(5, projectInvocations.Count); Assert.Equal(5, new HashSet <Project>(projectInvocations).Count); Assert.Equal(7, build.FindChildrenRecursive <Target>().Count); Assert.Equal(10, build.FindChildrenRecursive <Task>().Count); var items = build.FindChildrenRecursive <Item>().ToArray(); // This is flaky because sometimes items will be in the tree and sometimes not // so the result could be 4 or 8 //Assert.Equal(4, items.Length); }
private async void OpenLogFile(string filePath) { if (!File.Exists(filePath)) { return; } DisplayBuild(null); this.logFilePath = filePath; SettingsService.AddRecentLogFile(filePath); UpdateRecentItemsMenu(); Title = DefaultTitle + " - " + filePath; var progress = new BuildProgress(); progress.ProgressText = "Opening " + filePath + "..."; SetContent(progress); bool shouldAnalyze = true; Build build = await System.Threading.Tasks.Task.Run(() => { try { return(Serialization.Read(filePath)); } catch (Exception ex) { shouldAnalyze = false; build = new Build() { Succeeded = false }; build.AddChild(new Error() { Text = "Error when opening file: " + filePath }); build.AddChild(new Error() { Text = ex.ToString() }); return(build); } }); if (shouldAnalyze) { progress.ProgressText = "Analyzing " + filePath + "..."; await System.Threading.Tasks.Task.Run(() => BuildAnalyzer.AnalyzeBuild(build)); } DisplayBuild(build); }
private async void BuildCore(string projectFilePath, string customArguments) { var progress = new BuildProgress(); progress.ProgressText = $"Building {projectFilePath}..."; SetContent(progress); var buildHost = new HostedBuild(projectFilePath, customArguments); Build result = await buildHost.BuildAndGetResult(progress); progress.ProgressText = "Analyzing build..."; await System.Threading.Tasks.Task.Run(() => BuildAnalyzer.AnalyzeBuild(result)); DisplayBuild(result); }
private async System.Threading.Tasks.Task QueueAnalyzeBuild(Build build) { await System.Threading.Tasks.Task.Run(() => { try { BuildAnalyzer.AnalyzeBuild(build); } catch (Exception ex) { DialogService.ShowMessageBox( "Error while analyzing build. Sorry about that. Please Ctrl+C to copy this text and file an issue on https://github.com/KirillOsenkov/MSBuildStructuredLog/issues/new \r\n" + ex.ToString()); } }); }
private async void OpenLogFile(string filePath) { if (!File.Exists(filePath)) { return; } DisplayBuild(null); this.logFilePath = filePath; SettingsService.AddRecentLogFile(filePath); UpdateRecentItemsMenu(); Title = DefaultTitle + " - " + filePath; var progress = new BuildProgress(); progress.ProgressText = "Opening " + filePath + "..."; SetContent(progress); bool shouldAnalyze = true; Build build = await System.Threading.Tasks.Task.Run(() => { try { return(Serialization.Read(filePath)); } catch (Exception ex) { ex = ExceptionHandler.Unwrap(ex); shouldAnalyze = false; return(GetErrorBuild(filePath, ex.ToString())); } }); if (build == null) { build = GetErrorBuild(filePath, ""); shouldAnalyze = false; } if (shouldAnalyze) { progress.ProgressText = "Analyzing " + filePath + "..."; await System.Threading.Tasks.Task.Run(() => BuildAnalyzer.AnalyzeBuild(build)); } DisplayBuild(build); }
private async void BuildCore(string projectFilePath, string customArguments, string searchText = null) { var progress = new BuildProgress { IsIndeterminate = true }; progress.ProgressText = $"Building {projectFilePath}..."; SetContent(progress); var buildHost = new HostedBuild(projectFilePath, customArguments); Build result = await buildHost.BuildAndGetResult(progress); progress.ProgressText = "Analyzing build..."; await System.Threading.Tasks.Task.Run(() => BuildAnalyzer.AnalyzeBuild(result)); DisplayBuild(result); if (searchText != null && CurrentBuildControl != null) { CurrentBuildControl.InitialSearchText = searchText; } }
private void Run(string binlog, int index, string taskName) { Construction.ParentAllTargetsUnderProject = SettingsService.ParentAllTargetsUnderProject; var build = Serialization.Read(binlog); // Need to analyze build here to fully emulate what the viewer does when opening a .binlog. // Since the analyzers will mutate the tree it affects indices of TimedNodes. To properly // calculate the right index we need to have the same tree as in the viewer. BuildAnalyzer.AnalyzeBuild(build); Task task = null; if (index > -1) { task = build.FindDescendant(index) as Task; } else { task = build.FindFirstDescendant <Task>(t => t.Name == taskName); } if (task == null) { if (index > -1) { Console.Error.WriteLine($"Task number {index} not found in {binlog}"); } else { Console.Error.WriteLine($"Task {taskName} not found in {binlog}"); } return; } Executor.Execute(task); }