JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q21784F
  • License MIT

Temporarily install and run dotnet tools via npx

Package Exports

  • dntx
  • dntx/bin/index.cjs

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (dntx) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

dntx

A simple node CLI tool to temporarily install and run .NET tools via npx. No global installation required!

https://github.com/user-attachments/assets/48da0e8b-bc7f-446a-bbfa-155961f98c40

Why?

There's currently no way to temporarily install a .NET tool and have it execute in a single command like NPX allows for node projects.

How?

When you run the tool, it captures the first arg passed into it as the dotnet tool NuGet Package Id and attempts to install it to a local temporary path (eg: dotnet tool install --tool-path "/tmp/abc123" NuGetPackageIdHere --version=1.2.3). Once it's installed, it infers the executable command from the installed location and runs the process, passing along any remaining args from the original call. Once the process exits, the temporary installed dotnet tool files are cleaned up.

Quick Start

Run any .NET tool directly without installation:

npx dntx[@version] <package-id> [arguments]

Prerequisites

  • Node.js (>= 14.0.0)
  • .NET SDK (any version)

Usage

You can run any .NET tool directly using npx without installing it globally:

npx dntx <package-id> [arguments]

Examples

  1. Run a tool without version specification:
npx dntx androidsdk.tool
  1. Run a tool with a specific version:
npx dntx androidsdk.tool@0.19.0
  1. Run a tool with arguments:
npx dntx androidsdk.tool sdk info --format=json

How It Works

  1. Checks if .NET SDK is installed
  2. Creates a temporary directory
  3. Installs the specified .NET tool (with version if specified)
  4. Runs the tool with any provided arguments
  5. Automatically cleans up after execution

Features

  • โœจ No global installation required
  • ๐ŸŽฏ Version pinning support (package-id@version)
  • ๐Ÿงน Automatic cleanup
  • ๐Ÿ”„ Works cross-platform
  • ๐Ÿš€ Simple and intuitive interface

Development

Setup

  1. Clone the repository:
git clone https://github.com/redth/npx-dntx.git
cd npx-dntx
  1. Install dependencies:
npm install

Available Scripts

  • npm test - Run tests
  • npm run test:watch - Run tests in watch mode
  • npm run build - Run build process (currently runs tests)
  • npm run prepare-publish - Prepare for publishing (runs build and shows included files)

Running Tests

The project uses Jest for testing. Tests run across multiple Node.js versions and operating systems in CI.

npm test

Continuous Integration

GitHub Actions workflows automatically run tests on:

  • Multiple operating systems (Windows, macOS, Linux)
  • Multiple Node.js versions (14.x, 16.x, 18.x, 20.x)
  • Multiple .NET SDK versions (6.0.x, 7.0.x, 8.0.x)

Publishing

Preparing for Release

  1. Update version and create git tag:
npm version patch  # or minor/major
  1. Preview what will be published:
npm run prepare-publish

Publishing to npm

Manual Publishing

npm login
npm publish

Automated Publishing via GitHub

  1. Create an npm access token:
npm token create
  1. Add the token to GitHub:

    • Go to your repository's Settings
    • Navigate to Secrets and variables > Actions
    • Create a new secret named NPM_TOKEN
    • Paste your npm token as the value
  2. Create a new release on GitHub:

    • Go to Releases > Draft a new release
    • Choose the tag created by npm version
    • Add release notes
    • Publish the release

The GitHub Actions workflow will automatically publish to npm when the release is created.

Error Handling

The tool provides clear error messages for common issues:

  • Missing .NET SDK installation
  • Invalid package IDs
  • Non-existent versions
  • Tool execution failures

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - see the LICENSE file for details.

Author

Jon Dick (redth)