public override void OnBuildDone(vsBuildScope scope, vsBuildAction action) { base.OnBuildDone(scope, action); var build = new BuildEvent { SolutionName = Dte.Solution.FullName, }; var filesWithErrors = new List <string>(); //start at 1 when iterating through Error List for (var i = 1; i <= Dte.ToolWindows.ErrorList.ErrorItems.Count; i++) { var item = Dte.ToolWindows.ErrorList.ErrorItems.Item(i); var beli = new BuildEventErrorListItem { BuildEvent = build, ErrorListItem = TypeConverters.ErrorItemToErrorListItem(item) }; //only worry about critical errors if (!string.IsNullOrWhiteSpace(beli.ErrorListItem.CriticalErrorName)) { build.ErrorItems.Add(beli); //add the file with the error to our list of items that have errors if (filesWithErrors.Contains(beli.ErrorListItem.File.ToLower()) == false) { filesWithErrors.Add(beli.ErrorListItem.File.ToLower()); } } } //add in breakpoint information for (var i = 1; i <= Dte.Debugger.Breakpoints.Count; i++) { var bebp = new BuildEventBreakPoint { BreakPoint = TypeConverters.IdeBreakPointToBreakPoint(Dte.Debugger.Breakpoints.Item(i)), BuildEvent = build }; build.Breakpoints.Add(bebp); } //get all files in the solution var files = SolutionHelpers.GetSolutionFiles(Dte.Solution); //add in associated documents foreach (var bd in files.Select(file => new BuildDocument { Build = build, Document = file })) { build.Documents.Add(bd); } EventFactory.ToZippedBinary(build); //let others know that we have created a new event NotifyEventCreated(this, new EventCreatedArgs(build)); CheckInterventionStatus(); }
//kind of silly right now, but it does set us up nicely for future expansion public static CodeDocument FromDteDocument(Document document) { var codeDocument = new CodeDocument { FileName = Path.Combine(document.Path, document.Name), Content = File.ReadAllText(document.FullName) }; var dte = (DTE2)document.DTE; //start at 1 when iterating through Error List for (var i = 1; i <= dte.ToolWindows.ErrorList.ErrorItems.Count; i++) { var item = dte.ToolWindows.ErrorList.ErrorItems.Item(i); //only grab events that are related to the current file var fileName = Path.GetFileName(item.FileName); if (fileName == null) { continue; } var itemFileName = fileName.ToLower(); var name = Path.GetFileName(document.FullName); if (name == null) { continue; } var documentFileName = name.ToLower(); if (string.Compare(itemFileName, documentFileName, StringComparison.CurrentCultureIgnoreCase) == 0) { var eli = new CodeDocumentErrorListItem { CodeDocument = codeDocument, ErrorListItem = TypeConverters.ErrorItemToErrorListItem(item) }; codeDocument.ErrorItems.Add(eli); } } //add in breakpoint information for (var i = 1; i <= dte.Debugger.Breakpoints.Count; i++) { var bp = TypeConverters.IdeBreakPointToBreakPoint(dte.Debugger.Breakpoints.Item(i)); //agan, only grab breakpoints set in the current document if (string.Compare(bp.File, document.FullName, StringComparison.OrdinalIgnoreCase) != 0) { continue; } var cbp = new CodeDocumentBreakPoint { CodeDocument = codeDocument, BreakPoint = bp }; codeDocument.BreakPoints.Add(cbp); } return(codeDocument); }