LinuxCommandLibrary

mono

Run .NET applications on Linux

TLDR

Run a .NET assembly in debug mode

$ mono --debug [path/to/program.exe]
copy

Run a .NET assembly
$ mono [path/to/program.exe]
copy

SYNOPSIS

mono [options] <assembly|script> [arguments...]
where <assembly|script> is the path to a .NET executable (.exe), a shared library (.dll), or a script file (e.g., .fsx, .ps1).

PARAMETERS

-V, --version
    Displays the Mono runtime version information.

-h, --help
    Shows the command-line help message with available options.

--debug
    Enables debugging support for the executed assembly, typically used with a debugger client.

--profile[=profiler]
    Activates a profiler to analyze application performance. If profiler is omitted, the default is used.

--aot[=options]
    Performs Ahead-Of-Time (AOT) compilation of the assembly. This generates native code before execution, potentially improving startup time. Optional options can specify compilation behavior.

--optimize[=option]
    Controls the runtime's optimization levels. Can enable or disable specific optimizations (e.g., all, -all, shared, calls).

--runtime=version
    Specifies the desired runtime version (e.g., v4.0) to load the assembly against.

--config <file>
    Uses an alternative file as the Mono runtime configuration file instead of the default.

--server
    Optimizes the runtime for server workloads, potentially improving throughput for long-running applications.

--trace[=category]
    Enables tracing of runtime events. category can filter traced events (e.g., all, assembly, gc).

--gc=sgen|boehm
    Selects the garbage collector. sgen is the default, newer, generational collector; boehm is the older, conservative collector.

DESCRIPTION

The mono command is the primary executable for the Mono runtime, an open-source implementation of Microsoft's .NET Framework and Common Language Infrastructure (CLI). It enables developers to run applications written in languages like C# (compiled into assemblies with a .exe or .dll extension) directly on Linux, macOS, and other Unix-like operating systems. Mono provides a complete CLI runtime, including a Just-In-Time (JIT) compiler, garbage collector, and a comprehensive set of core class libraries. This command facilitates the execution of cross-platform applications, ranging from desktop programs to server-side services, without requiring a Windows environment.

CAVEATS

While Mono aims for broad compatibility, not all features of the Microsoft .NET Framework (especially Windows-specific UI frameworks like WPF or certain legacy WinForms controls) are fully implemented. Performance characteristics may also differ from native .NET on Windows. Users should verify compatibility for complex applications.

ENVIRONMENT VARIABLES

Several environment variables can influence Mono's behavior, including:
MONO_PATH: Specifies directories to search for assemblies.
MONO_CONFIG: Overrides the default runtime configuration file location.
MONO_GC_PARAMS: Configures parameters for the garbage collector.

JIT VS. AOT COMPILATION

By default, Mono uses a Just-In-Time (JIT) compiler, which compiles IL code to native code during execution. The --aot option allows for Ahead-Of-Time (AOT) compilation, generating native code before runtime. AOT can improve application startup time, especially on embedded systems, but may result in larger executable sizes and reduced dynamic code generation capabilities.

HISTORY

Initiated by Miguel de Icaza and Novell in 2001, the Mono project sought to bring .NET development to Linux and other non-Windows platforms. It gained significant adoption, notably with the Unity 3D game engine. Development continued under Xamarin, which Microsoft later acquired in 2016. With Microsoft's push for cross-platform .NET Core (now simply .NET), the focus of the broader .NET ecosystem shifted. However, Mono continues to be actively maintained, particularly for specific use cases like Unity, Xamarin.Forms mobile development, and embedded systems, often leveraging the modern .NET runtime's libraries.

SEE ALSO

mcs(1), xsp4(1), certmgr(1), mozroots(1), dotnet(1)

Copied to clipboard