Hello, for the life of me I can't get the build events (OnBuildBegin,
OnBuildDone, etc) to work in my package.
In my Package Initialize method I put the code show below. The code
executes fine but when I run the package and build a project it doesn't hit
the methods I wired up. Can't find any examples of using build events with
packages in the VSIP docs or samples.
(within the Initialize method)
DTE dte = (DTE)GetService(typeof(DTE));
dte.Events.BuildEvents.OnBuildBegin += BuildEvents_OnBuildBegin;
(method wired above)
void BuildEvents_OnBuildBegin(vsBuildScope Scope, vsBuildAction Action)
{
Debug.WriteLine("BuildEvents_OnBuildBegin");
}
"Gary Chang[MSFT]" - 21 Jul 2005 11:21 GMT
Hi Paul,
Currently I am performing some tests on this issue. 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.
"Gary Chang[MSFT]" - 22 Jul 2005 09:45 GMT
Hi Paul,
Based on your sample code, the events would connect up correctly, but what
happened then is the BuildEvents handler
is local to the Initialize function. When the function exits, the
BuildEvents handler is marked for deletion, and eventually it would be
garbage collected.
So you need to define the BuildEvents objects in the package's class level,
such as the following code:
..
public class YourVSPkg : MSVSIP.Helper.Package
{
...
public DTE dte;
public Events evnts;
public BuildEvents Buildevnts;
...
protected override void Initialize()
{
dte = (DTE)GetService(typeof(DTE));
evnts= (Events)dte.Events;
Buildevnts = evnts.BuildEvents;
Buildevnts.OnBuildBegin+=new
_dispBuildEvents_OnBuildBeginEventHandler(BuildEvents_OnBuildBegin);
...
base.Initialize();
}
..
By the way, I tested the above code in the VS2003 IDE, if you use the
VS2005, you need to used the Event2 interface and the new simplified syntax
instead:)
Hope this helps!
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.
Paul Skelton - 22 Jul 2005 18:41 GMT
That did the trick. Thanks!!!
> Hi Paul,
>
[quoted text clipped - 46 lines]
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
"Gary Chang[MSFT]" - 23 Jul 2005 03:30 GMT
Hi Paul, I am glad to help you on this issue, wish you have a nice weekend:)
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.