Execute custom command after solution is instantiated

Jun 20, 2013 at 3:56 PM
Hi guys,

I want to create a toolkit to reuse an specific solution structure (combination of folders and projects).
Initially the solution will be created empty and later to add all corresponding elements using EnvDTE.
The idea is to execute my custom command after the solution is instantiated.
I only see how to execute visual studio commands but not custom commands.
What should be the type of CommandType in order to achieve my goal?

Thanks for your hints.
Jun 21, 2013 at 4:16 AM
Hi mosquet,

This is easy.
In your toolkit project, in Solution Builder, right click on the 'Automation\Library\Commands' node and create a new command, give it a sensible name for what it does.
This is a custom command in C#. Make sure you update the attributes on your command class. These will be needed by you to find your command later.
Modify the Execute() method, do whatever you like here. You can import ISolution if you want to do stuff in SOlution Explorer instead of messing with EnvDTE.
Compile your Automation project.

Now go into your pattern model, right click on an element in the 'Automation' compartment, and a add an Automation, select a 'Command' automation.
Change the 'Command Type' property, and from the list that pops up find your new custom command.
Now add a 'Event Launch Point' in the same way, set the 'Event Type' property to be 'On Element Instantiated', and select your new 'command' property.

That should do it.
BTW: details for this are found in the Guidance Explorer window, under the " How To: Guides | Authoring | Automation | How To: Create Your Own Commands."
Jun 25, 2013 at 7:45 AM
Edited Jun 25, 2013 at 7:52 AM
Hi Jezz,

Thanks for your reply.
I was missing the compilation of the Automation project after create the Command.
It is mandatory to see the new command created as 'Command Type' like you said.
In fact the Pattern Toolkit Guidance is my main tool for any development.