Skip to content

About

Run a dotnet C# file or script using .NET 10+

Resources

Code of conduct

Contributing

Security policy

Stars

6 stars

Watchers

0 watching

Forks

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Latest commit

 

History

23 Commits

Folders and files

Repository files navigation

🏃 dotnet-run

Runs a C# file using .NET 10+

Usage

- name: 🏃 C#
  uses: devlooped/dotnet-run@v2
  with:
    # If args has newlines, it will be properly quoted/escaped
    args: |
      --message
      Hi "kzu", I can even mix 'single' quotes
    # Script can be an inline C# script, including nuget packages
    script: |
      #:package Humanizer@2.*
      using Humanizer;
  
      var date = DateTime.Parse("${{ github.event.inputs.date }}");
      var elapsed = DateTime.Now - date;
  
      if (elapsed.TotalSeconds > 0)
          Console.WriteLine($"It's been {elapsed.Humanize()} since {date.Humanize()}");
      else
          Console.WriteLine($"Still {elapsed.Negate().Humanize()} until {date.Humanize()}");

You can also specify a file to run:

- name: 🏃 C#
  uses: devlooped/dotnet-run@v2
  with:
    file: ./script.cs

The file does not need to have a shebang, but if it does, it will be ignored, since this action will always run the file using dotnet run.

If you give the step an id, you can use the output generated by the script in subsequent steps:

- name: 🏃 C#
  id: runcs
  uses: devlooped/dotnet-run@v2
  with:
    script: |
      Console.WriteLine("Hello world");

- name: 👀 output
  # will print "Hello world"
  run: echo "${{ steps.runcs.outputs.output }}"

The action will automatically install .NET 10+ SDK as needed.

Sponsors

Clarius Org MFB Technologies, Inc. SandRock DRIVE.NET, Inc. Keith Pickford Thomas Bolon Reuben Swartz Jacob Foshee Eric Johnson Jonathan Ken Bonny Simon Cropp agileworks-eu Zheyu Shen Vezel ChilliCream 4OTC domischell Adrian Alonso torutek Ryan McCaffery Seika Logiciel Andrew Grant eska-gmbh Geodata AS

Sponsor this project

Learn more about GitHub Sponsors

About

Run a dotnet C# file or script using .NET 10+

Resources

Code of conduct

Contributing

Security policy

Stars

6 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors