开发者

StyleCop 4.4 works inside VS.NET 2010 but not MSBuild command line

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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜