Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / Extensibility / August 2005

Tip: Looking for answers? Try searching our database.

Aborting a build process?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Notre Poubelle - 09 Aug 2005 22:24 GMT
Hello,

I am planning to write custom behaviour in a pre or post build event, using
the BuildEvents capability exposed by a project system's automation model.  
Is it possible, within one of these events handlers (e.g. OnBuildBegin) to
abort the build process, if my custom processing detects what I define as a
problem in my validation?

Thanks,

Notre
"Gary Chang[MSFT]" - 10 Aug 2005 10:12 GMT
Hi Notre,

Currently, we are looking into this problem. We will update you as soon as
we get anything out.

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.
Carlos J. Quintero [.NET MVP] - 10 Aug 2005 10:33 GMT
AFAIK, no, it is not possible with the BuildEvents, since they lack a ByRef
Cancel parameter. However, you can do it trapping the
CommandEvents.BeforeExecute event of the Build.XXX commands and use its
CancelDeafult parameter.

The following article of mine shows the technique to get command events (and
a bug that happens in VS.NET 2002/2003):

BUG: Command events fired only to last addin loaded in Visual Studio .NET
http://support.microsoft.com/default.aspx?scid=kb;en-us;555090

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

> Hello,
>
[quoted text clipped - 9 lines]
>
> Notre
Notre Poubelle - 10 Aug 2005 17:16 GMT
Thank you for your feedback Carlos!  

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?  Would I need to handle
menu commands separately from the toolbar commands?  What about context menu
vs. non-context versions of these commands?  

I'm not clear on what the various parameters are to the BeforeExecute met
hod (and the documentation I found at
http://msdn2.microsoft.com/library/5b1fh1sd(en-us,vs.80).aspx doesn't help).
I assume the Guid is the command group and the Id is relative to the command
groupm but I'm not clear.
Carlos J. Quintero [.NET MVP] - 11 Aug 2005 11:16 GMT
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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.