process-api-net11
Was er macht
Dieser Skill erklärt, wie die neuen Process-APIs in .NET 11 externe Programme ausführen, ihre Ausgabe erfassen und ihre Lebensdauer steuern. Er ist für Entwickler gedacht, die .NET-11-Apps bauen, die andere Programme starten.
Wann du ihn nutzt
- ✓Wenn deine .NET-11-App ein externes Programm ausführen und seine Ausgabe erfassen muss.
- ✓Wenn Kindprozesse sich automatisch beenden sollen, sobald die übergeordnete App endet.
- ✓Wenn du einen losgelösten Prozess starten oder steuern willst, welche Handles ein Kindprozess erbt.
Link zum Skill
https://github.com/dotnet/skills/blob/main/plugins/dotnet11/skills/process-api-net11/SKILL.mdKopiere ihn und füge ihn in deine KI ein (Claude, ChatGPT oder Cursor) mit der Bitte, den Anweisungen zu folgen.
So nutzt du ihn
Am einfachsten: Kopiere die Nachricht und füge sie in deine KI ein. Sie liest den Skill und folgt den Anweisungen.
Fertige Nachricht zum Einfügen
Für Claude Code, Codex oder Cursor: Führe den Befehl in deinem Projektordner aus, dann wird der Skill installiert.
Lade die SKILL.md herunter und lege sie in den Skills-Ordner deines Agenten.
Beispielanfrage an deine KI
“Führe in meiner .NET-11-App ein Kommandozeilenwerkzeug aus, erfasse seine Textausgabe und stelle sicher, dass es beim Beenden meiner App geschlossen wird.”
5 neue Skills pro Woche. 1 Minute Lesezeit.
So funktioniert es
Der Agent nutzt die neuen Prozessmethoden von .NET 11, die Warten und Ausgabeerfassung übernehmen, und setzt die Lebensdauer-Optionen, die du verlangst.
Technischer Inhalt (originale SKILL.md)
Originaltext des Autors, auf Englisch, direkt von GitHub.
Process API Improvements — .NET 11
New APIs added to System.Diagnostics.Process in .NET 11 simplify process management, eliminate boilerplate, and prevent common deadlock patterns when capturing output in .NET 11 or later applications.
When to Use
- Running or orchestrating external processes in a .NET 11 (or later) project.
- Needing to start a process, wait for it to exit, and capture its output/error streams without risking deadlocks (
Process.RunAndCaptureText[Async]). - Wanting to ensure child processes are automatically terminated when the parent process exits (
KillOnParentExit). - Requiring lightweight, low-overhead process creation via
SafeProcessHandleon supported platforms. - Requiring fine-grained control over handle inheritance (
InheritedHandles) or starting detached processes (StartDetached).
When Not to Use
- The project targets .NET 10 or earlier — these APIs are not available before .NET 11.
- The default
Process.Start()is sufficient and does not require output capturing or advanced lifecycle rules.
Target Framework
<TargetFramework>net11.0</TargetFramework>
New APIs
Types
Before using the new convenience methods, note the following types. Use the framework types directly:
| Type | Kind | Read-only properties |
|---|---|---|
ProcessExitStatus |
Sealed class | int ExitCode, bool Canceled, PosixSignal? Signal |
ProcessTextOutput |
Sealed class | ProcessExitStatus ExitStatus, string StandardOutput, string StandardError, int ProcessId |
ProcessOutputLine |
Readonly struct | string Content, bool StandardError |
ProcessExitStatus describes the outcome of a completed process. Interpret ExitCode using the external command's contract; there is no universal Success property. ProcessTextOutput contains the exit status, captured output and error text, and process ID. ProcessOutputLine identifies one output line and whether it came from standard error.
High-Level Convenience APIs
Static Methods
The ProcessStartInfo overloads below require UseShellExecute = false, which is the default for .NET.
Process.Run / Process.RunAsync
Starts a process and waits for it to exit, returning the exit status. Does not capture standard output or error. Passing silent: true discards standard output and error by internally redirecting standard handles to the NUL device. On timeout or cancellation, the process is killed.
public static ProcessExitStatus Run(string fileName, IEnumerable<string>? arguments = null, bool silent = false, TimeSpan? timeout = null)
public static Task<ProcessExitStatus> RunAsync(string fileName, IEnumerable<string>? arguments = null, bool silent = false, CancellationToken cancellationToken = default)
public static ProcessExitStatus Run(ProcessStartInfo startInfo, TimeSpan? timeout = null)
public static Task<ProcessExitStatus> RunAsync(ProcessStartInfo startInfo, CancellationToken cancellationToken = default)
Process.RunAndCaptureText / Process.RunAndCaptureTextAsync
Starts a process, captures both standard output and error, and waits for it to exit. Extremely useful for avoiding deadlocks on stream redirection. On timeout or cancellation, the process is killed.
When using the ProcessStartInfo overloads, the caller is responsible for setting RedirectStandardOutput = true and RedirectStandardError = true on ProcessStartInfo (because BCL APIs cannot modify the input arguments they were given).
public static ProcessTextOutput RunAndCaptureText(string fileName, IEnumerable<string>? arguments = null, TimeSpan? timeout = null)
public static Task<ProcessTextOutput> RunAndCaptureTextAsync(string fileName, IEnumerable<string>? arguments = null, CancellationToken cancellationToken = default)
public static ProcessTextOutput RunAndCaptureText(ProcessStartInfo startInfo, TimeSpan? timeout = null)
public static Task<ProcessTextOutput> RunAndCaptureTextAsync(ProcessStartInfo startInfo, CancellationToken cancellationToken = default)
Process.StartAndForget
There is a common misconception that when a process is disposed, it's also being killed. This is not the case, as Process.Dispose only releases the resources associated with the process, but does not kill it.
To make it easier to start a process without the need to worry about disposing it, Process.StartAndForget was introduced. The method starts an executable, retu
Häufige Fragen
Funktioniert das mit .NET 10?
Nein. Diese APIs gibt es nur in .NET 11 und neuer.
Funktioniert das normale Process.Start noch?
Ja. Der Standard ist in Ordnung, wenn du keine Ausgabeerfassung oder die neuen Lebensdauerregeln brauchst.
Was macht KillOnParentExit?
Es sorgt dafür, dass Kindprozesse automatisch enden, wenn der übergeordnete Prozess endet.
Details
Originalbeschreibung des Autors
Provides guidance on the new System.Diagnostics.Process APIs introduced in .NET 11: Process.Run, Process.RunAndCaptureText, Process.StartAndForget, Process.ReadAllText/Bytes/Lines, KillOnParentExit, InheritedHandles, and StartDetached. USE FOR: starting, orchestrating, or capturing output from external processes in applications targeting net11.0 or later. DO NOT USE FOR: applications targeting .NET 10 or earlier, or basic pre-.NET 11 Process.Start usage without new APIs.
repo: dotnet/skills
Beliebtheit
- GitHub-Sterne
- 5.8k
- Platz im Ranking
- #14655
- Lizenz
- MIT
- Aktualisiert
- 2.11.2026
Kommentare
- …
Weitere Skills aus diesem Repository
create-custom-agent
5.8kHilft deinem Agenten, Agenten-Dateien für VS Code zu erstellen, mit eigenen Werkzeugen, Anweisungen und Übergaben an andere Agenten.
create-skill
5.8kHilft deinem Agenten, einen neuen Agenten-Skill mit gültigem Namen, klarer Auslöserbeschreibung und einer SKILL.md-Datei nach dem Standard zu erstellen.
csharp-scripts
5.8kHilft deinem Agenten, ein kleines C#-Programm als einzelne Datei mit dem .NET-Kommandozeilen-Tool auszuführen, ohne ein vollständiges Projekt anzulegen.
dotnet-pinvoke
5.8kHilft deinem Agenten, native C- oder C++-Bibliotheken korrekt aus .NET aufzurufen, mit Signaturen, Zeichenkettenbehandlung, Speicher und sicheren Handles.
Ähnliche Skills
api-connector-builder
280kLässt deinen Agenten neue API-Anbindungen nach dem bestehenden Muster bauen. Nutze es, wenn du eine weitere Integration ergänzen willst, ohne neue Wege einzuführen.
api-design
280kHilft deinem Agenten, REST-APIs nach Best Practices zu entwerfen. Nützlich für die Kommunikation, die Fehlerausgabe und die Organisation von Daten.
backend-patterns
280kHilft deinem Agenten bei Architekturmustern für die Serverseite und bei der Datenbankoptimierung. Nützlich zum Bauen und Prüfen von Server-Code.