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
- Run a tool without version specification:
npx dntx androidsdk.tool- Run a tool with a specific version:
npx dntx androidsdk.tool@0.19.0- Run a tool with arguments:
npx dntx androidsdk.tool sdk info --format=jsonHow It Works
- Checks if .NET SDK is installed
- Creates a temporary directory
- Installs the specified .NET tool (with version if specified)
- Runs the tool with any provided arguments
- 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
- Clone the repository:
git clone https://github.com/redth/npx-dntx.git
cd npx-dntx- Install dependencies:
npm installAvailable Scripts
npm test- Run testsnpm run test:watch- Run tests in watch modenpm 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 testContinuous 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
- Update version and create git tag:
npm version patch # or minor/major- Preview what will be published:
npm run prepare-publishPublishing to npm
Manual Publishing
npm login
npm publishAutomated Publishing via GitHub
- Create an npm access token:
npm token createAdd 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
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)