dotnet-cs 0.0.10

There is a newer version of this package available.
See the version list below for details.
dotnet tool install --global dotnet-cs --version 0.0.10
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local dotnet-cs --version 0.0.10
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=dotnet-cs&version=0.0.10
                    
nuke :add-package dotnet-cs --version 0.0.10
                    

dotnet-cs

A tool that makes it easy to run C# from a file, URI, or stdin.

Currently requires .NET 10 SDK daily build, version 10.0.100-preview.3.25163.13 or later

Installation

dotnet tool install -g dotnet-cs

Usage

cs [<TARGETAPPFILE> [<APPARGS>...]]
<COMMAND> | cs [<APPARGS>...]
cs -
cs [<APPARGS>...] < <CSFILE>

Arguments

Name Description
<TARGETAPPFILE> The file path or URI for the C# file to run. Pass '-' to enter interactive terminal mode.
<APPARGS> Any arguments that should be passed to the C# app

Options

Name Description
-?, -h, --help Show help information
--version Show version information
--edit Edit content in an interactive terminal C# editor
--no-cache Do not use the cache file to determine if the target file is up to date

Examples

Run a C# file named hello.cs in the current directory:

~/apps
$ cs hello.cs
Hello, world!

Run a C# file named hello.cs in a sub-directory and pass an argument to it:

~/apps
$ cs ./utils/hello.cs David
Hello, David!

Run a C# file from https://github.com/DamianEdwards/csrun/tree/main/samples/hello.cs and pass an argument to it:

~/apps
$ cs https://raw.githubusercontent.com/DamianEdwards/csrun/refs/heads/stdin/samples/hello.cs Stephen
Hello, Stephen!

Pipe C# code from a shell string literal to cs:

$ 'Console.WriteLine("Hello, world!");' | cs
Hello, world!

Pipe C# code from shell command output to cs via stdin:

$ cat hello.cs | cs
Hello, world!

Enter interactive stdin mode to just type C# straight into the terminal:

$ cs -
Reading from standard input. Press Ctrl+R to execute..
Console.WriteLine("Hello, world!");
Running...
Hello, world!

Edit a C# file named hello.cs in the current directory:

~/apps
$ cs hello.cs --edit
Interactive C# editor! Press CTRL+R to run, CTRL+ALT+S to save, CTRL+Q to quit.
01 var name = args.Length > 0 ? args[0] : "World";
02 Console.WriteLine($"Hello, {name}!");
Hello, world!
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last updated
0.0.13 150 4/7/2025
0.0.12 100 4/5/2025
0.0.11 165 4/3/2025
0.0.10 154 4/3/2025
0.0.9 83 3/29/2025
0.0.8 103 3/29/2025
0.0.7 149 3/19/2025
0.0.6 134 3/17/2025
0.0.5 66 3/14/2025
0.0.4 67 3/14/2025
0.0.3 131 3/13/2025
0.0.2 137 3/13/2025
0.0.1 134 3/13/2025