In my last post, I touched briefly on the concept of build extensions, and explained that they are an implementation of WF4 extensions. I thought it would be useful to list the other build extensions that are available inside of a build template:
- IBuildDetail – This build extension enables you to notify the build server about important aspects of your build (compilation/test status, overall build status, the label associated with the build, etc.). In fact, this is the how the SetBuildDetails built-in activity is constructed. So a typical use-case for this extension could be, for example, to fail the build when your activity encounters an error condition, despite having succeeded in compiling or running the tests. However, if you choose this route, I strongly urge you to use the composition approach rather than the code approach.
- IBuildLoggingExtension – This extension is useful for controlling which activities are logged into the build log.
- IAgentReservationExtension – This extension seems to be used for actually requesting the server to reserve/free an agent for running a specific workflow. This looks to be very interesting for doing complex dependency-management stuff – when I build component A, I’d like to make sure that the latest version of component B (upon which A is dependent) is built, which is a separate build altogether. I intend to try this out soon.
- IBuildAgent – This extension allows you to retrieve details of the build agent that is currently running your build. Of course, this is only relevant for activities that run inside an AgentScope.
As I mentioned before, using extensions requires 2 stages:
1. Declare that you will need the extension inside the activity’s CacheMetadata method, using the metadata’s RequireExtension<T> method
2. Retrieve the extension inside the execution method (Execute/BeginExecute) using the activity context’s GetExtension<T> method