Well - I don't have this kind of "StyleCop-summary.xsl" included in my summary - thus I see only the warnings displayed by "compile-msbuild.xsl" report (not sure if this is exactly how it's named in default installation).
Truth be told - I don't really care that much about summary view; whenever I want to see what was wrong I just go to the "Stylecop-details.xsl" link. I've setup our CI to fail the build whenever the violation count exceeds, say, 100 - and as long as it passes - I don't bother;) What I can see is that the structure looks sth like that: > <msbuild startTime="02/21/2011 22:45:31" elapsedTime="00:00:03" > elapsedSeconds="3" success="true"> > <project file="*d:\CI\Scripts\stylecop.RunStylecop.msbuild*" > startTime="02/21/2011 22:45:31" elapsedTime="00:00:03" > elapsedSeconds="3" success="true"> > <target name="StyleCop" startTime="02/21/2011 22:45:31" > elapsedTime="00:00:03" elapsedSeconds="3" success="true"> > <message level="normal"><![CDATA[Running StyleCop...]]></message> > *<warning file="D:\CI\...\SomeCodeFile.cs" line="15" column="1" > timeStamp="02/21/2011 22:45:33"><![CDATA[FP1001: Instance variables > should be prefixed by underscore.]]></warning>* > ... > <message level="normal"><![CDATA[9 violations > encountered.]]></message> > <message level="normal"><![CDATA[StyleCop executed]]></message> > </target> > </project> > </msbuild> (this is the part logged by the logger) and the compile-msbuild.xsl processes this element then in such a way: > <xsl:template match="warning"> > <div style="color:blue"> > <xsl:if test="@file != ''" > > <xsl:value-of select="@file"/> (<xsl:value-of > select="@line"/>,<xsl:value-of select="@column"/>): > </xsl:if> > warning <xsl:value-of select="@code"/>: <xsl:value-of > select="text()" /> > </div> > </xsl:template> So what I would try to do would be firstly trying to get from current <warning> element to <project> and check if it has file attribute equals to the *PATH\stylecop.RunStylecop.msbuild*. (You probably should be able to do it using the xpath - http://www.w3.org/TR/xpath/) And display this warning only if it does not come from this task - as you know you handle it the other way. Alternatively you can probably check the content for SAXXXX code or sth - but this could fail later on if you add some custom rules like in my example above. Probably not the most elegant solution, but should work. Let me know if this is not making sense, or if you have problems with modifying the xslt - I can try to help with that. Matt On 2011-02-21 12:00, östen petersson wrote: > it works very good together with the xsl-files i found here: > http://markmail.org/thread/al2obbfaejohdpt2 > (i can't find them in the actual group so I won't claim they are clean > though) > > however for some reason msbuild writes the results to the log so I > show them twice in the summary area. How does it look on your builds? > > > On Feb 15, 9:37 pm, snake001 <[email protected]> wrote: >> Ah, I didnt even look, to be honest... assumed you just needed the docs >> because you don't >> have yours installed or sth... pretty dumb of me!:) >> >> I can offer you the solution we have in our ccnet server. >> >> We have exec task running msbuild project, like so:> <msbuild> >>> <executable>$(MSBuildPath)</executable> >>> <projectFile>$(StyleCopAnalysisTaskPath)</projectFile> >>> <timeout>120</timeout> >>> <logger>$(MSBuildLoggerPath)</logger> >>> </msbuild> >> My paths are defined as follows in case in doubt: >> >>> <cb:define >>> MSBuildPath="c:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe"/> >>> <cb:define MSBuildLoggerPath="C:\Program >>> Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll"/> >>> <cb:define >>> StyleCopAnalysisTaskPath="d:\CI\Scripts\stylecop.RunStylecop.msbuild"/> >> And the "heart" is the StyleCopAnalysisTask, defined as follows: >> >>> <?xml version="1.0" encoding="utf-8"?> >>> <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" >>> ToolsVersion="3.5"> >>> <UsingTask AssemblyFile="C:\Program >>> Files\MSBuild\Microsoft\StyleCop\v4.3\Microsoft.StyleCop.dll" >>> TaskName="StyleCopTask" /> >>> <PropertyGroup> >>> <TPath>c:\Program >>> Files\MSBuild\ExtensionPack\MSBuild.ExtensionPack.tasks</TPath> >>> </PropertyGroup> >>> <Import Project="$(TPath)"/> >>> <!-- StyleCop --> >>> <ItemGroup> >>> <!-- Add Project to Analyze with StyleCop here --> >>> <Project Include="$(CCNetWorkingDirectory)\*\**\*.csproj" >>> Exclude="$(CCNetWorkingDirectory)\**\*.Spec.csproj" >>> /> >>> </ItemGroup> >>> <Target Name="StyleCop"> >>> <ItemGroup> >>> <ExcludeFiles >>> Include="%(Project.RootDir)%(Project.Directory)**\*.Designer.cs" /> >>> <ExcludeFiles >>> Include="%(Project.RootDir)%(Project.Directory)App_Code\**\*.cs" /> >>> <ExcludeFiles >>> Include="%(Project.RootDir)%(Project.Directory)obj\**\*.cs" /> >>> </ItemGroup> >>> <Message Text="Running StyleCop..." /> >>> <!--<Message Text="Excluding: @(ExcludeFiles)" />--> >>> <CreateItem >>> Include="%(Project.RootDir)%(Project.Directory)**\*.cs" >>> Exclude="@(ExcludeFiles)"> >>> <Output TaskParameter="Include" ItemName="StyleCopFiles" /> >>> </CreateItem> >>> <StyleCopTask ProjectFullPath="$(MSBuildProjectFile)" >>> SourceFiles="@(StyleCopFiles)" >>> AdditionalAddinPaths="@(StyleCopAdditionalAddinPaths)" >>> ForceFullAnalysis="true" >>> DefineConstants="DEBUG TRACE CODE_ANALYSIS" >>> TreatErrorsAsWarnings="true" >>> CacheResults="false" >>> OverrideSettingsFile="$(CCNetWorkingDirectory)\Settings.StyleCop" >>> OutputFile="$(CCNetWorkingDirectory)\stylecop-results.xml" >>> MaxViolationCount="1500"> >>> </StyleCopTask> >>> <Message Text="StyleCop executed" /> >>> </Target> >>> </Project> >> Then the resulting file must be merged: >> >>> <publishers> >>> <merge> >>> <files> >>> <file>stylecop-results.xml</file> >>> </files> >>> </merge> >> Basically, what it does is take all *.csproj files (except the ones with >> .spec.csproj - test projects), >> Then take all *.cs files located under project (s) directories (apart >> from *.designer.cs and stuff like that). >> And run them against stylecop. >> >> Actually it works well enough for me, so that I placed this msbuild task >> in separate file and just include it >> in every project I want to run stylecop on: >> >>> <cb:include href="..\ProjectIncludes\stylecop.RunAnalysis.xml"/> >> As a final note, please note I use MSBuild.ExtensionPack to run the >> stylecop task. >> >> Let me know if you'd be interested in introducing it in your build but >> sth doesn't make sense, will try to elaborate. >> >> -- >> >> And as for your � letter - I promise I did not make it on purpose!:P:) >> >> Matt >> >> On 2011-02-15 10:45, �sten petersson wrote: >> >>> That would have been exactly what I was looking for if it wasn't for >>> the fact that that page was updated last 2005 - the stylecop support >>> came in 1.5 :( >>> //�sten >>> I know this is not the forum for this but why is it that neither >>> google nor microsoft consider my name to be valid and usually as in >>> your reply remove the letter �?? Why not consider the internet to be a >>> global meeting place? :( >>> On Feb 14, 8:38 pm, snake001 <[email protected]> wrote: >>>> Hi, >>>> not sure if this is what you're looking for, but seems like >>>> documentation for ccnet can be found >>>> here:http://ccnet.sourceforge.net/CCNET/Configuring%20the%20Server.html >>>> Or do you specifically ask how to setup stylecop with ccnet? >>>> Matt >>>> On 2011-02-14 13:13, sten petersson wrote: >>>>> I need to set up stylecop and the documentation on thoughtworks is >>>>> still flagged - any one who could post the documentation here or on >>>>> sourceforge? >>>>> best regards >>>>> sten >>
