Helpers to locate .NET-based tools (e.g. PowerShell) restored via dotnet tool restore or
available on PATH.
Used to resolve tool paths consistently across local development and CI environments.
Add the package as a dependency:
{
"dependencies": {
"@react-native-windows/find-dotnet-tools": "<version>"
}
}Locates a PowerShell executable by checking, in order:
- A
dotnet-tool-restored copy ofpwsh.exe(skipped in CI builds) pwsh.exeon the system PATH- The built-in Windows PowerShell as a last resort
import {findPowerShell} from '@react-native-windows/find-dotnet-tools';
const pwsh = findPowerShell();
// e.g. "C:\\Users\\user\\.nuget\\packages\\PowerShell\\7.6.1\\tools\\net10.0\\any\\win\\pwsh.exe"Returns the path to the global NuGet packages folder by checking, in order:
- The
NUGET_PACKAGESenvironment variable - The output of
dotnet nuget locals global-packages --list - The default
~/.nuget/packageslocation
import {getNugetGlobalPackagesFolder} from '@react-native-windows/find-dotnet-tools';
const packagesDir = getNugetGlobalPackagesFolder();
// e.g. "C:\\Users\\user\\.nuget\\packages"