How to clear the "ErrorList" window before compiling
-
Monday, September 10, 2007 1:03 PMHi there,
I'm invoking "SolutionBuild2.BuildProject()" on various projects in an arbitrary solution and need to inspect each project's build errors via "DTE2.ToolsWindows.ErrorList". I discovered however that Visual Studio (VS) doesn't always clear the "Error List" window of existing errors when you compile a different project but simply appends new errors to it. Moreover, VS even parses some projects behind the scenes automatically and populates the "Error List" window on-the-fly. Lastly, the "Project" column in the "Error List" window isn't even filled in for some project types like C++ so I can't even identify the project. Does anyone (therefore) know how to compile a project and detect its errors given that the "Error List" window may contain messages from projects I haven't explicitly compiled (which aren't dependencies) as well as messages whose project can't even be identified. Thanks very much.
Answers
-
Monday, September 10, 2007 10:20 PM
Youwill not be able to clear the error list of all items. Each item is owned by a specific item provider; a compiler, an error scanner, etc. Items within the error list stay until the item provider decides that the items are invalidated and clears them. This means closing the HTML document, recompiling the project, or some other action. One tool decide when the items of another tool are invalid and should be removed, unless those tools are closely related and communicate privately, is not allowed.
Recompiling a project may remove some items, but it may not remove everything.
Craig
All Replies
-
Monday, September 10, 2007 2:24 PMModerator
Hi Larry,
That snippet provided by MyP3uK in "TaskProvider" thread might be helpful for you as well:
Code Snippet_vsDte = (DTE2)GetGlobalService(typeof(DTE));
_vsDte.Solution.SolutionBuild.Clean(true);The thread "Error message highlighting in source code" also contains several links related to Error List, which are can be interesting for you and other forum members.Hope that helps! -
Monday, September 10, 2007 3:00 PMThanks for the feedback (appreciated). I'll take a look through these links but I've been developing an AddIn for more than a year now and this seems to be turning into a major problem. I'm not sure if "Clean()" will solve the situation anyway (need to investigate) but it's not a solution I would likely want to rely on. It means re-compiling the entire solution or even an individual project which shouldn't be necessary here. It's difficult to believe the extensibility API doesn't provide a mainstream way to simply check if a project cleanly compiles or not (and/or inspect its errors) but I'm starting to think this may be the case. I'm also not familiar with VS programming issues at the package level and would not want to turn to this unless absolutely necessary. Do you have any advice?
-
Monday, September 10, 2007 10:20 PM
Youwill not be able to clear the error list of all items. Each item is owned by a specific item provider; a compiler, an error scanner, etc. Items within the error list stay until the item provider decides that the items are invalidated and clears them. This means closing the HTML document, recompiling the project, or some other action. One tool decide when the items of another tool are invalid and should be removed, unless those tools are closely related and communicate privately, is not allowed.
Recompiling a project may remove some items, but it may not remove everything.
Craig
-
Tuesday, September 11, 2007 1:11 AMThanks very much Craig. This is the definitive answer I've been looking for after days of spinning my wheels. I don't want to impose on your time but this is now a serious blocking issue for me after more than a year's worth of work. I'm simply trying to iterate the "ProjectItems" for specific projects in an arbitrary solution but can't proceed unless I know the project itself is error-free (and its buildable dependencies). Note that I only need to support the mainstream languages for now (C#, VB, C++ and J#). How do the VS refactoring commands handle this situation for instance. They will (optionally) warn you if there are build errors so is there a way to tap into the same mechanism as one possible solution. Any assistance you can provide would be greatly appreciated. Thanks very much

