Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions src/Build.UnitTests/BinaryLogger_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,13 @@ public void UnusedEnvironmentVariablesDoNotAppearInBinaryLog()
</Project>";
TransientTestFolder logFolder = env.CreateFolder(createFolder: true);
TransientTestFile projectFile = env.CreateFile(logFolder, "myProj.proj", contents);
BinaryLogger logger = new();
logger.Parameters = _logFile;
RunnerUtilities.ExecMSBuild($"{projectFile.Path} -bl:{logger.Parameters}", out bool success);

RunnerUtilities.ExecMSBuild($"{projectFile.Path} -bl:{_logFile}", out bool success);
success.ShouldBeTrue();
RunnerUtilities.ExecMSBuild($"{logger.Parameters} -flp:logfile={Path.Combine(logFolder.Path, "logFile.log")};verbosity=diagnostic", out success);

RunnerUtilities.ExecMSBuild($"{_logFile} -flp:logfile={Path.Combine(logFolder.Path, "logFile.log")};verbosity=diagnostic", out success);
success.ShouldBeTrue();

string text = File.ReadAllText(Path.Combine(logFolder.Path, "logFile.log"));
text.ShouldContain("EnvVar2");
text.ShouldContain("value2");
Expand Down Expand Up @@ -230,10 +231,9 @@ private void AssemblyLoadsDuringTaskRun(string additionalEventText)
""";
TransientTestFolder logFolder = env.CreateFolder(createFolder: true);
TransientTestFile projectFile = env.CreateFile(logFolder, "myProj.proj", contents);
BinaryLogger logger = new();
logger.Parameters = _logFile;

env.SetEnvironmentVariable("MSBUILDNOINPROCNODE", "1");
RunnerUtilities.ExecMSBuild($"{projectFile.Path} -nr:False -bl:{logger.Parameters} -flp1:logfile={Path.Combine(logFolder.Path, "logFile.log")};verbosity=diagnostic -flp2:logfile={Path.Combine(logFolder.Path, "logFile2.log")};verbosity=normal", out bool success);
RunnerUtilities.ExecMSBuild($"{projectFile.Path} -nr:False -bl:{_logFile} -flp1:logfile={Path.Combine(logFolder.Path, "logFile.log")};verbosity=diagnostic -flp2:logfile={Path.Combine(logFolder.Path, "logFile2.log")};verbosity=normal", out bool success);
success.ShouldBeTrue();

string assemblyLoadedEventText =
Expand All @@ -245,7 +245,7 @@ private void AssemblyLoadsDuringTaskRun(string additionalEventText)
string text2 = File.ReadAllText(Path.Combine(logFolder.Path, "logFile2.log"));
text2.ShouldNotContain(assemblyLoadedEventText);
text2.ShouldNotContain(additionalEventText);
RunnerUtilities.ExecMSBuild($"{logger.Parameters} -flp1:logfile={Path.Combine(logFolder.Path, "logFile3.log")};verbosity=diagnostic -flp2:logfile={Path.Combine(logFolder.Path, "logFile4.log")};verbosity=normal", out success);
RunnerUtilities.ExecMSBuild($"{_logFile} -flp1:logfile={Path.Combine(logFolder.Path, "logFile3.log")};verbosity=diagnostic -flp2:logfile={Path.Combine(logFolder.Path, "logFile4.log")};verbosity=normal", out success);
success.ShouldBeTrue();
text = File.ReadAllText(Path.Combine(logFolder.Path, "logFile3.log"));
text.ShouldContain(assemblyLoadedEventText);
Expand Down Expand Up @@ -438,22 +438,22 @@ public void SuppressCommandOutputForNonDiagVerbosity()
<Exec Command='echo a'/>
</Target>
</Project>";
BinaryLogger logger = new();
logger.Parameters = _logFile;


TransientTestFolder testFolder = env.CreateFolder(createFolder: true);

TransientTestFile projectFile1 = env.CreateFile(testFolder, "testProject01.proj", contents);
string consoleOutput1 = RunnerUtilities.ExecMSBuild($"{projectFile1.Path} -bl:{logger.Parameters} -verbosity:diag -nologo", out bool success1);
string consoleOutput1 = RunnerUtilities.ExecMSBuild($"{projectFile1.Path} -bl:{_logFile} -verbosity:diag -nologo", out bool success1);
success1.ShouldBeTrue();
var expected1 = $"-nologo -bl:{logger.Parameters} -verbosity:diag {projectFile1.Path}";
var expected1 = $"-nologo -bl:{_logFile} -verbosity:diag {projectFile1.Path}";
consoleOutput1.ShouldContain(expected1);

foreach (var verbosity in new string[] { "q", "m", "n", "d" })
{
TransientTestFile projectFile2 = env.CreateFile(testFolder, $"testProject_{verbosity}.proj", contents);
string consoleOutput2 = RunnerUtilities.ExecMSBuild($"{projectFile2.Path} -bl:{logger.Parameters} -verbosity:{verbosity} -nologo", out bool success2);
string consoleOutput2 = RunnerUtilities.ExecMSBuild($"{projectFile2.Path} -bl:{_logFile} -verbosity:{verbosity} -nologo", out bool success2);
success2.ShouldBeTrue();
var expected2 = $"-nologo -bl:{logger.Parameters} -verbosity:{verbosity} {projectFile2.Path}";
var expected2 = $"-nologo -bl:{_logFile} -verbosity:{verbosity} {projectFile2.Path}";
consoleOutput2.ShouldNotContain(expected2);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Build/Logging/DistributedLoggers/DistributedFileLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private void ParseFileLoggerParameters()
/// </summary>
private void ApplyFileLoggerParameter(string parameterName, string parameterValue)
{
if (String.Equals("LOGFILE", parameterName, StringComparison.OrdinalIgnoreCase))
if (string.Equals("LOGFILE", parameterName, StringComparison.OrdinalIgnoreCase))
{
if (string.IsNullOrEmpty(parameterValue))
{
Expand Down Expand Up @@ -104,7 +104,7 @@ public void Initialize(IEventSource eventSource)
_nodeFileLogger = new FileLogger();
string extension = Path.GetExtension(_logFile);
// If there is no extension add a default of .log to it
if (String.IsNullOrEmpty(extension))
if (string.IsNullOrEmpty(extension))
{
_logFile += ".log";
extension = ".log";
Expand Down
5 changes: 0 additions & 5 deletions src/MSBuild.UnitTests/TerminalLogger_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -383,13 +383,8 @@ public void TestTerminalLoggerTogetherWithOtherLoggers()
TransientTestFolder logFolder = env.CreateFolder(createFolder: true);
TransientTestFile projectFile = env.CreateFile(logFolder, "myProj.proj", contents);

BinaryLogger loggerWithTL = new();
string logFileWithTL = env.ExpectFile(".binlog").Path;
loggerWithTL.Parameters = logFileWithTL;

BinaryLogger loggerWithoutTL = new();
string logFileWithoutTL = env.ExpectFile(".binlog").Path;
loggerWithoutTL.Parameters = logFileWithoutTL;

// Execute MSBuild with binary, file and terminal loggers
RunnerUtilities.ExecMSBuild($"{projectFile.Path} /m /bl:{logFileWithTL} -flp:logfile={Path.Combine(logFolder.Path, "logFileWithTL.log")};verbosity=diagnostic -tl:on", out bool success);
Expand Down
23 changes: 6 additions & 17 deletions src/MSBuild/CommandLineSwitches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@ internal ParameterizedSwitchInfo(
new ParameterizedSwitchInfo( new string[] { "question", "q" }, ParameterizedSwitch.Question, null, false, null, true, false),
new ParameterizedSwitchInfo( new string[] { "detailedsummary", "ds" }, ParameterizedSwitch.DetailedSummary, null, false, null, true, false),
new ParameterizedSwitchInfo( new string[] { "getProperty" }, ParameterizedSwitch.GetProperty, null, true, "MissingGetPropertyError", true, false),
new ParameterizedSwitchInfo( new string[] { "getItem" }, ParameterizedSwitch.GetItem, null, true, "MissingGetItemError", true, false),
new ParameterizedSwitchInfo( new string[] { "getTargetResult" }, ParameterizedSwitch.GetTargetResult, null, true, "MissingGetTargetResultError", true, false),
new ParameterizedSwitchInfo( new string[] { "getItem" }, ParameterizedSwitch.GetItem, null, true, "MissingGetItemError", true, false),
new ParameterizedSwitchInfo( new string[] { "getTargetResult" }, ParameterizedSwitch.GetTargetResult, null, true, "MissingGetTargetResultError", true, false),
};

/// <summary>
Expand All @@ -301,7 +301,7 @@ internal static bool IsParameterlessSwitch(
{
foreach (string parameterlessSwitchName in switchInfo.switchNames)
{
if (String.Equals(switchName, parameterlessSwitchName, StringComparison.OrdinalIgnoreCase))
if (string.Equals(switchName, parameterlessSwitchName, StringComparison.OrdinalIgnoreCase))
{
parameterlessSwitch = switchInfo.parameterlessSwitch;
duplicateSwitchErrorMessage = switchInfo.duplicateSwitchErrorMessage;
Expand All @@ -313,17 +313,6 @@ internal static bool IsParameterlessSwitch(
return false;
}

/// <summary>
/// Identifies/detects a switch that takes no parameters.
/// </summary>
internal static bool IsParameterlessSwitch(
string switchName)
{
ParameterlessSwitch parameterlessSwitch;
string duplicateSwitchErrorMessage;
return CommandLineSwitches.IsParameterlessSwitch(switchName, out parameterlessSwitch, out duplicateSwitchErrorMessage);
}

/// <summary>
/// Identifies/detects a switch that takes parameters.
/// </summary>
Expand Down Expand Up @@ -354,7 +343,7 @@ internal static bool IsParameterizedSwitch(
{
foreach (string parameterizedSwitchName in switchInfo.switchNames)
{
if (String.Equals(switchName, parameterizedSwitchName, StringComparison.OrdinalIgnoreCase))
if (string.Equals(switchName, parameterizedSwitchName, StringComparison.OrdinalIgnoreCase))
{
parameterizedSwitch = switchInfo.parameterizedSwitch;
duplicateSwitchErrorMessage = switchInfo.duplicateSwitchErrorMessage;
Expand Down Expand Up @@ -480,7 +469,7 @@ internal bool SetParameterizedSwitch(
// check if the switch has multiple parameters
if (multipleParametersAllowed)
{
if (String.Empty.Equals(switchParameters) && emptyParametersAllowed)
if (string.Empty.Equals(switchParameters) && emptyParametersAllowed)
{
// Store a null parameter if its allowed
_parameterizedSwitches[(int)parameterizedSwitch].parameters.Add(null);
Expand Down Expand Up @@ -551,7 +540,7 @@ internal string GetEquivalentCommandLineExceptProjectFile()
commandLineA.Sort(StringComparer.OrdinalIgnoreCase);
commandLineB.Sort(StringComparer.OrdinalIgnoreCase);

return (String.Join(" ", commandLineA).Trim() + " " + String.Join(" ", commandLineB).Trim()).Trim();
return (string.Join(" ", commandLineA).Trim() + " " + string.Join(" ", commandLineB).Trim()).Trim();
}

/// <summary>
Expand Down