Skip to content
Open
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
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 @@ -87,8 +87,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 @@ -766,18 +766,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 @@ -1472,6 +1472,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
6 changes: 3 additions & 3 deletions src/MSBuild/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 @@ -120,6 +119,7 @@ internal enum ParameterizedSwitch
GetResultOutputFile,
FeatureAvailability,
MultiThreaded,
NoLogo,
// This has to be kept as last enum value
NumberOfParameterizedSwitches,
}
Expand Down Expand Up @@ -215,7 +215,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 @@ -297,7 +296,8 @@ internal ParameterizedSwitchInfo(
new ParameterizedSwitchInfo( ["getTargetResult"], ParameterizedSwitch.GetTargetResult, null, true, "MissingGetTargetResultError", true, false, "HelpMessage_45_GetTargetResultSwitch"),
new ParameterizedSwitchInfo( ["getResultOutputFile"], ParameterizedSwitch.GetResultOutputFile, null, true, "MissingGetResultFileError", true, false, "HelpMessage_51_GetResultOutputFileSwitch"),
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( ["multithreaded", "mt"], ParameterizedSwitch.MultiThreaded, null, false, null, true, false, "HelpMessage_49_MultiThreadedSwitch"),
new ParameterizedSwitchInfo( ["nologo"], ParameterizedSwitch.NoLogo, null, false, null, true, false, "HelpMessage_5_NoLogoSwitch")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot update HelpMessage_5_NoLogoSwitch to mention that you can also pass -nologo:false

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the help message to document the boolean parameter support. The help text now shows -noLogo[:true|false] and explicitly mentions that users can specify -nologo:false to show the logo. (c3b9b87)

};

/// <summary>
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 @@ -1468,6 +1469,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.

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

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

Loading