Search code examples
c#compiler-constructioncode-analysisroslynroslyn-code-analysis

Roslyn - Throw build error


Looking through Roslyn's documentation, I could not find anything about failing the build. I have currently built an analyzer tool that will look to see if methods are missing a tag and notify the developer with a suggestion to add this tag. But what I want to do is be able to fail the build if they attempt to build the project.

I saw places online where devs have been using: CodeIssue but I do not think this would work.

This would be similar to how stylecop works when it fails the build.

Has anyone found any examples/resources where it can return a build failed with errors?


Solution

  • You can set the compiler options to treat your analyzer's warning ID as an error, just like with built-in warnings.