/// <summary>
        /// Adds a file logger.
        /// Each file logger will be declared in the order added.
        /// The first file logger will match up to the /fl parameter.
        /// The next nine (max) file loggers will match up to the /fl1 through /fl9 respectively.
        /// </summary>
        /// <param name="settings">The settings.</param>
        /// <param name="fileLoggerParameters">Parameters to be passed to the logger.</param>
        /// <returns>The same <see cref="MSBuildSettings"/> instance so that multiple calls can be chained.</returns>
        public static MSBuildSettings AddFileLogger(this MSBuildSettings settings, MSBuildFileLogger fileLoggerParameters)
        {
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }
            if (fileLoggerParameters == null)
            {
                throw new ArgumentNullException(nameof(fileLoggerParameters));
            }
            settings.FileLoggers.Add(fileLoggerParameters);

            return(settings);
        }
Пример #2
0
        private string GetLoggerArgument(int index, MSBuildFileLogger logger)
        {
            if (index >= 10)
            {
                throw new InvalidOperationException("Too Many FileLoggers");
            }

            var counter  = index == 0 ? string.Empty : index.ToString();
            var argument = $"/fl{counter}";

            var parameters = logger.GetParameters(_environment);

            if (!string.IsNullOrWhiteSpace(parameters))
            {
                argument = $"{argument} /flp{counter}:{parameters}";
            }
            return(argument);
        }