Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you programatically execute 'Run Custom Tool' on a ProjectItem in C#?

Tags:

c#

vsx

I was wondering if it is possible to execute 'Run Custom Tool' on a file in the VS Solution? I have the ProjectItem object already.

info: C#, Visual Studio 2010 SDK

like image 594
Phill Duffy Avatar asked Mar 01 '23 05:03

Phill Duffy


2 Answers

You'll need to ensure that the ProjectItem is selected, and then run:

DTE.ExecuteCommand("Project.RunCustomTool")
like image 67
Aaron Marten Avatar answered Apr 05 '23 23:04

Aaron Marten


Try to case the Object property value of a ProjectItem to a VSProjectItem. If not null, simply call RunCustomTool() on it.

// assumes you already have a ProjectItem projectItem that is **NOT** null
VSProjectItem vsProjectItem = projectItem.Object as VSProjectItem;
if (vsProjectItem != null)
{
    vsProjectItem.RunCustomTool();
}
like image 40
Peli Avatar answered Apr 05 '23 23:04

Peli