tags:

views:

226

answers:

1

We are seeing extremely strange results where StyleCop will correctly report violations when run from within Visual Studio 2010. However, when we run msbuild on the command line (e.g., "MSBuild.exe mySolution.sln") it reports "No violations encountered" when clearly there are the same violations as when we ran it within Visual Studio. Is this a bug in the latest release of StyleCop? Or in the 2010 integration? Is there anything you can tell me about possible differences with StyleCop executing from within VS.NET versus MSBuild command line? Thanks.

A: 

I figured out the problem to my own question. The setup for this was that, inside our csproj file, we had this:

<Import Project="..\..\lib\StyleCop\Microsoft.StyleCop.targets" />

which is a slight difference from what Microsoft shows here where they do this:

<Import Project="$(ProgramFiles)\MSBuild\Microsoft\StyleCop\v4.3\Microsoft.StyleCop.targets" />

But everything should still work. The problem was that in our lib\StyleCop folder, we only had:

  • Microsoft.StyleCop.Targets
  • Microsoft.StyleCop.dll

We were missing:

  • Microsoft.StyleCop.CSharp.dll
  • Microsoft.StyleCop.CSharp.Rules.dll

which are dynamically discovered. Once we added those 2 other files to our lib\StyleCop folder, now everything is working fine from MSBuild. This enables us to be able to utilize StyleCop without every developer running the installer to put the binaries in the ProgramFiles directory. This also means we don't have to run the installer on the build server.

Steve Michelotti