1
votes

I'm trying to reduce the verbosity of the output produced by a NANT script since many hours.

I've tried to set the msbuild command link parameters to: /v:m /clp:ErrorsOnly but I still get informations like:

RestorePackages:
     [exec]          Restoring NuGet packages...

I've also tried to set almost everything to verbose in the NANT script but it still get it in the console output

<delete verbose="true"

I've tried to google a lot but I couldn't manage to clear the log of NANT / MSBUILD.

1

1 Answers

1
votes

You can create your own task container that defines log level for the inside code

        [TaskName("loglevel")]
        public class LogLevelTask : TaskContainer
        {
            private Level _logLevel;

            protected override void ExecuteTask()
            {
                Level oldLevel = Project.Threshold;
                try
                {
                    SetLogLevel(_logLevel);
                    base.ExecuteTask();
                }
                finally
                {
                    SetLogLevel(oldLevel);
                }
            }

            [TaskAttribute("level", Required = true)]
            public Level LogLevel
            {
                get
                {
                    return _logLevel;
                }
                set
                {
                    _logLevel = value;
                }
            }

            public void SetLogLevel(Level newLevel)
            {
                foreach(IBuildListener listener in Project.BuildListeners)
                {
                    IBuildLogger logger = listener as IBuildLogger;
                    if(logger != null)
                    {
                        logger.Threshold = newLevel;
                    }
                }
            }
        }

And then you can add it to the nant script

<loglevel level="None"> <!-- You can set any other level -->
    <!-- Do whatever you want -->
</loglevel>

You can read more about here http://www.neovolve.com/2008/01/16/loglevel-nant-task/