dotnet-cs
0.0.10
There is a newer version of this package available.
See the version list below for details.
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
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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
nuke :add-package dotnet-cs --version 0.0.10
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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 | Versions 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.