Skip to content

Fixed to be able to use ’shell: dotnet run {0}' #3885

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hanachiru
Copy link

@hanachiru hanachiru commented Jun 2, 2025

Summary

Since .NET10 Preview 4, it is possible to run a standalone .cs file directly.

$ ls
app.cs
$ dotnet run app.cs

ref: https://devblogs.microsoft.com/dotnet/announcing-dotnet-run-app/

So I would like to write the following code.

- uses: actions/setup-dotnet@v4
  with:
    dotnet-version: "10.0.x"
    dotnet-quality: "preview"
- name: Sandbox
  shell: dotnet run {0}
  run: |
    Console.WriteLine("Hello, world!");

But I found that it only works if the extension is .cs.

$ dotnet run sample.cs    
Hello, World!
$ dotnet run sample2
Couldn't find a project to run. Ensure a project exists in /Users/hanachiru/Sandbox, or pass the path to the project using --project.

So I added the extension .cs if shellCommand is dotnet.

Changes

  • If the shellCommand is dotnet, add the extension .cs.

Note

I would like to discuss with the reviewer whether to add ["dotnet"] = "run {0}" to the _defaultArguments.

private static readonly Dictionary<string, string> _defaultArguments = new(StringComparer.OrdinalIgnoreCase)
{
["cmd"] = "/D /E:ON /V:OFF /S /C \"CALL \"{0}\"\"",
["pwsh"] = "-command \". '{0}'\"",
["powershell"] = "-command \". '{0}'\"",
["bash"] = "--noprofile --norc -e -o pipefail {0}",
["sh"] = "-e {0}",
["python"] = "{0}"
};

@hanachiru hanachiru requested a review from a team as a code owner June 2, 2025 04:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant