Gapotchenko.FX.Diagnostics.CommandShell
2026.5.3
Prefix Reserved
dotnet add package Gapotchenko.FX.Diagnostics.CommandShell --version 2026.5.3
NuGet\Install-Package Gapotchenko.FX.Diagnostics.CommandShell -Version 2026.5.3
<PackageReference Include="Gapotchenko.FX.Diagnostics.CommandShell" Version="2026.5.3" />
<PackageVersion Include="Gapotchenko.FX.Diagnostics.CommandShell" Version="2026.5.3" />
<PackageReference Include="Gapotchenko.FX.Diagnostics.CommandShell" />
paket add Gapotchenko.FX.Diagnostics.CommandShell --version 2026.5.3
#r "nuget: Gapotchenko.FX.Diagnostics.CommandShell, 2026.5.3"
#:package Gapotchenko.FX.Diagnostics.CommandShell@2026.5.3
#addin nuget:?package=Gapotchenko.FX.Diagnostics.CommandShell&version=2026.5.3
#tool nuget:?package=Gapotchenko.FX.Diagnostics.CommandShell&version=2026.5.3
Overview
The module provides OS command shell functionality.
CommandShell
CommandShell static class from Gapotchenko.FX.Diagnostics.CommandShell module provides operations for locating files using the PATH environment variable according to the rules of a host operating system.
Where
The Where method enumerates the paths of a file with the specified name using the PATH environment variable. It is similar to the Windows where command or Unix which command, but works cross-platform.
The basic usage is straightforward:
using Gapotchenko.FX.Diagnostics;
foreach (string path in CommandShell.Where("notepad"))
Console.WriteLine(path);
On Windows, this might produce output like:
C:\Windows\System32\notepad.exe
C:\Windows\notepad.exe
The method respects the operating system's file discovery rules:
- On Windows, it uses the
PATHEXTenvironment variable to try different file extensions (.exe,.cmd,.bat, etc.) - On Unix-like systems, it searches for files with the exact name specified
- It handles case sensitivity according to the host operating system
Where with Probing Paths
You can also specify custom probing paths that will be checked before the PATH environment variable:
using Gapotchenko.FX.Diagnostics;
// Check custom directories first, then PATH
string[] customPaths = [@"C:\MyTools", @"C:\MyDir"];
foreach (string path in CommandShell.Where("myapp", customPaths))
Console.WriteLine(path);
This is useful when you want to prioritize certain directories or check additional locations beyond the standard PATH.
Handling Paths with Directory Information
If the file name contains directory information, Where method will only search in that specific directory:
using Gapotchenko.FX.Diagnostics;
// Only searches in "C:\MyDir" directory
foreach (string path in CommandShell.Where(@"C:\MyDir\myapp"))
Console.WriteLine(path);
Cross-Platform Behavior
The Where method automatically adapts to the host operating system:
- Windows: Uses
PATHEXTenvironment variable to try multiple file extensions - Unix/Linux/macOS: Searches for files with the exact name specified
This makes it easy to write cross-platform code that locates executables correctly on any operating system.
Commonly Used Types
Gapotchenko.FX.Diagnostics.CommandShell
Other Modules
Let's continue with a look at some other modules provided by Gapotchenko.FX:
- Gapotchenko.FX
- Gapotchenko.FX.AppModel.Information
- Gapotchenko.FX.Collections
- Gapotchenko.FX.Console
- Gapotchenko.FX.Data
- Gapotchenko.FX.Diagnostics
- Gapotchenko.FX.IO
- Gapotchenko.FX.Linq
- Gapotchenko.FX.Math
- Gapotchenko.FX.Memory
- Gapotchenko.FX.Security.Cryptography
- Gapotchenko.FX.Text
- Gapotchenko.FX.Threading
- Gapotchenko.FX.Tuples
- Gapotchenko.FX.Versioning
Or look at the full list of modules.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 is compatible. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.7.2
- Gapotchenko.FX (>= 2026.5.3)
- Gapotchenko.FX.IO (>= 2026.5.3)
-
.NETStandard 2.0
- Gapotchenko.FX (>= 2026.5.3)
- Gapotchenko.FX.IO (>= 2026.5.3)
-
.NETStandard 2.1
- Gapotchenko.FX (>= 2026.5.3)
- Gapotchenko.FX.IO (>= 2026.5.3)
-
net10.0
- Gapotchenko.FX (>= 2026.5.3)
- Gapotchenko.FX.IO (>= 2026.5.3)
-
net8.0
- Gapotchenko.FX (>= 2026.5.3)
- Gapotchenko.FX.IO (>= 2026.5.3)
-
net9.0
- Gapotchenko.FX (>= 2026.5.3)
- Gapotchenko.FX.IO (>= 2026.5.3)
NuGet packages (5)
Showing the top 5 NuGet packages that depend on Gapotchenko.FX.Diagnostics.CommandShell:
| Package | Downloads |
|---|---|
|
Gapotchenko.Shields.MSys2.Deployment
The deployment module of MSYS2 Shield. |
|
|
Gapotchenko.Shields.Homebrew.Deployment
Locates setup instances of Homebrew package manager. |
|
|
Gapotchenko.Shields.BusyBox.Deployment
Locates setup instances of BusyBox toolkit. |
|
|
Gapotchenko.Shields.Git.Deployment
Locates setup instances of Git version control system. |
|
|
Gapotchenko.Shields.Canonical.Snap.Deployment
Provides deployment discovery services for identifying installed instances of Canonical Snap on a system. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2026.5.3 | 69 | 2/24/2026 |
| 2026.4.2 | 95 | 2/4/2026 |
| 2026.3.5 | 93 | 1/29/2026 |
| 2026.2.2 | 95 | 1/25/2026 |
| 2026.1.5 | 97 | 1/13/2026 |
| 2025.1.45 | 410 | 12/25/2025 |
| 2025.1.27-beta | 190 | 10/8/2025 |
| 2025.1.26-beta | 240 | 8/30/2025 |
| 2025.1.25-beta | 840 | 7/22/2025 |
| 2025.1.24-beta | 351 | 7/16/2025 |
| 2025.1.23-beta | 481 | 7/12/2025 |