Hi Notre,
> If I use the CommandEvents.BeforeExecute you referred to in your post,
> would
> I need to write cases for each of the Build / Rebuild / Deploy (which in
> my
> project system's case implies build), etc commands?
You need to trap the events for each of those commands, yes, but you can
have a single command event handler routine to handle all of them.
> Would I need to handle menu commands separately from the toolbar commands?
> What about context menu vs. non-context versions of these commands?
You only need to worry about commands, not about UI elements created from
commands (internally all buttons on menus or toolbars call some command,
maybe the same in some cases, maybe not). Bottom line: you need a list with
all relevant commands for Build operations. There are:
- Named commands (that have a name). You can learn the named commands in the
Tools, Customize menu, Keyboard button, "Show commands containing" textbox.
Enter "Build" (without quotes), review the list of matches and take note of
the candidates of your interest.
- Unnamed commands (that only have GUID and ID). You can learn if there are
unnamed commands for some build action setting a global command event
handler:
m_objCommandEvents = objDTE.Events.CommandEvents() ' Neither GUID nor ID
provided
Then build your target solution using every user interface element (button,
context menu, etc.) that you can think and in the event handler, call
Commands.Item(Guid, ID) to retrieve the command executed for that UI element
and examine the Command.Name property. If it is blank, then it is an unnamed
command. I have seen unnamed commands for Source Code Control operations
(check-in, check-out), not sure if they exist for Build operations, you need
to check.
> I'm not clear on what the various parameters are to the BeforeExecute met
> hod (and the documentation I found at
[quoted text clipped - 3 lines]
> command
> groupm but I'm not clear.
Commands are uniquely identified by the the pair GUID, ID. GUID is the
"owner" of the command (a package or subsystem within VS.NET) and ID allows
a package to distinguish its own commands. For commands created by add-ins,
the GUID is always the value of the constant
EnvDTE.Constants.vsAddInCmdGroup and the ID is increased every time some
add-in calls AddNamedCommand. You can ignore CustomIn and CustomOut
parameters, and CancelDefault allows you to cancel the execution of the
command.
I hope all is clear now.

Signature
Best regards,
Carlos J. Quintero
MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com
Notre Poubelle - 11 Aug 2005 16:59 GMT
Thanks Carlos, your comments are much appreciated!
> Hi Notre,
>
[quoted text clipped - 53 lines]
>
> I hope all is clear now.
"Gary Chang[MSFT]" - 15 Aug 2005 06:30 GMT
Hi Noter,
I think Carlos's workaround is practical, you need to cancel the build
command before it starts, there is no way to interrupt a build process...
Thanks for your understanding!
Best regards,
Gary Chang
Microsoft Community Support
--------------------
Get Secure! ¡§C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp
&SD=msdn
This posting is provided "AS IS" with no warranties, and confers no rights.
"Ed Dore [MSFT]" - 15 Aug 2005 21:54 GMT
Hi Notre,
I haven't tried this, but have you tried executing the Build.Cancel
command. If the project in question supports this command, you should be
able to execute it programatically via the DTE.ExecuteCommand method.
From a VSIP (VS SDK) scenario, you typically call
IVsBuildableProjectCfg.Stop to cancel a build operation. I'm not quite sure
how to go about retrieving this particular interface in your specific
scenario, but that might be another way to go if using DTE.ExecuteCommand
to run the Build.Cancel command doesn't work out.
Sincerely,
Ed Dore [MSFT]
This post is "AS IS" with no warranties, and confers no rights.
Paul Skelton - 19 Aug 2005 21:37 GMT
Thanks, Ed.
I implemented this method and it works great. The only downside is that a
task that reads "Compilation cancelled by user" is added to the Error List.
I guess I could try to programmatically remove that Error List item. In any
case, here's the code.
dte.ExecuteCommand("Build.Cancel", string.Empty);
> Hi Notre,
>
[quoted text clipped - 13 lines]
>
> This post is "AS IS" with no warranties, and confers no rights.