MSBuild 脚本中的 StyleCop。如何使其在构建过程中仅输出文件而没有警告或错误

发布于 2024-09-15 18:16:34 字数 2513 浏览 9 评论 0原文

我正在使用 StyleCop 4.4.0 RTW。我已经安装了它,将内容复制到版本控制目录,然后通过简单地将这一行添加到每个 .csproj 文件中,将其添加到我的每个项目文件中:

<Import Project="..\Library\StyleCop\v4.4\Microsoft.StyleCop.targets" />

基本功能似乎可以工作。当我在 Visual Studio 中构建项目时,我得到:

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

我得到包含违规的 PROJECTDIR\obj\Debug\StyleCopViolations.xml。

我只想获取输出文件中的 StyleCop 信息。我不想要警告或错误。如果可能的话,我该如何配置它才能像这样工作?

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:

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

南巷近海 2024-09-22 18:16:34

你不能。 StyleCop 任务中没有可用的设置来仅包含输出文件而没有警告或错误。

可能的解决方案:

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

Possible solutions :

少钕鈤記 2024-09-22 18:16:34

如果您打开运行 StyleCop 的项目解决方案文件夹,您可以在其中找到一个名为 StyleCop.Cache 的文件。该文件包含 StyleCop 的输出。如果您想查看 StyleCop 的输出,只需在记事本中打开它即可。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文