protected override void ProcessRecord() { base.ProcessRecord(); var loggerParameters = new ConsoleLoggerParameters() { Verbosity = Verbosity, PerformanceSummary = PerformanceSummary, DisableConsoleColor = DisableConsoleColor, DisableMPLogging = DisableMPLogging, EnableMPLogging = EnableMPLogging, ErrorsOnly = ErrorsOnly, ForceConsoleColor = ForceConsoleColor, ForceNoAlign = ForceNoAlign, NoItemAndPropertyList = NoItemAndPropertyList, NoSummary = NoSummary, ShowCommandLine = ShowCommandLine, ShowEventId = ShowEventId, ShowTimestamp = ShowTimestamp, Summary = Summary, WarningsOnly = WarningsOnly }; var logger = new LoggerDescription { Assembly = Assembly, ClassName = PSHost.IsPresent ? PSHostLoggerClassName : PSStreamsLoggerClassName, Parameters = loggerParameters.ToString(), Verbosity = Verbosity }; WriteObject(logger); }
/// <summary> /// Gets the MSBuild command-line based on the current properties of this object. /// </summary> /// <param name="useShortSwitchNames"><code>true</code> to use short command-line argument switches like '/nr' instead of '/NodeReuse', otherwise <code>false</code>.</param> /// <returns></returns> public string ToString(bool useShortSwitchNames) { CommandLineBuilder commandLineBuilder = new CommandLineBuilder(); commandLineBuilder.AppendSwitchIfNotNull($"/{(useShortSwitchNames ? "t" : "Target")}:", Targets); commandLineBuilder.AppendSwitchIfNotNull($"/{(useShortSwitchNames ? "p" : "Property")}:", Properties); commandLineBuilder.AppendSwitchIfNotNull($"/{(useShortSwitchNames ? "m" : "MaxCpuCount")}:", MaxCpuCount, minValue: 1); commandLineBuilder.AppendSwitchIfNotNull($"/{(useShortSwitchNames ? "tv" : "ToolsVersion")}:", ToolsVersion); commandLineBuilder.AppendSwitchIfNotNull($"/{(useShortSwitchNames ? "v" : "Verbosity")}:", Verbosity); commandLineBuilder.AppendSwitchIfNotNullOrEmpty($"/{(useShortSwitchNames ? "val" : "Validate")}:", Validate); commandLineBuilder.AppendSwitchIfNotNull($"/{(useShortSwitchNames ? "ignore" : "IgnoreProjectExtensions")}:", IgnoreProjectExtensions); if (ConsoleLoggerParameters != null) { commandLineBuilder.AppendSwitchIfNotNull($"/{(useShortSwitchNames ? "clp" : "ConsoleLoggerParameters")}:", ConsoleLoggerParameters.ToString(useShortSwitchNames)); } commandLineBuilder.AppendSwitchIfTrue($"/{(useShortSwitchNames ? "dfl" : "DistributedFileLogger")}", DistributedFileLogger); foreach (MSBuildLoggerParameters logger in Loggers) { commandLineBuilder.AppendSwitch($"\"/{(useShortSwitchNames ? "l" : "Logger")}:{logger}\""); } commandLineBuilder.AppendSwitchIfNotNull($"/{(useShortSwitchNames ? "nr" : "NodeReuse")}:", NodeReuse); commandLineBuilder.AppendSwitchIfTrue($"/{(useShortSwitchNames ? "noconlog" : "NoConsoleLogger")}", NoConsoleLogger); for (int i = 0; i < FileLoggers.Count; i++) { string index = FileLoggers.Count > 1 ? i.ToString() : String.Empty; commandLineBuilder.AppendSwitch($"/{(useShortSwitchNames ? "fl" : "FileLogger")}{index}"); commandLineBuilder.AppendSwitchIfNotNull($"/{(useShortSwitchNames ? "flp" : "FileLoggerParameters")}{index}:", FileLoggers[i].ToString(useShortSwitchNames)); } foreach (MSBuildDistributedLoggerParameters distributedLogger in DistributedLoggers) { commandLineBuilder.AppendSwitch($"\"/{(useShortSwitchNames ? "dl" : "DistributedLogger")}:{distributedLogger}\""); } if (BinaryLogger != null) { commandLineBuilder.AppendSwitch($"/{(useShortSwitchNames ? "bl" : "BinaryLogger")}{BinaryLogger}"); } commandLineBuilder.AppendSwitchIfNotNullOrEmpty($"/{(useShortSwitchNames ? "pp" : "PreProcess")}:", PreProcess); commandLineBuilder.AppendSwitchIfTrue($"/{(useShortSwitchNames ? "ds" : "DetailedSummary")}", DetailedSummary); commandLineBuilder.AppendSwitchIfTrue($"/{(useShortSwitchNames ? "noautorsp" : "NoAutoResponse")}", NoAutoResponse); commandLineBuilder.AppendSwitchIfTrue("/NoLogo", NoLogo); commandLineBuilder.AppendSwitchIfTrue($"/{(useShortSwitchNames ? "ver" : "Version")}", Version); foreach (string responseFile in ResponseFiles.Where(i => !String.IsNullOrWhiteSpace(i))) { commandLineBuilder.AppendSwitch("@"); commandLineBuilder.AppendTextUnquoted($"\"{responseFile}\""); } commandLineBuilder.AppendFileNameIfNotNull(Project); return(commandLineBuilder.ToString()); }
public ILogger CreateConsoleLogger(ConsoleLoggerParameters consoleLoggerParameters, bool usePSHost) { var verbosity = consoleLoggerParameters.Verbosity ?? LoggerVerbosity.Normal; return(CreateConsoleLogger(verbosity, consoleLoggerParameters.ToString(), usePSHost)); }