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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Gapotchenko.FX.Diagnostics.CommandShell" Version="2026.5.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Gapotchenko.FX.Diagnostics.CommandShell" Version="2026.5.3" />
                    
Directory.Packages.props
<PackageReference Include="Gapotchenko.FX.Diagnostics.CommandShell" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Gapotchenko.FX.Diagnostics.CommandShell --version 2026.5.3
                    
#r "nuget: Gapotchenko.FX.Diagnostics.CommandShell, 2026.5.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Gapotchenko.FX.Diagnostics.CommandShell@2026.5.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Gapotchenko.FX.Diagnostics.CommandShell&version=2026.5.3
                    
Install as a Cake Addin
#tool nuget:?package=Gapotchenko.FX.Diagnostics.CommandShell&version=2026.5.3
                    
Install as a Cake Tool

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 PATHEXT environment 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 PATHEXT environment 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:

Or look at the full list of modules.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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