In my project's settings in Visual Studio, I have set 'Treat warnings as errors' to 'All'. The Warning level is set to 4. I tested this by deliberately introducing code that violates CA1305, but it builds (and rebuilds) successfully, returning a Warning. What I expected was that the build would fail and an Error would be returned. Is my understanding wrong?
相关问题
- Visual Studio 2010 randomly says the command line
- (ASP.NET) Project file must include 'WindowsBa
- Partial Form Class C# - Only display code view for
- Why does this code not compile?
- Does Visual Studio 2010 Professional support UML m
相关文章
- How to show location of errors, references to memb
- Log4Net Multiple Projects
- Compiling error in C++ project with C and C++ code
- How to use Mercurial from Visual Studio 2010?
- VSIX: execute code on VS startup
- Copy different file to output directory for releas
- How do we alias a Sql Server instance name used in
- visual studio 2010 confirmation on close
You could use the "CodeAnalysisTreatWarningsAsErrors" property in your csproj-file like described here:
http://blogs.msdn.com/b/codeanalysis/archive/2007/08/08/_24002800_codeanalysistreatwarningaserrors_2900_-msbuild-property.aspx
This can be used with in combination with
<StyleCopTreatErrorsAsWarnings>false</StyleCopTreatErrorsAsWarnings>
, which will have the same effect on StyleCop warnings.Code Analysis uses a different mechanism to treat warnings as errors. To have Code Analysis warnings treated as such, add a new Code Analysis Ruleset to your solution. To do so, rightclick your solution and choose "Add new item...". Search for "Rule Set" and select to add a new "Code Analysis Rule Set". Give it any name you want.
In the Rule Set Editor, select the rules you want to include in your project and set them to Error. You can choose which rules to treat as errors and which as warnings.
Set the name for the rule set in the Code Analysis Ruleset properties window and save it. Then open the
Analyze->Configure Code Analysis for Solution
menu item.Select your "As Error" ruleset for your projects and apply.