How to have MSBuild quiet output but with error/warning summary
late to the party, but MSBuild has the option /verbosity:quiet
now and it doesn't print out anything beside error and warnings.
You can specify the following verbosity levels:
q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]
Documentation source: https://msdn.microsoft.com/en-us/library/ms164311.aspx
Use /consoleloggerparameters:ErrorsOnly
or clp:ErrorsOnly
to solve your problem.
I don't think there is a set of options thet matches what you want exactly. But since you're on the commandline anyway, using findstr/grep/tail and the likes is always a good option. Here's an example using powershell to display the summary and what comes after it
powershell -Command "msbuild.exe /nologo project.sln |
Select-String 'Build succeeded|failed' -Context 0, 100"
Another possibility is to use a custom logger, which is not hard as it sounds at first and there are tons of examples on the net. Plus it has the benefit you can get any custom output you want. Here's code to replicate the summary:
using System;
using Microsoft.Build.Utilities;
using Microsoft.Build.Framework;
public class CustomLogger : Logger
{
private int warnings = 0;
private int errors = 0;
public override void Initialize( IEventSource eventSource )
{
eventSource.WarningRaised += ( s, e ) => ++warnings;
eventSource.ErrorRaised += ( s, e ) => ++errors;
eventSource.BuildFinished += ( s, e ) =>
{
Console.WriteLine( errors == 0 ? "Build succeeded." : "Build failed." );
Console.WriteLine( String.Format( " {0} Warning(s)", warnings ) );
Console.WriteLine( String.Format( " {0} Error(s)", errors ) );
};
}
}
Put this in a file CustomLogger.cs and compile it:
csc /t:library CustomLogger.cs /reference:Microsoft.Build.Utilities.v4.0.dll;Microsoft.Build.Framework.dll
which creates a CustomLogger dll file. Now use it like this:
msbuild /nologo /logger:CustomLogger.dll /noconsolelogger project.sln
Use /verbosity:minimal
instead. This prints much less, but not nothing.