如果有未使用的命名空间,是否有任何工具或方法会使构建失败

时间:2019-04-12 08:31:23

标签: c# visual-studio resharper

Visual Studio Resharper 突出显示未使用的名称空间,但是它们生成任何警告,因此我们无法使用 Treat警告为错误,并且项目编译良好:

enter image description here

2 个答案:

答案 0 :(得分:0)

我找到了CI(连续集成)解决方案。您可以使用Inspections in TeamCity

  1. 创建构建步骤Inspections (Resharper)
  2. 添加Failure Conditions Fail build on metric change(检查警告数量)。

https://www.jetbrains.com/help/resharper/Detect_code_issues_in_a_build_using_ReSharper_and_TeamCity.html

答案 1 :(得分:-1)

Resharper可以在边栏中显示警告,但可以配置为显示我认为的错误。

StyleCop也许也可以做到这一点。快速的Google搜索使我相信IDE0005启用了此功能。