diff --git a/GitVersionExe/Program.cs b/GitVersionExe/Program.cs index 8accbb99fd..807cfb449f 100644 --- a/GitVersionExe/Program.cs +++ b/GitVersionExe/Program.cs @@ -36,6 +36,9 @@ static void Main() return; } + if (!string.IsNullOrEmpty(arguments.Proj) || !string.IsNullOrEmpty(arguments.Exec)) + arguments.Output = OutputType.BuildServer; + ConfigureLogging(arguments); var gitPreparer = new GitPreparer(arguments); @@ -142,11 +145,16 @@ static IEnumerable GetApplicableBuildServers(Arguments arguments) static void ConfigureLogging(Arguments arguments) { - Action writeAction = x => { }; + var writeActions = new List>(); + + if (arguments.Output == OutputType.BuildServer) + { + writeActions.Add(Console.WriteLine); + } if (arguments.LogFilePath == "console") { - writeAction = Console.WriteLine; + writeActions.Add(Console.WriteLine); } else if (arguments.LogFilePath != null) { @@ -158,7 +166,7 @@ static void ConfigureLogging(Arguments arguments) using (File.CreateText(arguments.LogFilePath)) { } } - writeAction = x => WriteLogEntry(arguments, x); + writeActions.Add(x => WriteLogEntry(arguments, x)); } catch (Exception ex) { @@ -166,9 +174,9 @@ static void ConfigureLogging(Arguments arguments) } } - Logger.WriteInfo = writeAction; - Logger.WriteWarning = writeAction; - Logger.WriteError = writeAction; + Logger.WriteInfo = s => writeActions.ForEach(a => a(s)); + Logger.WriteWarning = s => writeActions.ForEach(a => a(s)); + Logger.WriteError = s => writeActions.ForEach(a => a(s)); } static void WriteLogEntry(Arguments arguments, string s)