I'm developing a Visual Studio Extension and I need to show errors in the VS Error List to the user. I want these errors to prevent/break the building/running of the solution, i.e., something like this. How can I achieve this?
I've tried two approaches but both of them only show errors, they do note break/prevent building of the solution:
I've also looked a bit at using Diagnostics but you need ReportDiagnostic which seems to be related to code Analyzers specifically.
What you actually need is a build error. For this, you should use Roslyn technology. See this similar issue.
Reason why the error occurs in Error list but can't break the build:
According to this similar issue, it's by design that the rules from Nuget can break the build in VS IDE while rules from VS extension can't. So we can use the MSBuild magic in nuget to break the build if we need.