Skip to content

demaconsulting/DotnetToolWrapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

36 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

DotnetToolWrapper

GitHub forks GitHub Repo stars GitHub contributors GitHub

A .NET console application that enables native executables to be distributed as .NET Tools.

Overview

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.

Features

  • 🌍 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

Quick Start

Install a tool that uses DotnetToolWrapper:

dotnet tool install -g YourTool.Package
your-tool --help

Create your own wrapped tool by following the Usage section below.

Usage

To create a .NET tool using DotnetToolWrapper, you'll need to:

  1. Create a .nuspec file for the .NET tool package
  2. Create configuration files (DotnetToolSettings.xml and DotnetToolWrapper.json)
  3. Copy DotnetToolWrapper files and your native executables
  4. Package as a NuGet package

For complete step-by-step instructions, detailed examples, and troubleshooting, see the Usage Guide.

Quick Example

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

How It Works

  1. User installs your .NET tool package via dotnet tool install
  2. When the tool is invoked, .NET launches DemaConsulting.DotnetToolWrapper.dll
  3. The wrapper detects the current OS and architecture
  4. The wrapper reads DotnetToolWrapper.json to find the appropriate native executable
  5. The wrapper launches the native executable with the original arguments
  6. The wrapper returns the native executable's exit code

Platform Support

Operating Systems

  • Windows
  • Linux
  • FreeBSD
  • macOS

Architectures

  • 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 Frameworks

  • .NET 8.0
  • .NET 9.0
  • .NET 10.0

Documentation

Building from Source

# 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/

Examples

For real-world examples of tools using DotnetToolWrapper, see:

Contributing

We welcome contributions! Please see CONTRIBUTING.md for details on:

  • Reporting bugs
  • Suggesting enhancements
  • Submitting pull requests
  • Development setup
  • Code style guidelines

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

About

Package native tools in a Dotnet tool container

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages