Stopping excessive build steps in TFS 2008

Posted on Posted in Uncategorized

EDIT: Updated the query below to only delete the steps of finished builds. Deleting steps while the build is in progress can cause the build to abort.

Since upgrading to TFS 2008, we’ve had two extremely annoying sources of pain:

  1. the amount of msbuild output that goes into the BuildLog.txt
  2. the excessive number of build steps generated during a Team Build if you use project references within a solution


The excessive output in BuildLog.txt is easy enough to fix. MSBuild 3.5 defaults to diagnostic logging, so appending “/fileLoggerParameters:verbosity=normal” to the TFSBuild.rsp will cut down on the file size considerably.

The Build Steps are unaffected by the verbosity option though and there appears to be no simple flag to cut down on the chatter generated. A Team Builds of 4 or 5 solutions which generated around 400 steps under TFS 2005 now generates over 3000 steps under TFS 2008.

The bulk of these steps are repetitive and rather useless information messages about building targets GetTargetPath, GetNativeManifest, and GetCopyToOutputDirectory. Rather than writing custom tasks to iterate through the BuildStep node tree, I wrote the query below and scheduled it to run every 2 minutes in TFSBuild. It will delete any successful buildstep nodes that mention one of the three targets above. Running this cut our build steps down to a much more manageable size. While I haven’t had any issues with it, Microsoft doesn’t like you touching their tables directly, so buyer beware.

DECLARE @nodes TABLE (NodeId int)

INSERT @nodes
SELECT bif.NodeId
FROM tbl_BuildInformationField bif INNER JOIN tbl_BuildInformation bi
ON bif.NodeId = bi.NodeId INNER JOIN tbl_Build b
ON bi.BuildId = b.BuildId
WHERE (
bif.FieldValue LIKE '%"GetTargetPath".'
OR bif.FieldValue LIKE '%"GetNativeManifest".'
OR bif.FieldValue LIKE '%"GetCopyToOutputDirectoryItems".'
)
AND EXISTS( --only delete nodes that succeeded
SELECT 1
FROM tbl_BuildInformationField status
WHERE status.NodeId = bif.NodeId
AND status.FieldName = 'Status'
AND status.FieldValue = 'Succeeded'
)
AND b.FinishTime IS NOT NULL

DELETE tbl_BuildInformationField
WHERE NodeId IN (SELECT NodeId FROM @nodes)

DELETE tbl_BuildInformation
WHERE NodeId IN (SELECT NodeId FROM @nodes)

Leave a Reply

Your email address will not be published. Required fields are marked *