Wire a button macro to custom MSBuild target

Hey everyone,

Hopefully this is the right forum for this question...

Does anyone know how to wire a button in Visual Studio 2005 to call a macro that will initiate an MSBuild build, but calling a specific (non-standard) Target?

For example, if I have an MSBuild task (just edited my .csproj file or whatever) to have

Code Snippet

<Target Name="OpenNotepad">

...(for whatever reason, notepad.exe is opened here, just as an example)

</Target>

could I create a macro and add it to a toolbar in Visual Studio so that when I click the button, MSBuild starts with /target=OpenNotepad?

Just curious.

Thanks a ton!

-Matt

[906 byte] By [mattman206] at [2008-1-7]
# 1

Matt,

The easiest way I think would be to use Tools->External Tools; there you can configure call MSBuild with project and specific custom target; the additional advantage would be that you have access to set solution/project specific properties (SolutionDir etc).

Hope that helps, Eugene

EugeneZakhareyev at 2007-10-2 > top of Msdn Tech,Visual Studio,Visual Studio MSBuild...
# 2

Hi Eugene,

Thanks for the reply! That worked fabulously.

I created the external tool to run msbuild with the current project file and /target=CustomTarget and then also made a toolbar button to execute the external tool. The external tool even puts its output in the output window. Awesome.

Thanks again,

-Matt

mattman206 at 2007-10-2 > top of Msdn Tech,Visual Studio,Visual Studio MSBuild...

Visual Studio

Site Classified