How to fetch compilation errors and warnings when using ant+msbuild in RTC
When building a visual studio solution file using the "Jazz Build for Microsoft Visual Studio Solution", using MSBuild , all compilation errors and warnings are nicely displayed in the compilation tab of the build result.
Now I'm trying to achieve the same result using an ANT file for building (as I want to combine the build with several customized pre- and post steps).
Building goes fine, but I can't find out how to process the buildlog so it is displayed the same way (showing the compilation errors and warnings)
I tried several things using antlib:org.apache.ant.dotnet and dn:msbuild, but also with <exec executable="msbuild.exe" .... and so on.
So, basically 3 questions
- is it possible anyway to have the msbuild log processed when using ant so the compile results are shown in the compile tab of the build result?
- if so, does anyone has an example of the ant build statement using msbuild ?
-
is it also possible to have the compile errors and warnings shown when using devenv instead of msbuild?
(running Nunit tests and publishing those results goes fine by the way, so it's only this part)
Thanks for your support.
Accepted answer
3 other answers
Many many thanks to Nick, as he pointed me into the right direction with the example he provided.
So, what is the scenario:
in Ant:
- I use MSBuild to build my solution files (and underlying visual studio project files)
- I create an XML build log using a MSBuild extension pack (found at http://msbuildextensionpack.codeplex.com/; see also http://www.msbuildextensionpack.com/help/4.0.5.0/html/242ab4fd-c2e2-f6aa-325b-7588725aed24.htm)
- translate the xml logging (using ant xslt statement)
- publish the translated xml via the jdtCompileLogPublisher
The translation sheet I used (probably not perfect XLST, but at least it works for the tests I performed):
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" encoding="UTF-8" version="1.0"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/build">
<xsl:text> </xsl:text>
<compiler>
<sources>
<xsl:apply-templates select="//project" />
</sources>
</compiler>
</xsl:template>
<xsl:template match="project">
<xsl:if test="substring(@file, string-length(@file) - 8) != '.metaproj' and substring(@file, string-length(@file) - 3) != '.sln'">
<source package="{@file}" path="{@file}">
<problems>
<xsl:apply-templates/>
</problems>
</source>
</xsl:if>
</xsl:template>
<!-- skip all the message lines in the original output -->
<xsl:template match="message">
<xsl:apply-templates/>
</xsl:template>
<!-- handle warnings -->
<xsl:template match="warning">
<problem id="{@code}" line="{@line}" severity="WARNING">
<xsl:variable name="TheMessageContent">
<xsl:value-of disable-output-escaping="yes" select="."/>
</xsl:variable>
<message value="reports warning {@code}: {$TheMessageContent}"/>
<source_context value="{@file}"/>
<xsl:apply-templates/>
</problem>
</xsl:template>
<!-- handle errors -->
<xsl:template match="error">
<problem id="{@code}" line="{@line}" severity="ERROR">
<xsl:variable name="TheMessageContent">
<xsl:value-of disable-output-escaping="yes" select="."/>
</xsl:variable>
<message value="reports error {@code}: {$TheMessageContent}"/>
<source_context value="{@file}"/>
<xsl:apply-templates/>
</problem>
</xsl:template>
</xsl:stylesheet>
(hmm, looks the forum editor screws up the layout a bit :( )
Hopefully others can use this too.
For me, it shows now clearly the amount of error / warnings per visual studio project file, and the number of compiler warnings can be shown using the appropriate widget.
Once again, thanks 2 all for your support and pointing me in the right direction.
Regards, Pascal
<execute>$Build_Engine_Path/jbe -userId $Build_User -pass $Build_Password -repository $Repository_Address -buildResultUUID $buildResultUuid -engineUUID $engineUUID -participants com.ibm.team.build.jazzscm -noComplete -verbose</execute><resultsblock><match pattern="RC\=[0]"><setenv name="Changes" value="TRUE" type="temp append\n" /></match><match pattern="RC\=[1]"><setenv name="Failure" value="TRUE" type="temp append\n" /></match><match pattern="RC\=[2]"><setenv name="Delete" value="TRUE" type="temp append\n" /></match></resultsblock>
Comments
The latter <resultsblock> part tells Build Forge to pattern match against the output of JBE. RC=0 indicates the build ran, successfully. RC=1 indicates it failed. RC=2 indicates the build was scheduled but there were no new changes to build.
I've filed enhancement request Provide an msbuildLogPublisher Ant task (256426)
> RC=2 indicates the build was scheduled but there were no new changes to build.
Hi all
first of all: thanks for your help so far !
From this post: https://jazz.net/forum/questions/105512/build-setup-for-net-projects
I was also looking at the JbeMsBuildLogger.dll as log filter. I also tried the extension pack of MSBuild. The latter generates great XML, but RTC does not fetch the right info from it.
But to be honest I'm a bit surprised that there is no parser for the msbuild log, in that sense that I get the expected output when invoking msbuild directly from the buildengine (using buildengine type "Jazz Build for Microsoft Visual Studio Solution"). This raised the expectation to me that there was a parser.
I'll dig into Nicks answer tomorrow when I'm back at work.
In that case.
Another option would be to use JbeMsBuildLogger.dll or the extension pack to output the compilation results as XML, then map that XML format to JDT's ECJ (Eclipse Compiler for Java) XML format e.g. using XSLT, then use the jdtCompileLogPublisher Ant task.
Hi Nick
This sounds like the easiest way forward. The XML of the extension pack seems to be quite complete, so I have a good feeling about it.
Do you perhaps have an ant example how to implement this and/or a xlst file that can be used for conversion ?
Thanks a lot for the support!
Sorry, I don't have any good examples of XSLT for this. This thread may help for pointers, but it's for transforming NUnit XML to JUnit XML from before the time we had nunitLogPublisher:
Hi Nick
I dropped you a mail last week. Did you already find an example, as I've been digging in the translator already?
I managed to translate the sheet into a different format, and all I need now is to know to which format/style to translate it.
Thanks and regards
Pascal
Comments
Scott Cowan
JAZZ DEVELOPER Mar 18 '13, 9:45 a.m.Hi Pascal,
Have you seen the Jazz build Ant task reference? Maybe there's something in there that can help.
Scott
Pascal van Kempen
Mar 18 '13, 1:15 p.m.Hi Scott
From the reference you mention I found already out that jdtCompileLogPublisher is the one that publishes the log that is shown in the compilation tab of the eclipse client.
But I'm looking more into which logger or whatsoever is needed (and how to use it) to create the right content for that logfile, so that the warnings and errors are shown.
I see my component now in the tab, and although there are several warnings, the counters are still on "0".
Regards, Pascal
Scott Cowan
JAZZ DEVELOPER Mar 18 '13, 11:20 a.m.Hi Pascal,
I'm thinking we'd need an msbuildLogPublisher that can properly parse an msbuild.log file. I see we have an mstestLogPublisher. I'm thinking this is currently unsupported. I'll ask around.
Scott