Chaining SharePoint Builds Status
So I am still in migration hell and fixing some build code. One of the problems we just ran into was chaining build events. Consider if you had SharePoint project X which contained and Exec command that triggered SharePoint project Y. The goal of their custom build is to query into the build status of SharePoint project Y, and display the build status in SharePoint project X’s build status. Put simply, I needed a mechanism where Project Y build status, like whether it returns Success, Partial Success, etc.
Fortunately, this isn’t terribly difficult using the Exec task to execute a command leveraging the exitcode to get the status. This looks like the following:
- <Target Name="MyBuildTarget">
- <Exec Command="tfsbuild start /server:myserver /builddefinition:\mytfsproject\buildprojectb" ContinueOnError="true">
- <Output TaskParameter="ExitCode" PropertyName="BuildProjectExitCode"/>
- <Message Text="BuildProjectExitCode=$(BuildProjectExitCode)"></Message>
The exitcode return will be an integer, which is easy to correlate to the respective return values, Failure is 100, Partial Success is 1, Success is 0, Unknown is -1, and Unrecognized Command is 2.