Build Fails due to CA warnings

Hi all,

I have a project that builds fine in VS2022, giving a set of warnings about a specific code analysis issue (CA1815). In Rider, the same project cannot be built, showing the same set of issues as errors. When I right click on an error, it only gives me the options to Jump to Source or copy. If I go to source, I don't get the error/warning in the Context Actions, so there's no way to change the severity level.

I've searched the settings and cannot find either the specific issues or any general setting for treating warnings as errors. Short of solving the issues, is there any way to disable treating these warnings as errors and failing the build? I'm often dealing with legacy code that I do not control and cannot change, so treating these issues as build failures is a show stopper. 

Any help would be appreciated! 

Comment actions Permalink

Hello Todd,

I am sorry to hear that you encounter such an issue.

Would you mind confirming that you are able to Build your solution in Visual Studio?

We would appreciate it if you could share your .csproj file with us.
You can copy-paste it here or upload it to the [Upload Service]( and let me know the Upload ID.

Thank you in advance!

Comment actions Permalink

Such warning should not prevent Rider from building the project unless the project is configured for that.

I assume there is some analyzer is configured for your project that leads to this behavior. 

While investigating, I noticed that Visual Studio does allow to start project via `Run`(triangle) button, even with the analyzers that are configured to prevent a project from being built because of some warnings (as, for example, I took CA1815), but an attempt to build project leads to build failure.
So with the same project configuration, while Rider doesn't allow to `Run` or `Build` a project because of sample warnings, the behavior in Visual Studio:

  • a project might be started via `Run` button, and the appropriate .dll is being generated during this build. 
  • the attempt to `Build | Build Solution` leads to the build failure with the mentioned warnings.

To get the understanding and suggest a solution for the issue, we would appreciate it if you could share the additional information as described below:

1. Let me know if you have the following checkboxes enabled or not:

  • `File | Settings | Editor | Inspection Settings | Roslyn | Enable Roslyn analyzers and Source Generators`;
  • `File | Settings | Editor | Inspection Settings | Read settings from editorconfig, project settings and rule sets`;
  • `File | Settings | Editor | Code Style | Enable StyleCop support;
  • `File | Settings | Editor | Code Style | Enable EditorConfig support;

2. Please share your .csproj file;
3. Please check if you have an .editorconfig/.ruleset/.stylecop file in your project/solution directory and share this file if there is such;

As a confirmation of my assumption, you might try to reproduce this issue with a template project. I assume you will be able to run and build such project without errors, as there will be no custom analyzer configured.

Comment actions Permalink

Hi Dmitry, 

Thanks for getting back to me with the detailed response. Let me start by confirming that your assumption was correct. I created a template project, dropped the code in and had no issue. I went to all 4 settings you listed above and turned them all on and tried building, then turned them all off and tried building. No change in either project - my original continued to fail, the templated one continued to build. 

I do have an .editorconfig file in the solution and when I removed it, I got a different set of warnings that failed the build. When I fix those errors, the original warnings reappeared and failed the build.

I uploaded the project file (Upload id: 2022_05_05_UCXc9NAY4j6nYW8o). I'm happy to give any other information or work with you to try other ideas to get to the bottom of this.



Comment actions Permalink

Hello Todd,

Thank you for the details shared. It is a meaningful detail that removing the .editorconfig file doesn't help and leads the warnings to reappear. Are you sure there is no {some}.ruleset file in your solution/project directories? If there is such, would you mind sharing it with me? We might find clues there. 

I analyzed the `GroomingInferencing.Service.Tests.csproj` file you shared and I didn't find clues, that might help our investigation. I see this is a tests project .csproj file. Are there any reasons you shared this exact .csproj file?

I assume we should find a clue in the main project file, which this tests project has reference to: `..\GroomingInferencing.Service\GroomingInferencing.Service.csproj`

Would you mind sharing two more items with me:

  • GroomingInferencing.Service.csproj
  • Screenshot of solution explorer, so I could get more understanding of the project structure; You can fold all the folders with source files. I need only the projects to be unfolded.

Thank you in advance!


Please sign in to leave a comment.