locked
VSIX. Running a tool OnBuild. RRS feed

  • Question

  • Hi fellow programmers,

    I've recently wrote my first VSIX tool. It works just like I wanted it to, it can be run by clicking Tools->MyTool or by hitting a bound key combination.

    All the tool does - it generates C# class with constant strings out of INI file sections.

    Now I want this tool to run automatically on some "OnBeforeBuild" so a programmer won't have to run this tool manually, but I can't find how do I register this event handler with Visual Studio.

    Can anyone help me on this one?

    Thank you in advance.


    Make assembly, not C++.

    Sunday, October 2, 2016 7:05 AM

Answers

  • Ok... Figured that out by myself.

    All you need to do is add the following code to your Package's Initialize method:

    EnvDTE.DTE dte = (EnvDTE.DTE)GetService(typeof(EnvDTE.DTE));
    var be = dte.Events.BuildEvents;
    be.OnBuildBegin += Be_OnBuildBegin;

    Hope it helps to somebody.


    Make assembly, not C++.


    • Marked as answer by miromakh Sunday, October 2, 2016 12:47 PM
    • Edited by miromakh Sunday, October 2, 2016 2:04 PM
    Sunday, October 2, 2016 12:47 PM

All replies

  • Ok... Figured that out by myself.

    All you need to do is add the following code to your Package's Initialize method:

    EnvDTE.DTE dte = (EnvDTE.DTE)GetService(typeof(EnvDTE.DTE));
    var be = dte.Events.BuildEvents;
    be.OnBuildBegin += Be_OnBuildBegin;

    Hope it helps to somebody.


    Make assembly, not C++.


    • Marked as answer by miromakh Sunday, October 2, 2016 12:47 PM
    • Edited by miromakh Sunday, October 2, 2016 2:04 PM
    Sunday, October 2, 2016 12:47 PM
  • Hi,

    I am glad to know you solved this problem and thanks for sharing the solution. 

    It will be very beneficial for other community members who have the similar questions. 

    Best regards,

    Cole Wu


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, October 3, 2016 6:28 AM