Answered BuildEvents - EnvDTE.DTE

  • Thursday, November 29, 2007 9:24 AM
     
     

    Hi there!

     

    After moving from VS2005 to 2008 the

    ..

    EnvDTE.DTE.Events.BuildEvents.OnBuildBegin += new ......

     

    is no longer thrown...???

     

    Without any luck, we tried:

    - Refrenced the same dll that a new Visual Studio 2008 Add-in project

      • C:\Windows\assembly\GAC\EnvDTE\8.0.0.0__b03f5f7f11d50a3a\EnvDTE.dll
      • C:\Windows\assembly\GAC\EnvDTE80\8.0.0.0__b03f5f7f11d50a3a\EnvDTE80.dll
      • C:\Windows\assembly\GAC\EnvDTE90\9.0.0.0__b03f5f7f11d50a3a\EnvDTE90.dll
    • Also
      • C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PublicAssemblies\EnvDTE.dll

    We are doing a DSL solution and we need to generate Artifact on build time

     

    protected override void OnDocumentLoaded()

    {

    base.OnDocumentLoaded();

    DTE dte = (EnvDTE.DTE)Package.GetGlobalService(typeof(DTE));

    dte.Events.BuildEvents.OnBuildBegin += new _dispBuildEvents_OnBuildBeginEventHandler(buildEvents_OnBuildBegin);

    }

     

    Any ideas on why the Build event is not thrown?

    Thanks

    Christian

     

All Replies

  • Friday, November 30, 2007 8:31 AM
    Moderator
     
     Answered

     

    See the problem and solution here:

     

    PRB: Visual Studio .NET events being disconnected from add-in.

    http://www.mztools.com/resources_vsnet_addins.aspx

     

    (The surprising thing is that your code worked in VS 2005... )

  • Friday, November 30, 2007 2:18 PM
     
     Answered

    Super.. I had already been down that path and it still did not work.

    But then I realized that I only had moved the BuildEvent out of the scope of the method... After moving the DTE out too, it worked.

     

    Cool.. thanks for bringing me back on track!

     

    private EnvDTE.BuildEvents buildEvents;

    DTE dte;

    protected override void OnDocumentLoaded()

    {

    base.OnDocumentLoaded();

    dte = (EnvDTE.DTE)Package.GetGlobalService(typeof(DTE));

    buildEvents = dte.Events.BuildEvents;

    buildEvents.OnBuildBegin += new _dispBuildEvents_OnBuildBeginEventHandler(buildEvents_OnBuildBegin);

    delegate(vsBuildScope Scope, vsBuildAction Action)

    {

    GenerateArtifact();

    };

    }

     

    /Christian