Another “task” that can be quite usual from a Visual Studio add-in is to add a task to the Task List or Error List. It happens in Visual Studio 2005/2008 that it is not as easy as it seems because of the following:
- VS 2005/2008 uses a separate Error List window for errors, and the automation model (EnvDTE) doesn’t provide a way to add errors, you need to implement an error provider for that (typically compilers implement an error provider). So, you can only add items to the Task List, not to the Error List.
- While a Task Item has properties for a file and line number, when you double click it VS doesn’t navigate to that file and line number unless you have used the EnvDTE80.TaskItems2.Add2 method.
- When an add-in (or macro) adds a task, it is added to a new item in the combobox of the Task List with the name “Add-ins and macros”, instead of, say, the “User Tasks” item. So you need to filter the combobox by that provider, but, alas, this is very tricky. Chetan Chudasama, from the Visual Studio team, published how to do it in its Programmatically setting TaskList view blog post. He didn’t mention where the numbers such as 2200 come from, so wrote a HOWTO: Execute a command by Guid and Id from a Visual Studio add-in post explaining it.
Here is the article:
HOWTO: Add a filtered task with navigation to the Task List from a Visual Studio add-in