MZ-Tools Articles Series: HOWTO: Add a filtered task with navigation to the Task List from a Visual Studio add-in

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
http://www.mztools.com/articles/2008/MZ2008014.aspx

3 thoughts on “MZ-Tools Articles Series: HOWTO: Add a filtered task with navigation to the Task List from a Visual Studio add-in”

  1. Hi Carlos,
    I want to load the Task List with the “Add-ins and macros” selected when VS.NET IDE is first opened. However, I am not able to do so, when I use the Raise command in OnStartupComplete() method. Kindly let me know how to provide this feature.

  2. Hi,

    I want to delete the all the taskItems with a particular file name before loading additional task items.

    The code which does this is:
    For h As Int32 = 1 To taskList.TaskItems.Count

    If taskitems2.Item(h).FileName = xmlpath Then

    taskList.TaskItems.Item(h).Delete()
    End If

    Next

    But when I do this it deletes everything except the last task item. In short it does not delete all the items.

    Help!!!!!!

Comments are closed.