thank you :)
I have looked around and didn't find any examples of how to to run
stylecop without hacking the csproj file - but this look like it will
do the trick.
I use msbuild community tasks for fxcop and ncover so it will fit
right in

//östen

@craig <- To get devs to document their changes is hard work I know ;)

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
>
>

Reply via email to