0

Lately I have tried to get all quality and style rules for my team into an .editorconfig file. As ReSharper still has a larger scope of style rules than .NET Analyzers and other such things, and as it has grown to embrace the EditorConfig approach, I have exported all of our ReSharper rules to the .editorconfig file, and deleted our team's DotSettings file. I've been attempting to make almost all rules have a minimum severity of warning, and to have warnings be treated as errors. This goes for ReSharper and the standard VS rules. My end goal is to have our builds break, both locally and on our Azure DevOps Pipelines, if any of the rules in the .editorconfig, from ReSharper or otherwise, are violated.

So far, I have been unable to get ReSharper-specific errors or warnings to break the build in any of the following:

  • Visual Studio build (MSBuild)
  • dotnet build (local)
  • ReSharper Build
  • dotnet build (Azure DevOps YAML Pipeline)

Now I'm starting to suspect that the ReSharper rules are really only for assistance at design time, but that there are no mechanisms to make them actually cause a build to fail. I'm hoping I'm wrong and that I just need to change a configuration or install some kind of add-on locally and/or on Azure DevOps.

bubbleking
  • 3,329
  • 3
  • 29
  • 49

1 Answers1

0

As you already suspected, some of your criteria cannot be met ootb, namely:

  • Visual Studio build (MSBuild)
  • dotnet build (local)
  • dotnet build (Azure DevOps YAML Pipeline)

This is because R# is an IDE feature and low(er)-level tools like MSBuild or the .NET global tools are simply unaware of R#, its rules, etc.
I think one had to write a Roslyn analyzer to enable this because this is Microsoft's intended way of integrating custom code checks into the build pipeline.
Another option would be to use InspectCode out of the R# Command Line Tools. If you integrate this tool into your build pipeline, it will fail when specific R# rules are violated.

But you should be able to make builds fail using R# Builds when setting the severity of all your relevant rules inside .editorconfig to error.

mu88
  • 4,156
  • 1
  • 23
  • 47
  • Thanks, I'm working through this and will come back to this answer. Your last sentence, as I take it, means I can't have R# builds fail on warnings, but just errors? I'm trying to fail builds on warnings. – bubbleking Sep 29 '22 at 18:50
  • Then you need to set `true` - builds otherwise never fail on warnings – mu88 Oct 03 '22 at 05:51