ConPtySharp 1.0.0
dotnet add package ConPtySharp --version 1.0.0
NuGet\Install-Package ConPtySharp -Version 1.0.0
<PackageReference Include="ConPtySharp" Version="1.0.0" />
<PackageVersion Include="ConPtySharp" Version="1.0.0" />
<PackageReference Include="ConPtySharp" />
paket add ConPtySharp --version 1.0.0
#r "nuget: ConPtySharp, 1.0.0"
#:package ConPtySharp@1.0.0
#addin nuget:?package=ConPtySharp&version=1.0.0
#tool nuget:?package=ConPtySharp&version=1.0.0
ConPtySharp
Managed C# wrapper around Windows ConPTY (Pseudo Console) API.
Create and manage interactive pseudo terminal sessions in .NET using a simple API for:
- Spawning shell processes (
cmd, PowerShell, bash, etc.) - Sending commands programmatically
- Reading live terminal output
- Managing multiple terminal sessions
Built on top of native Windows ConPTY via WinAPI.
Features
✔ ConPTY session creation
✔ Interactive stdin/stdout bridging
✔ Multi-session manager
✔ Live output callbacks
✔ Session output buffering
✔ SafeHandle support
Installation
dotnet add package ConPtySharp
Quick Start
using ConPtySharp.Sessions;
var manager = new ConPtySessionManager();
var session = manager.Create("mysession", "cmd.exe");
session.OnOutput = output =>
{
Console.Write(output);
};
session.SendLine("dir");
session.SendLine("echo Hello from ConPtySharp");
Interactive Example
using ConPtySharp.Sessions;
var id = Console.ReadLine();
var manager = new ConPtySessionManager();
var session = manager.Create(id, "cmd.exe");
session.OnOutput = output =>
{
Console.Write(output);
};
while (true)
{
var input = Console.ReadLine();
if (input == "stop")
{
session.Stop();
return;
}
session.SendLine(input);
await Task.Delay(1000);
}
API
Create Session
var session = manager.Create(
id: "shell1",
cmd: "cmd.exe",
x: 120,
y: 30
);
Send Input
session.Send("help");
session.SendLine("dir");
Receive Output
session.OnOutput = output =>
{
Console.Write(output);
};
Or pull buffered output:
string output = session.GetOutput();
Clear after reading:
string output = session.GetOutputAndClear();
Session Manager
Create:
manager.Create("one");
Get:
var session = manager.Get("one");
Remove:
manager.Remove("one");
List all:
var sessions = manager.GetAll();
Example Use Cases
- Remote shell brokers
- Automation tools
- Terminal emulators
- Bot command execution
- Sandboxed shell sessions
- CI/CD command orchestration
Requirements
- Windows 10 1809+ (ConPTY support)
- .NET 8+ recommended
Example Output
C:\> dir
Volume in drive C is OS
Directory of C:\
file.txt
folder1
C:\>
Roadmap
Planned:
- Async command execution
- Resize support
- Expect-style prompt matching
- PowerShell helpers
- Session pooling
- SafeHandle wrapper for HPCON
License
MIT
Contributing
PRs and issues welcome.
If you find a bug or have ideas for improving ConPTY support, open an issue.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 378 | 4/25/2026 |