0

Ok, here's the thing:

I'm driving myself nuts trying to get the WARNINGS from a IBuildDetail object when invoking a CustomActivity.

This is what I've tried:

private static List<IBuildInformationNode> GetBuildWarnings(IBuildDetail buildInformation)
{
    var warnings = buildInformation.Information.GetNodesByType(InformationTypes.BuildWarning);

    if (warnings.Count == 0 && buildInformation.CompilationStatus == BuildPhaseStatus.Succeeded)
    {
        buildInformation.RefreshAllDetails();
        warnings = buildInformation.Information.GetNodesByType(InformationTypes.BuildWarning);
    }
    return warnings;
}

That gives me 0 WARNINGS.

I've also tried the same code using :

var warnings = InformationNodeConverters.GetBuildWarnings(buildInformation);

which still brings no warnings.

This CustomActivity is invoked at the end of the Workflow: I actually don't have any issues retrieving the rest of the details like build status, build errors, test information, etc.

The issue is only with the Warnings.

Funny thing is that, at the end of the build, when I check the build results, there ARE warnings.

Any ideas?

Thanks in advance!

Silvestre
  • 804
  • 11
  • 25

2 Answers2

0

Is it possible that the warnings are happening after your custom activity is run. Can you examine the build log and see exactly where the warnings occur?

Dylan Smith
  • 22,069
  • 2
  • 47
  • 62
  • Thanks for responding. I can see the warnings in the msbuild log file already, which is previous to my custom activity invocation. I also see them in the Build Details in Visual Studio, when I double click the run build, right in the Summary. Another data is that I have a separate console and I'm querying the build definitions programmatically (out of the workflow/customactivity) and I'm having the same result: no warnings, rest of the build details are fine. – Silvestre Dec 12 '13 at 17:03
0

buildDetail.Information.GetNodesByType(InformationTypes.BuildWarning) does not return what you're looking for because messages from tracking participant are not flushed immediately.

InformationNodeConverters.GetBuildWarnings internally calls GetNodesByType(), thus it won't work for same reason.

Original information is kept in internal field of TrackingParticipant, thus it is inaccessible. Anyway, if you wait >15seconds, information from this internal field is flushed to accessible field.

Thus the ugly hack that does the job seems to be:

System.Threading.Thread.Sleep(16000);
var trackingParticipant = context.GetExtension<Microsoft.TeamFoundation.Build.Workflow.Tracking.BuildTrackingParticipant>();
var warnings = GetWarnings(trackingParticipant.GetActivityTracking(context));


    private List<IBuildInformationNode> GetWarnings(IActivityTracking activityTracking ){
        IBuildInformationNode rootNode = getRootNode( activityTracking.Node );
        return rootNode.Children.GetNodesByType(InformationTypes.BuildWarning, true);
    }

    private IBuildInformationNode getRootNode( IBuildInformationNode  node)
    {
        while( node.Parent != null ) node = node.Parent;
        return node;
    }