开发者

StyleCop in MSBuild script. How make it output file only and no warnings or errors during build

I am using StyleCop 4.4.0 RTW. I have installed it, copied the contents to a version controlled directory and I've added it to each of my project files by simply adding this line to each .csproj-file:

<Im开发者_Go百科port Project="..\Library\StyleCop\v4.4\Microsoft.StyleCop.targets" />

The basic functionality seems to work. When I Build a project in Visual Studio I get:

------ Build started: Project: MyProject.Core, Configuration: Debug Any CPU ------
C:\Windows\Microsoft.NET\Framework\v3.5\Csc.exe /noconfig /nowarn:1701,1702 /errorreport:prompt /warn:4 /define:DEBUG;TRACE /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.EnterpriseServices.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Web.Services.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /debug+ /debug:full /filealign:512 /keyfile:..\Build\myproject.snk /optimize- /out:obj\Debug\MyProject.Core.dll /target:library Controller\AcceptAllAccessController.cs Controller\NoSearchSessionSpecifiedException.cs Controller\DenyAllAccessController.cs Controller\SearchContextExpiredException.cs Controller\SearchEngineFacade.cs Environment\ConnectionSettings.cs Environment\IAccessController.cs Environment\ICache.cs Model\Age.cs Model\Bet.cs Model\Category.cs Model\CategoryGroup.cs Model\Click.cs Model\DateTimeInfo.cs Model\DateTimeRange.cs Model\FileFormat.cs Model\FileFormatCollection.cs Model\Hit.cs Model\Language.cs Model\MetaAttributes.cs Model\QueryCompletionResponse.cs Model\QueryRefinement.cs Model\SearchContext.cs Model\SearchFilter.cs Model\SearchFilterCollection.cs Model\SearchRequest.cs Model\SearchResponse.cs Model\Session.cs Model\SortOrder.cs Model\SpellingSuggestion.cs Properties\AssemblyInfo.cs Util\HexEncoding.cs Util\ParameterConv.cs Util\StringUtil.cs "Web References\WebService\Reference.cs"

Compile complete -- 0 errors, 0 warnings
MyProject.Core -> C:\Users\kentl\Documents\Visual Studio 2008\Projects\WebToWebForms\MyProject.Core\bin\Debug\MyProject.Core.dll
Controller\AcceptAllAccessController.cs(15,1): warning : SA1508: A closing curly bracket must not be preceded by a blank line.
Done building project "MyProject.Core.csproj".
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========

I get PROJECTDIR\obj\Debug\StyleCopViolations.xml containing the violations.

I would like to ONLY get the StyleCop information in the output file. I do not want a warning or error. If it is possible, how do I configure it to work like that?


You can't. There is no setting available in StyleCop task to have only the output file and no warnings or errors.

Possible solutions :

  • Create a Custom MSBuild Logger that will filter StyleCop log (More on info on MSBuild logger).
  • Create a Custom task doing the same thing than StyleCop one but without logging warning and error in console (More info on custom task).
  • Ask for the feature or do it yourself (StyleCop opensource project)


If you open the Project Solution Folder in which StyleCop has run, there you can find one file named as StyleCop.Cache. This file contains the output of StyleCop. If you wanna see the output of StyleCop, Just you will have to open it in the Notepad.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜