0

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?

Existing questions here on SO, such as 2801985 and 3629125 do not go down to this granularity / distinction.

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

Community
  • 1
  • 1
Sarah Weinberger
  • 15,041
  • 25
  • 83
  • 130

1 Answers1

1

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.

Carlos Quintero
  • 4,300
  • 1
  • 11
  • 18
  • I marked the answer above as the answer, however the methodology is different. I had to obtain the DateTime stamp of the output assembly before and after and compare them. I used IvsOutputWindowPane to this end, not IVsBuildableProjectCfg. I guess different strokes for different folks. Retrieving the output build window text is not a viable solution. – Sarah Weinberger Feb 25 '15 at 22:48