Hi Ed,
thanks for your obviously knowledgeable reply. I have a few comments below.
> Hi Johan,
>
[quoted text clipped - 3 lines]
> do a rebuild. The problem with this though is that all the outputs of
> the previous build would wind up be deleted.
That isn't really an option for me, it sounds much too involved and kludgy.
> To get access to the actual VCPostBuildEventTool object for a VC
> project, you have use the IVCCollection interface. Below is a quick
> macro that will dump the various VCPostBuildEventTool properties to
> your output window. I cobbled that together before realizing there's
> no way to actually execute the tool programatically.
Thanks anyway - I could still use that in combination with the IVsLaunchPad
stuff (as you say below).
> I don't have a solution for launching that
> VCPostBuildEvent.CommandLine from a macro either. If you are
> in-process to devenv.exe, (from an addin or VSIP package) you could
> utilize the IVsLaunchPad service documented in the Visual Studio SDK.
> Like IDesignerHost, you can't actually get at this interface
> out-of-process.
Just to clarify - aren't the macros run in-process? If I've got the VS 2005
SDK installed, wouldn't it be possible to add the correct
references/assemblies to the macro project and access SVsLaunchPad?
Sorry it that's a silly question, but I've never really put in a lot of time
learning how the VS.NET extensibility works. I've just ordered the Inside
Visual Studio.NET 2003 book, though (and will order the 2005 counterpart
whenever it appears).
> If you have an addin, you can convert the DTE object to a COM
> IServiceProvider interface and call QueryService for the SVsLaunchPad
> service to retrieve an IVsLaunchPad interface. You could then use the
> ToolPath and CommandLine properties of the VCPostBuildEvent object to
> run the command(s) listed in the project settings.
[snip code]
What I perhaps should have said from the beginning is why I'd like to do
this:
One of my projects in the solution is the test driver, responsible for
running all tests. I want that driver to execute during each build (I'm
doing TDD development), so I've added the running of the driver as a
post-build event to it's own project.
However, once in a while I'd like to just rerun the tests in the same way -
without having to do some dummy editing in a source file to trigger a
compile/link/post-build action.
Thanks,
Johan Nilsson
"Ed Dore [MSFT]" - 12 Jan 2006 19:08 GMT
Hi Johan,
You're more than welcome. It took a bit of source code diving and some
hints from the dev team before I actually figured out how to retrieve that
VCPostBuildEventTool object :-)
Macros are actually run from another process (VSMSVR.EXE). If you build an
addin, which runs inproc to the IDE, you can retrieve and leverage that
SVsLaunchPad service, but it's not accessible from that vsmsvr.exe process.
IMHO, Inside Visual Studio .Net is a must have book for anyone doing VS
automation or extensibility stuff.
It sounds like the best approach would be to create an addin, and implement
a command/toolbar button that to do this. Then you could just use the
command/toolbar button to fire off the postbuild commandline with
IVsLaunchPad. The only tricky part would be the expansion of any macros
like $(OutputDir), but I suspect this can be done using the
VCProjectEngine. I haven't actually investigated that particular problem as
of yet.
If you decide to go the addin route, and get stuck let me know. Given we
already know how to get at that VcPostBuidlEventTool now, it probably
wouldn't take much to throw together an addin that would launch that
commandline.
Sincerely,
Ed Dore [MSFT]
This post is 'AS IS' with no warranties, and confers no rights.