After some research and thanks to article mentioned by @Joe Steele, I've managed to hook up the CommandEvents.AfterExecute
event, responsible for project creation:
DTE application = this.GetService(typeof(SDTE)) as DTE;
string guidVSStd97 = "{5efc7975-14bc-11cf-9b2b-00aa00573819}".ToUpper();
int cmdidNewProject = 216;
this.createCmd = application.Events.CommandEvents[guidVSStd97, cmdidNewProject];
this.createCmd.AfterExecute += this.command_AfterExecute;
And this is how the delegate looks like:
void command_AfterExecute(string Guid, int ID, object CustomIn, object CustomOut)
{
// place your code here
}
Notes:
Probably the most difficult part was to find the right guid
and commandId
, but this article was of help.
Sometimes, during debugging, event didn't fire at all, which made me baffled, but thankfully I've stumbled across this piece of advise:
The SolutionEvents object can go out of scope and be garbage collected before the solution is closed. To retain a reference to this object, declare a private variable in the class in which you implement the solution event handlers.Source
Thus introduction of private variable solved the issue:
private CommandEvents createCmd;