Skip to content
4 changes: 2 additions & 2 deletions src/Build.UnitTests/BinaryLogger_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -611,15 +611,15 @@ public void SuppressCommandOutputForNonDiagVerbosity()
TransientTestFile projectFile1 = env.CreateFile(testFolder, "testProject01.proj", contents);
string consoleOutput1 = RunnerUtilities.ExecMSBuild($"{projectFile1.Path} -bl:{_logFile} -verbosity:diag -nologo", out bool success1);
success1.ShouldBeTrue();
var expected1 = $"-nologo -bl:{_logFile} -verbosity:diag {projectFile1.Path}";
var expected1 = $"-bl:{_logFile} -nologo -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:{_logFile} -verbosity:{verbosity} -nologo", out bool success2);
success2.ShouldBeTrue();
var expected2 = $"-nologo -bl:{_logFile} -verbosity:{verbosity} {projectFile2.Path}";
var expected2 = $"-bl:{_logFile} -nologo -verbosity:{verbosity} {projectFile2.Path}";
consoleOutput2.ShouldNotContain(expected2);
}
}
Expand Down
57 changes: 47 additions & 10 deletions src/MSBuild.UnitTests/CommandLineSwitches_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ public void VersionSwitchIdentificationTests(string version)
[InlineData("NoLogo")]
public void NoLogoSwitchIdentificationTests(string nologo)
{
CommandLineSwitches.IsParameterlessSwitch(nologo, out CommandLineSwitches.ParameterlessSwitch parameterlessSwitch, out string duplicateSwitchErrorMessage).ShouldBeTrue();
parameterlessSwitch.ShouldBe(CommandLineSwitches.ParameterlessSwitch.NoLogo);
CommandLineSwitches.IsParameterizedSwitch(nologo, out CommandLineSwitches.ParameterizedSwitch parameterizedSwitch, out string duplicateSwitchErrorMessage, out bool multipleParametersAllowed, out string missingParametersErrorMessage, out bool unquoteParameters, out bool emptyParametersAllowed).ShouldBeTrue();
parameterizedSwitch.ShouldBe(CommandLineSwitches.ParameterizedSwitch.NoLogo);
duplicateSwitchErrorMessage.ShouldBeNull();
}

Expand Down Expand Up @@ -778,18 +778,18 @@ public void SetParameterlessSwitchTests()
{
CommandLineSwitches switches = new CommandLineSwitches();

switches.SetParameterlessSwitch(CommandLineSwitches.ParameterlessSwitch.NoLogo, "/nologo");
switches.SetParameterlessSwitch(CommandLineSwitches.ParameterlessSwitch.Help, "/help");

Assert.Equal("/nologo", switches.GetParameterlessSwitchCommandLineArg(CommandLineSwitches.ParameterlessSwitch.NoLogo));
Assert.True(switches.IsParameterlessSwitchSet(CommandLineSwitches.ParameterlessSwitch.NoLogo));
Assert.True(switches[CommandLineSwitches.ParameterlessSwitch.NoLogo]);
Assert.Equal("/help", switches.GetParameterlessSwitchCommandLineArg(CommandLineSwitches.ParameterlessSwitch.Help));
Assert.True(switches.IsParameterlessSwitchSet(CommandLineSwitches.ParameterlessSwitch.Help));
Assert.True(switches[CommandLineSwitches.ParameterlessSwitch.Help]);

// set it again
switches.SetParameterlessSwitch(CommandLineSwitches.ParameterlessSwitch.NoLogo, "-NOLOGO");
switches.SetParameterlessSwitch(CommandLineSwitches.ParameterlessSwitch.Help, "-HELP");

Assert.Equal("-NOLOGO", switches.GetParameterlessSwitchCommandLineArg(CommandLineSwitches.ParameterlessSwitch.NoLogo));
Assert.True(switches.IsParameterlessSwitchSet(CommandLineSwitches.ParameterlessSwitch.NoLogo));
Assert.True(switches[CommandLineSwitches.ParameterlessSwitch.NoLogo]);
Assert.Equal("-HELP", switches.GetParameterlessSwitchCommandLineArg(CommandLineSwitches.ParameterlessSwitch.Help));
Assert.True(switches.IsParameterlessSwitchSet(CommandLineSwitches.ParameterlessSwitch.Help));
Assert.True(switches[CommandLineSwitches.ParameterlessSwitch.Help]);

// we didn't set this switch
Assert.Null(switches.GetParameterlessSwitchCommandLineArg(CommandLineSwitches.ParameterlessSwitch.Version));
Expand Down Expand Up @@ -1494,6 +1494,43 @@ public void ProcessBooleanSwitchTest()
Should.Throw<CommandLineSwitchException>(() => MSBuildApp.ProcessBooleanSwitch(new[] { "invalid" }, defaultValue: true, resourceName: "InvalidRestoreValue"));
}

[Fact]
public void NoLogoParameterizedSwitchTest()
{
CommandLineSwitches switches = new CommandLineSwitches();

// Test that nologo is now identified as a parameterized switch
CommandLineSwitches.IsParameterizedSwitch("nologo", out CommandLineSwitches.ParameterizedSwitch parameterizedSwitch, out string duplicateSwitchErrorMessage, out bool multipleParametersAllowed, out string missingParametersErrorMessage, out bool unquoteParameters, out bool emptyParametersAllowed).ShouldBeTrue();
parameterizedSwitch.ShouldBe(CommandLineSwitches.ParameterizedSwitch.NoLogo);

// Test setting parameterized nologo switch with explicit true
switches.SetParameterizedSwitch(CommandLineSwitches.ParameterizedSwitch.NoLogo, "/nologo:true", "true", false, true, false);
switches.IsParameterizedSwitchSet(CommandLineSwitches.ParameterizedSwitch.NoLogo).ShouldBeTrue();
switches[CommandLineSwitches.ParameterizedSwitch.NoLogo][0].ShouldBe("true");

// Test setting parameterized nologo switch with explicit false
switches = new CommandLineSwitches();
switches.SetParameterizedSwitch(CommandLineSwitches.ParameterizedSwitch.NoLogo, "/nologo:false", "false", false, true, false);
switches.IsParameterizedSwitchSet(CommandLineSwitches.ParameterizedSwitch.NoLogo).ShouldBeTrue();
switches[CommandLineSwitches.ParameterizedSwitch.NoLogo][0].ShouldBe("false");
}

[Fact]
public void NoLogoBooleanProcessingTest()
{
// Test ProcessBooleanSwitch behavior for nologo
// Default value should be true when no parameters are provided
MSBuildApp.ProcessBooleanSwitch(Array.Empty<string>(), defaultValue: true, resourceName: "InvalidNoLogoValue").ShouldBeTrue();
MSBuildApp.ProcessBooleanSwitch(Array.Empty<string>(), defaultValue: false, resourceName: "InvalidNoLogoValue").ShouldBeFalse();

// Test with explicit true/false values
MSBuildApp.ProcessBooleanSwitch(new[] { "true" }, defaultValue: false, resourceName: "InvalidNoLogoValue").ShouldBeTrue();
MSBuildApp.ProcessBooleanSwitch(new[] { "false" }, defaultValue: true, resourceName: "InvalidNoLogoValue").ShouldBeFalse();

// Test invalid value throws exception
Should.Throw<CommandLineSwitchException>(() => MSBuildApp.ProcessBooleanSwitch(new[] { "invalid" }, defaultValue: true, resourceName: "InvalidNoLogoValue"));
}

public static IEnumerable<object[]> ProcessGraphBuildSwitchData()
{
var emptyOptions = new GraphBuildOptions();
Expand Down
4 changes: 2 additions & 2 deletions src/MSBuild/CommandLine/CommandLineSwitches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ internal enum ParameterlessSwitch
Invalid = -1,
Help = 0,
Version,
NoLogo,
NoAutoResponse,
NoConsoleLogger,
FileLogger,
Expand Down Expand Up @@ -121,6 +120,7 @@ internal enum ParameterizedSwitch
FeatureAvailability,
MultiThreaded,
ParentPacketVersion,
NoLogo,
// This has to be kept as last enum value
NumberOfParameterizedSwitches,
}
Expand Down Expand Up @@ -216,7 +216,6 @@ internal ParameterizedSwitchInfo(
//----------------------------------------------------------------------------------------------------------------------------------------------------------
new ParameterlessSwitchInfo( ["help", "h", "?"], ParameterlessSwitch.Help, null, "HelpMessage_4_HelpSwitch"),
new ParameterlessSwitchInfo( ["version", "ver"], ParameterlessSwitch.Version, null, "HelpMessage_6_VersionSwitch"),
new ParameterlessSwitchInfo( ["nologo"], ParameterlessSwitch.NoLogo, null, "HelpMessage_5_NoLogoSwitch"),
new ParameterlessSwitchInfo( ["noautoresponse", "noautorsp"], ParameterlessSwitch.NoAutoResponse, null, "HelpMessage_8_NoAutoResponseSwitch"),
new ParameterlessSwitchInfo( ["noconsolelogger", "noconlog"], ParameterlessSwitch.NoConsoleLogger, null, "HelpMessage_14_NoConsoleLoggerSwitch"),
new ParameterlessSwitchInfo( ["filelogger", "fl"], ParameterlessSwitch.FileLogger, null, "HelpMessage_20_FileLoggerSwitch"),
Expand Down Expand Up @@ -300,6 +299,7 @@ internal ParameterizedSwitchInfo(
new ParameterizedSwitchInfo( ["featureAvailability", "fa"], ParameterizedSwitch.FeatureAvailability, null, true, "MissingFeatureAvailabilityError", true, false, "HelpMessage_46_FeatureAvailabilitySwitch"),
new ParameterizedSwitchInfo( ["multithreaded", "mt"], ParameterizedSwitch.MultiThreaded, null, false, null, true, false, "HelpMessage_49_MultiThreadedSwitch"),
new ParameterizedSwitchInfo( ["parentpacketversion"], ParameterizedSwitch.ParentPacketVersion, null, false, null, false, false, null),
new ParameterizedSwitchInfo( ["nologo"], ParameterizedSwitch.NoLogo, null, false, null, true, false, "HelpMessage_5_NoLogoSwitch")
Comment thread
YuliiaKovalova marked this conversation as resolved.
// Add to ParameterizedSwitch enum (before NumberOfParameterizedSwitches):
};

Expand Down
4 changes: 2 additions & 2 deletions src/MSBuild/CommandLine/CommandLineSwitchesAccessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ internal CommandLineSwitchesAccessor(CommandLineSwitches switches)

public bool? Version => GetParameterlessSwitchValue(ParameterlessSwitch.Version);

public bool? NoLogo => GetParameterlessSwitchValue(ParameterlessSwitch.NoLogo);

public bool? NoAutoResponse => GetParameterlessSwitchValue(ParameterlessSwitch.NoAutoResponse);

public bool? NoConsoleLogger => GetParameterlessSwitchValue(ParameterlessSwitch.NoConsoleLogger);
Expand Down Expand Up @@ -156,6 +154,8 @@ internal CommandLineSwitchesAccessor(CommandLineSwitches switches)

public string[]? MultiThreaded => GetParameterizedSwitchValue(ParameterizedSwitch.MultiThreaded);

public string[]? NoLogo => GetParameterizedSwitchValue(ParameterizedSwitch.NoLogo);

private bool? GetParameterlessSwitchValue(ParameterlessSwitch switchType) => switches.IsParameterlessSwitchSet(switchType) ? switches[switchType] : null;

private string[]? GetParameterizedSwitchValue(ParameterizedSwitch switchType) => switches.IsParameterizedSwitchSet(switchType) ? switches[switchType] : null;
Expand Down
12 changes: 11 additions & 1 deletion src/MSBuild/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@
</comment>
</data>
<data name="HelpMessage_5_NoLogoSwitch" xml:space="preserve">
<value> -noLogo Do not display the startup banner and copyright message.
<value> -noLogo[:true|false] Do not display the startup banner and copyright message.
Specify -nologo:false to explicitly show the logo.
</value>
<comment>
LOCALIZATION: The following should not be localized:
Expand Down Expand Up @@ -1471,6 +1472,15 @@
LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized.
</comment>
</data>
<data name="InvalidNoLogoValue" xml:space="preserve">
<value>MSBUILD : error MSB1071: NoLogo value is not valid. {0}</value>
<comment>
{StrBegin="MSBUILD : error MSB1071: "}
UE: This message does not need in-line parameters because the exception takes care of displaying the invalid arg.
This error is shown when a user specifies a value for the nologo parameter that is not equivalent to Boolean.TrueString or Boolean.FalseString.
LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized.
</comment>
</data>
<data name="InvalidIsolateProjectsValue" xml:space="preserve">
<value>MSBUILD : error MSB1056: Isolate projects value is not valid. {0}</value>
<comment>
Expand Down
15 changes: 13 additions & 2 deletions src/MSBuild/Resources/xlf/Strings.cs.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 13 additions & 2 deletions src/MSBuild/Resources/xlf/Strings.de.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 13 additions & 2 deletions src/MSBuild/Resources/xlf/Strings.es.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading