c# - Event on Visual Studio project creation -


i want add functionality when user creates project \ solution in visual studio 2010\2012. i.e. need perform c# code when new project created.

i googled lot didn't find event fired on\after project creation.
there way that?

after research , article mentioned @joe steele, i've managed hook commandevents.afterexecute event, responsible project creation:

dte application = this.getservice(typeof(sdte)) 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 how delegate looks like:

void command_afterexecute(string guid, int id, object customin, object customout) {     // place code here } 

notes:

  1. probably difficult part find right guid , commandid, this article of help.

  2. sometimes, during debugging, event didn't fire @ all, made me baffled, thankfully i've stumbled across piece of advise:

the solutionevents object can go out of scope , garbage collected before solution closed. retain reference object, declare private variable in class in implement solution event handlers.source

thus introduction of private variable solved issue:

private commandevents createcmd; 

Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -