AdviseBuildStatusCallback

I'm implementing the IVsBuildStatusCallback interface and am not able to hit my breakpoint in the BuildEnd method. Here is the code I'm using to set AdviseBuildStatusCallback:

public int OnAfterOpenProject(IVsHierarchy pHierarchy, int fAdded)

{

if (Utilities.IsSameComObject(pHierarchy, this as Microsoft.VisualStudio.Shell.Interop.IVsHierarchy))

{

IVsProjectCfg project_cfg;

ConfigProvider.OpenProjectCfg("Release", out project_cfg);

IVsBuildableProjectCfg bpcfg;

uint bsc_cookie;

project_cfg.get_BuildableProjectCfg(out bpcfg);

bpcfg.AdviseBuildStatusCallback(this, out bsc_cookie);

}

return VSConstants.S_OK;

// throw new Exception("The method or operation is not implemented.");

}

I've also tried putting the code in my overloaded Build method on my ProjectNode class. I also tried using the MPF classes instead, but nothing seems to work. Any suggestions

Thanks,

Mike



Answer this question

AdviseBuildStatusCallback

  • MikeFrey

    I got these events to fire by declaring a BuildEvents object and using that instead of an inline call:

    BuildEvents myBuildEvents = MyDTE.Events.BuildEvents;

    myBuildEvents.OnBuildBegin += new _dispBuildEvents_OnBuildBeginEventHandler(XgenProject_OnBuildBegin);

    myBuildEvents.OnBuildDone += new _dispBuildEvents_OnBuildDoneEventHandler(XgenProject_OnBuildDone);

    My problem now is that the other project builds in my solution, like C# projects, are also triggering these events. Is there a way to make these events fire for only my project type. I tried adding the BuildEvents interface to my ProjectNode class and using those eventhandlers, but that did not work.

    Thanks,

    Mike


  • Lajash

    BuildEvents are raised by the shell. There is no way to change that behaviour. Have you considered creating your own .Net events
  • Asifkhan75025

    Do I need to implement automation on my package in order to use those events I tried this code in my ProjectNode class, but my event handler did not get called.

    MyDTE = (DTE) GetService(typeof(DTE));

    MyDTE.Events.BuildEvents.OnBuildDone += new _dispBuildEvents_OnBuildDoneEventHandler(XgenBuildDone);

    public void XgenBuildDone(EnvDTE.vsBuildScope Scope, EnvDTE.vsBuildAction Action)

    {

    MessageBox.Show("BuildDone");

    }


  • STreml

    IVsBuildStatusCallBack is implemented by the environment and is intendended for reporting to the shell about the build status. I would suggest you to use EnvDTE.BuildEvents instead which has exactly the callback methods (OnBuildDone etc.) you are looking for.

    Thanks,

    Ole


  • AdviseBuildStatusCallback