locked
DTE build event: notification of succeeded but not built RRS feed

  • Question

  • Q: How do I determine that a project succeeded but did not built (no changes)?

    I am aware that with a Visual Studio Package that I can tap into build events.

    _dte.Events.BuildEvents.OnBuild* += **;
    

    * is the rest of the event handler name and ** is the name of the event handler.

    There are two types of success codes, when building a project:

    ========== Build: 0 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
    

    and

    ========== Build: 1 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
    

    The first built successfully, but no changes were necessary, while the latter had changes and built successfully.

    The DTE build Success argument indicates that the build succeeded, as opposed to failed. If no errors are present, the result is always true regardless of changes or not.

    Sadly, there are no arguments that indicate success but not built or success and built. There is just success?

    How can I programmatically determine that a project succeeded in the build request but did not build (is up to date)?

    Monday, February 23, 2015 11:20 PM

Answers

  • The IVsBuildStatusCallback.BuildEnd method provides the same info than DTE, so it is no help:

    true if the build operation completed successfully. After an up-to-date check, fSuccess is set to true when the project configuration is up to date and false when the project configuration is not up to date.

    Some workarounds that I can imagine:

    - There is a IVsBuildableProjectCfg.StartUpToDateCheck method that you can invoke before a build to determine if a project is up-to-date. You can provide a class that implements the IVsOutputWindowPane interface and parse the output (somewhat error-prone, subject to localization issues)

    - If a project is up-to-date, the datetime of compiled output dll or exe doesn't change after a build.

    In both cases you need to perform an action before a build and after a build.


    * My new blog about VSX: http://www.visualstudioextensibility.com * Twitter: https://twitter.com/VSExtensibility * MZ-Tools productivity extension for Visual Studio: http://www.mztools.com.

    • Marked as answer by Caillen Monday, March 9, 2015 7:14 AM
    Tuesday, February 24, 2015 7:42 AM