Claus Appel
Claus Appel

Reputation: 409

Using NCrunch, FxCop Analyzers and "warnings as errors": How to configure warning severity in NCrunch?

I am coding C#. I use NCrunch to run my unit tests in the background. I have set in my CSPROJ files (new CSPROJ format).

I want to use FxCop Analyzers as NuGet packages: https://learn.microsoft.com/en-gb/visualstudio/code-quality/install-fxcop-analyzers?view=vs-2019

When I first installed the FxCop Analyzers, my code would not build because there were a number of warnings and I have . I've downgraded a bunch of warnings to "suggestion" level by adding this to my .editorconfig:

dotnet_diagnostic.CA2100.severity = suggestion

Now I can build in Visual Studio. But my problem is that NCrunch evidently does not read the .editorconfig file. So NCrunch fails to build the solution because it sees warnings.

How can I configure warning severity levels for NCrunch?

I have NCrunch 3.26.0.4.

Upvotes: 0

Views: 107

Answers (1)

Claus Appel
Claus Appel

Reputation: 409

I found a solution: Apparently the .editorconfig needs to be referenced in each project (csproj file). I had my .editorconfig just as a "solution item". So I did this for each project:

  1. Right-click project in Solution Explorer.
  2. Select Add -> Existing file.
  3. Select the .editorconfig file. Do not click "Add".
  4. Click the arrow next to "Add" and select "Add as link".

Repeat for all projects, then restart NCrunch engine. Now NCrunch builds.

Credit to the NCrunch forum for the solution: https://forum.ncrunch.net/yaf_postsm14118_Using-NCrunch--FxCop-Analyzers-and--warnings-as-errors---How-to-configure-warning-severity.aspx

Upvotes: 0

Related Questions