Build/Test Issues

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

Started by ClausAppel3Shape on 2,802 views

Hi!

I have NCrunch 3.26.0.4. I have <WarningsAsErrors /> set in my CSPROJ files (new CSPROJ format). I want to use FxCop Analyzers as NuGet packages: https://docs.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 <WarningsAsErrors />. 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?

(Also posted on Stack Overflow.)

Thanks in advance!

Edited

Hi, thanks for posting.

It's possible that NCrunch just isn't copying the .editorconfig file into the workspace used for building your project. Do you have this file included in your .csproj? If not, does including it make any difference?
Remco wrote:It's possible that NCrunch just isn't copying the .editorconfig file into the workspace used for building your project. Do you have this file included in your .csproj? If not, does including it make any difference?

Thanks for the advice! You're right. 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.

Woo! :D
Repeat for all projects, then restart NCrunch engine. Now NCrunch builds.

Is there a way to accomplish this more "globally" than adding the link to .editorconfig to every project?

Thank you
arthgg wrote:Repeat for all projects, then restart NCrunch engine. Now NCrunch builds.

Is there a way to accomplish this more "globally" than adding the link to .editorconfig to every project?

Thank you


Unfortunately not. I'll make a note to see if we can do this implicitly in the engine without any configuration, as it seems like a common case.

Post a reply

Log in to reply.