Force build to fail when warnings > N
According to the Interface IEventSource:
Defines the events raised by the build engine. Loggers receive an object implementing this interface in their Initialize method and use it to subscribe to the events they are interested in receiving.
So we could use a customer logger, which can be written in .NET, such as C#. After searching for a long time, I found a similar problems:
How can I treat MSB3245 (could not resolve reference) warning as an error?
You can refer to the stijn`s answer for detail info.
To resolve this issue, you can try to use class WarningRaised
to calculate the number of warnings:
public class ScanLogger : Logger
{
private int warnings = 0;
public override void Initialize(IEventSource eventSource)
{
eventSource.WarningRaised += (s, e) => ++warnings;
{
eventSource.MessageRaised += (s, e) =>
Common.errorsOccurred |= (warnings >= 600);
}
}
See below link for detail info about: IEventSource Interface
Hope this helps.