zo-
zo-

Reputation: 140

How do I integrate StyleCop 4.5.25 into msbuild in VS2010?

How do I setup StyleCop 4.5.25 (via NuGet package manager in VS2010) to integrate with MSBuild?

I currently have StyleCop 4.4 and the following setup: http://stylecop.codeplex.com/wikipage?title=Running%20StyleCop%20in%20VS2005%20or%20VS%20Express&referringTitle=Documentation

My goal is to switch from the current setup to using Nuget as my package manager for Stylecop while retaining the biuld integration. There are only 2 files in the package installed by Nuget(src\packages\StyleCop.4.5.25.0\lib\net35): StyleCop.dll and StyleCop.CSharp.dll. Since there is no targets file, I am not sure how to integrate this new version.

Upvotes: 3

Views: 1176

Answers (2)

Robert.K
Robert.K

Reputation: 506

In your msbuild file add:

<!--this will import stylecop as a task -->
<UsingTask AssemblyFile="$(StyleCopInstallDirectory)Microsoft.StyleCop.dll" TaskName="StyleCopTask"/>

<Target Name="RunStyleCop" >
    <StyleCopTask
        ProjectFullPath="$(MSBuildProjectFile)"
        SourceFiles="@(StyleCopFiles)"
        ForceFullAnalysis="$(StyleCopForceFullAnalysis)"
        DefineConstants="$(DefineConstants)"
        TreatErrorsAsWarnings="$(StyleCopTreatErrorsAsWarnings)"
        CacheResults="$(StyleCopCacheResults)"
        OverrideSettingsFile="$(StyleCopOverrideSettingsFile)" />
</Target>

Upvotes: 1

Danny Tuppeny
Danny Tuppeny

Reputation: 42333

A colleague recently tried to do something similar. It looks like the NuGet package contains only the libraries for creating StyleCop rules. It does not contain everything you need to run StyleCop as part of the build process.

For now, we just committed the StyleCop stuff, but we're hoping a NuGet package to set it all up appears soon!

Upvotes: 0

Related Questions