npm.io
0.84.0 • Published 2 months ago

@react-native-windows/find-dotnet-tools

Licence
MIT
Version
0.84.0
Deps
1
Size
9 kB
Vulns
0
Weekly
0
Stars
17.3K

@react-native-windows/find-dotnet-tools

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.

Usage

Add the package as a dependency:

{
  "dependencies": {
    "@react-native-windows/find-dotnet-tools": "<version>"
  }
}

findPowerShell

Locates a PowerShell executable by checking, in order:

  1. A dotnet-tool-restored copy of pwsh.exe (skipped in CI builds)
  2. pwsh.exe on the system PATH

Throws an error if pwsh.exe cannot be found.

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"
getNugetGlobalPackagesFolder

Returns the path to the global NuGet packages folder by checking, in order:

  1. The NUGET_PACKAGES environment variable
  2. The output of dotnet nuget locals global-packages --list
  3. The default ~/.nuget/packages location
import {getNugetGlobalPackagesFolder} from '@react-native-windows/find-dotnet-tools';

const packagesDir = getNugetGlobalPackagesFolder();
// e.g. "C:\\Users\\user\\.nuget\\packages"