Search code examples
c#visual-studiovisual-studio-2019visual-studio-extensionsvsix

Catch a newly added Project


I was wondering if there is any way to catch a 'Project add' event. I know you can do that with the DTE e.g. SolutionEvents.ProjectAdded event. However I am trying to accomplish this without the use of the DTE. I already tried it with the IVsHierarchyEvents, sadly the OnItemAdded and OnItemsAppended methods never get called for added Projects.

Note that I want to catch Projects which are either direct children of the solution or a solution-folder.


Solution

  • SolutionEvents.ProjectAdded is the best way to do this as far as I can tell. Sometimes (not always), but sometimes there aren't more appropriate lower level APIs or interfaces that provide the same or similar functionality found in the EnvDTE automation interfaces. In this particular instance the SolutionEvents ProjectAdded event isn't built upon a lower level API or service, and it's the only event I could find that fits what you're looking for here.

    Sincerely,