Skip to content

Support scripts without extension #49219

@tmds

Description

@tmds

Currently, C# script files require to have the '.cs' extension.

On Linux it is not required for scripts to have a specific extension. To the user there is little difference in invocation of a native binary or a script. It would be nice if C# scripts did not require an extension either.

Reproducer:

Create a script:

$ cat >program.cs <<EOF
#!/usr/bin/dotnet run

Console.WriteLine("Hello world");
EOF
$ chmod +x program.cs 

Script execute with .cs extension:

$ ./program.cs
Hello world

Script does not execute without .cs extension:

$ mv program.cs program
$ ./program
Couldn't find a project to run. Ensure a project exists in /tmp, or pass the path to the project using --project.

cc @DamianEdwards @baronfel

Metadata

Metadata

Assignees

Labels

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

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions