Over the last few months I have seen that some of the automated builds that we have setup aren’t producing code churn data in reports. The issue hasn’t been a high priority and I have searched online to try and find a quick fix but couldn’t find anything that related to our issues…
No errors were being reported and when I actually looked into the Team Foundation Server warehouse database tables the BuildChangesetSK table didn’t contain any rows for the affected builds.
Last week I decided to find and solve the issue! Reading this discussion on msdn helped me localize the problem. Martin Hinshelman’s great overview of how different artifacts are associated to each other – especially the section on build/changeset associations and Martin Woodwards explanation of how TFS handles the first build.
It turns out that you need to have your build definition set up with both “Associate Changesets and Work Items” and “Label Sources” set to true to get code churn calculated. Once we set that up the first build directly after does not include code churn but after that it all works as expected.