Mangh.Metrology.UnitGenerator 2.0.0

dotnet tool install --global Mangh.Metrology.UnitGenerator --version 2.0.0
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest # if you are setting up this repo
dotnet tool install --local Mangh.Metrology.UnitGenerator --version 2.0.0
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=Mangh.Metrology.UnitGenerator&version=2.0.0
nuke :add-package Mangh.Metrology.UnitGenerator --version 2.0.0

Unit Generator for C# and C++


  • Standalone dotnet tool for generating unit of measurement structures for C# or C++ languages from the console.


  • Install the tool as a "global tool":

    dotnet tool install --global Mangh.Metrology.UnitGenerator

    The tool is user-specific, not global to the machine (as you might think). It is only available to the user that installed the tool.

    NOTE: You can also install the tool as a "global tool in a custom location" or as a "local tool". If you do it, please amend the Usage instruction (below) accordingly. For details, see article "How to manage .NET tools". Don't forget to amend your scripts (e.g. CMakeLists.txt files) that make use of the tool.


  • Use the command line with the following syntax to run the tool:

    UnitGenerator targetLanguage targetNamespace templateFolder targetFolder [--with-models]


    targetLanguage  : CS | CPP.
    targetNamespace : namespace string, e.g.
                     "Demo.Metrology" for CS language,
                     "Demo::Metrology" for CPP language,
    templateFolder  : path to the folder containing definitions and templates,
    targetFolder    : path to the target folder for generated units and scales,
    --with-models   : request to save models in files (in the targetFolder)
  • Example use for C#:

    UnitGenerator CS "Demo.UnitsOfMeasurement" .\UnitsOfMeasurement\Templates .\UnitsOfMeasurement\Units
  • Example use for C++:

    UnitGenerator CPP "CALINE3::Metrology" Metrology/Templates Metrology/Units
  • The tool requires the following templates in the templateFolder directory:

    C# C++ purpose
    Definitions.txt definitions.txt units and scales definitions
    Unit.xslt unit.xslt unit template
    Scale.xslt scale.xslt scale template
    n/a math.xslt math constants
    Catalog.xslt n/a catalog template
    Aliases.xslt n/a aliases template
    Report.xslt report.xslt report template

    Sample templates can be found on the project website.


  • The package replaces the XsltGeneratorApp console application available in the source code of Mangh.Metrology version 1.x.
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last updated
2.0.0 163 6/21/2023

Version 2.x
     * C++ support (new),
     * source code heavily restructured,
     * packages renamed.
     Version 1.x (XsltGeneratorApp console application)
     * deprecated.