'MSBuild Error task show up as a warning in VS

I have an Error task in a C# MSBuild project. The error shows up as a warning in VS2022, below a huge number of other errors that are directly caused by the Error task halting the build. I'd prefer that the other errors don't show up at all, but failing that, the Error task error should at least be on the top of the list and certainly not a mere warning. How can I fix this?

enter image description here

The Error task looks like this:

<Target Name="ShowError">
   <Error Text="ToErrIsHuman" Code="CS0518"/>
</Target>

The Project has InitialTargets="ShowError" to trigger the Error task. The Code attribute does not seem to have any effect.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source