Skip to content

Passing a filename as an argument using the dotnet App.cs command isn’t working. #52108

@egvijayanand

Description

@egvijayanand

Describe the bug

Passing a filename as an argument using the dotnet App.cs command isn’t working.

There is a bug in the argument validation part.

To Reproduce

if (args.Length == 0)
{
    Console.WriteLine("Filename input is not provided.");
    return;
}

Console.WriteLine($"{Path.Combine(Environment.CurrentDirectory, args[0])}");
  • Save this snippet to a file named, say App.cs.
  • Then run dotnet App.cs.
  • Will print the Console message requesting the filename input.
  • Now run dotnet App.cs App.cs.
  • It's still printing the earlier Console message as part of input validation.
  • Now pass the input without the file extension, like dotnet App.cs App
  • Will print the absolute path of the input, of course, without the file extension.
  • There is a bug in the argument validation part when the argument has a dot in it.

Exceptions (if any)

Further technical details

details of dotnet --info

- CLI - .NET 10 SDK 10.0.101

Metadata

Metadata

Assignees

Labels

Area-run-fileItems related to the "dotnet run <file>" effort

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions