简体   繁体   English

Visual Studio使用代码分析强制执行构建错误

[英]visual studio enforce build error using code analysis

I'm new to C# and the project as well. 我是C#和项目的新手。 My team members are making a lot of spelling mistakes in strings. 我的团队成员在字符串中犯了很多拼写错误。 My manager want that the build should fail if there are spelling errors. 我的经理希望在出现拼写错误的情况下构建失败。 While searching I found out Visual Studio Code Analysis tool and Spell Checker Plugins . 在搜索时,我发现了Visual Studio代码分析工具拼写检查器插件

I have configured Code Analysis tool so that it shows analysis error if there are spelling mistakes. 我已经配置了代码分析工具,以便在出现拼写错误时显示分析错误。 Is there any way to a enforce it as a build failure in such situation? 在这种情况下,是否有任何方法可以强制将其作为构建失败? And is it a good approach? 这是一个好方法吗? Is there any better approach? 有没有更好的办法? I'm using VS2012. 我正在使用VS2012。

EDIT 编辑

I have configured Code Analysis to run on every build. 我已将代码分析配置为在每个版本上运行。 Now it's showing an error on running project after saving the code but if I run the code again (without saving), it runs successfully. 现在,保存代码后,在运行项目时显示错误,但是如果我再次运行代码(不保存),则它将成功运行。 But I want it show show error on every run until Code Analysis errors are resolved. 但是我希望它在每次运行时都显示show错误,直到代码分析错误解决为止。

I don't think enforcing build error using code analysis is a good approach, it is really disturbing for the developer while writing the code and the developer can just turn off or uninstall the plugin in their environment. 我不认为使用代码分析强制执行构建错误不是一种好方法,这确实给开发人员在编写代码时带来麻烦,并且开发人员只能在其环境中关闭或卸载插件。

What you might need to have is setting up a build server that runs the code analysis as part of it. 您可能需要设置一个构建服务器,该服务器在其中运行代码分析。 It could be cruise control .net or team city or sonarqube . 它可能是巡航控制.net团队城市sonarqube

You can run other things on that server, like unit test, auto deployment, complexity report, commenting, etc. 您可以在该服务器上运行其他内容,例如单元测试,自动部署,复杂性报告,注释等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM