TFSBuild 2010 User Activity: IBuildDetail.LastGoodBuildUri == null?

I am trying to use a personalized workflow to automatically create assembly numbers based on a previously completed assembly. This method worked with the MSBuild-based “workflow”, but I cannot get TFS to report the correct “last good build” for the current build definition.

What I'm doing is pretty simple:

IBuildDetail build = context.GetExtension<IBuildDetail>();
IBuildDetail last = build.BuildServer.GetBuild(build.BuildDefinition.LastGoodBuildUri);

I have already launched a successful build in which the activity of my code was forced to have the build number BuildName_1.0.0.0. But when I try to get this assembly and extract the version number, it GetBuildcomplains that LastGoodBuildUriit is null.

The custom assembly template that I use at the end installs both CompilationStatus, and TestStatusin BuildPhaseStatus.Succeeded, so TFS should be able to say that this is a good assembly. What else am I missing?

+3
source share
1 answer

Since you are running this code inside a custom action, you need to make sure:

  • Assembly ( IBuildDetail) is completed and saved on the server before the schedule for this user action.
  • Updated instance IBuildDetailor instance IBuildDefinition( build.BuildDefinition) to get the latest changes from the server.

You can check if your build is complete using IBuildDetail.IsFinished. If it is finished, update the BuildDefinition object with IBuildDefinition.Refresh().

Hope this helps.

+1

All Articles