Skip to content

Commit 6f8a284

Browse files
Copilotbaronfel
andauthored
Fix confusing environment option help text in dotnet run command (#50795)
Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: baronfel <[email protected]>
1 parent 449ab3b commit 6f8a284

19 files changed

+362
-34
lines changed

src/Cli/dotnet/CliStrings.resx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,18 @@ setx PATH "%PATH%;{0}"
512512
<data name="CmdEnvironmentVariableDescription" xml:space="preserve">
513513
<value>Sets the value of an environment variable.
514514
Creates the variable if it does not exist, overrides if it does.
515+
This argument can be specified multiple times to provide multiple variables.
516+
517+
Examples:
518+
-e VARIABLE=abc
519+
-e VARIABLE="value with spaces"
520+
-e VARIABLE="value;seperated with;semicolons"
521+
-e VAR1=abc -e VAR2=def -e VAR3=ghi
522+
</value>
523+
</data>
524+
<data name="CmdTestEnvironmentVariableDescription" xml:space="preserve">
525+
<value>Sets the value of an environment variable.
526+
Creates the variable if it does not exist, overrides if it does.
515527
This will force the tests to be run in an isolated process.
516528
This argument can be specified multiple times to provide multiple variables.
517529

src/Cli/dotnet/Commands/Test/TestCommandParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ private static Command GetVSTestCliCommand()
278278

279279
command.Options.Add(SettingsOption);
280280
command.Options.Add(ListTestsOption);
281-
command.Options.Add(CommonOptions.EnvOption);
281+
command.Options.Add(CommonOptions.TestEnvOption);
282282
command.Options.Add(FilterOption);
283283
command.Options.Add(AdapterOption);
284284
command.Options.Add(LoggerOption);

src/Cli/dotnet/Commands/Test/VSTest/TestCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ private static TestCommand FromParseResult(ParseResult result, string[] settings
232232
msbuildPath);
233233

234234
// Apply environment variables provided by the user via --environment (-e) option, if present
235-
if (result.GetValue(CommonOptions.EnvOption) is { } environmentVariables)
235+
if (result.GetValue(CommonOptions.TestEnvOption) is { } environmentVariables)
236236
{
237237
foreach (var (name, value) in environmentVariables)
238238
{

src/Cli/dotnet/CommonOptions.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,15 +338,19 @@ public static ForwardedOption<bool> InteractiveOption(bool acceptArgument = fals
338338
}
339339
.ForwardIfEnabled([$"--property:SelfContained=false", "--property:_CommandLineDefinedSelfContained=true"]);
340340

341-
public static readonly Option<IReadOnlyDictionary<string, string>> EnvOption = new("--environment", "-e")
341+
public static Option<IReadOnlyDictionary<string, string>> CreateEnvOption(string description) => new("--environment", "-e")
342342
{
343-
Description = CliStrings.CmdEnvironmentVariableDescription,
343+
Description = description,
344344
HelpName = CliStrings.CmdEnvironmentVariableExpression,
345345
CustomParser = ParseEnvironmentVariables,
346346
// Can't allow multiple arguments because the separator needs to be parsed as part of the environment variable value.
347347
AllowMultipleArgumentsPerToken = false
348348
};
349349

350+
public static readonly Option<IReadOnlyDictionary<string, string>> EnvOption = CreateEnvOption(CliStrings.CmdEnvironmentVariableDescription);
351+
352+
public static readonly Option<IReadOnlyDictionary<string, string>> TestEnvOption = CreateEnvOption(CliStrings.CmdTestEnvironmentVariableDescription);
353+
350354
private static IReadOnlyDictionary<string, string> ParseEnvironmentVariables(ArgumentResult argumentResult)
351355
{
352356
var result = new Dictionary<string, string>(

src/Cli/dotnet/xlf/CliStrings.cs.xlf

Lines changed: 26 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/xlf/CliStrings.de.xlf

Lines changed: 26 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/xlf/CliStrings.es.xlf

Lines changed: 26 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/xlf/CliStrings.fr.xlf

Lines changed: 26 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/xlf/CliStrings.it.xlf

Lines changed: 26 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/xlf/CliStrings.ja.xlf

Lines changed: 26 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)