A .NET console application that enables native executables to be distributed as .NET Tools.
DotnetToolWrapper bridges the gap between the .NET tool ecosystem and native applications. It provides a managed .NET entry point that detects the current platform and launches the appropriate native executable, enabling developers to distribute cross-platform command-line tools through NuGet.
- π Multi-Platform Support - Works on Windows, Linux, FreeBSD, and macOS
- ποΈ Multi-Architecture - Supports x86, x64, ARM, ARM64, WASM, and S390x
- π― Multi-Framework - Targets .NET 8.0, 9.0, and 10.0
- π¦ Zero Dependencies - No external dependencies beyond .NET runtime
- βοΈ Simple Configuration - JSON-based configuration for platform-to-executable mapping
- π Transparent Execution - Passes arguments and exit codes through seamlessly
- π Environment Variables - Supports environment variable expansion in paths
- β‘ Minimal Overhead - Lightweight wrapper with negligible performance impact
Install a tool that uses DotnetToolWrapper:
dotnet tool install -g YourTool.Package
your-tool --helpCreate your own wrapped tool by following the Usage section below.
To create a .NET tool using DotnetToolWrapper, you'll need to:
- Create a .nuspec file for the .NET tool package
- Create configuration files (DotnetToolSettings.xml and DotnetToolWrapper.json)
- Copy DotnetToolWrapper files and your native executables
- Package as a NuGet package
For complete step-by-step instructions, detailed examples, and troubleshooting, see the Usage Guide.
Here's a minimal folder structure:
root/
βββ tool.nuspec
βββ win-x64/
β βββ my-tool.exe
βββ linux-x64/
β βββ my-tool
βββ osx-arm64/
β βββ my-tool
βββ tools/
βββ net8.0/
β βββ any/
βββ net9.0/
β βββ any/
βββ net10.0/
βββ any/
βββ DotnetToolSettings.xml
βββ DotnetToolWrapper.json
βββ DemaConsulting.DotnetToolWrapper.dll
βββ (other wrapper files)
Package and install:
nuget pack tool.nuspec -Version 1.0.0
dotnet tool install -g My.Tool.Package
my-tool --help- User installs your .NET tool package via
dotnet tool install - When the tool is invoked, .NET launches
DemaConsulting.DotnetToolWrapper.dll - The wrapper detects the current OS and architecture
- The wrapper reads
DotnetToolWrapper.jsonto find the appropriate native executable - The wrapper launches the native executable with the original arguments
- The wrapper returns the native executable's exit code
- Windows
- Linux
- FreeBSD
- macOS
- x86 (32-bit Intel/AMD)
- x64 (64-bit Intel/AMD)
- ARM (32-bit ARM)
- ARM64 (64-bit ARM)
- WASM (WebAssembly)
- S390x (IBM System z)
- .NET 8.0
- .NET 9.0
- .NET 10.0
- Architecture - Detailed architecture and design documentation
- Contributing - Guidelines for contributing to the project
- Code of Conduct - Community standards and expectations
- Security - Security policy and vulnerability reporting
# Clone the repository
git clone https://github.com/demaconsulting/DotnetToolWrapper.git
cd DotnetToolWrapper
# Restore dependencies
dotnet restore
# Build the project
dotnet build --configuration Release
# Output will be in src/DemaConsulting.DotnetToolWrapper/bin/Release/For real-world examples of tools using DotnetToolWrapper, see:
- Check the GitHub topic for projects using this wrapper
We welcome contributions! Please see CONTRIBUTING.md for details on:
- Reporting bugs
- Suggesting enhancements
- Submitting pull requests
- Development setup
- Code style guidelines
This project is licensed under the MIT License - see the LICENSE file for details.
- Issues: Report bugs or request features via GitHub Issues
- Discussions: Ask questions via GitHub Discussions
- Security: Report vulnerabilities per SECURITY.md