LinuxCommandLibrary

mcs

Modify code signing attributes of Mach-O binaries

TLDR

Compile the specified files

$ mcs [path/to/input_file1.cs path/to/input_file2.cs ...]
copy

Specify the output program name
$ mcs -out:[path/to/file.exe] [path/to/input_file1.cs path/to/input_file2.cs ...]
copy

Specify the output program type
$ mcs -target:[exe|winexe|library|module] [path/to/input_file1.cs path/to/input_file2.cs ...]
copy

SYNOPSIS

mcs [options] [source-files]

PARAMETERS

-out:FILENAME
    Specifies the name of the output assembly file. For example, -out:MyProgram.exe.

-target:KIND
    Defines the type of target to build. Common kinds include library, exe (console application), winexe (GUI application), and module.

-r:ASSEMBLY
-reference:ASSEMBLY

    References an assembly required by the source code. Multiple assemblies can be specified separated by commas or using multiple -r options.

-debug
-debug+

    Emits debugging information into the output assembly, useful for stepping through code with a debugger.

-optimize
-optimize+

    Enables or disables code optimizations during compilation. -optimize- disables optimizations.

-define:SYMBOLS
-d:SYMBOLS

    Defines preprocessor symbols, which can be used for conditional compilation within the source code.

-warn:LEVEL
    Sets the compiler's warning level, ranging from 0 (no warnings) to 4 (all warnings).

-langversion:VERSION
    Specifies the C# language version to use for compilation, e.g., C#7.3 or latest.

-version
    Displays the Mono C# compiler's version number and exits.

DESCRIPTION

The mcs command is the Mono C# compiler, an open-source implementation of the C# language and the ECMA Common Language Infrastructure (CLI) standards. It compiles C# source code into Common Intermediate Language (CIL) assemblies, which can then be executed by the Mono runtime or any compatible .NET runtime.

mcs supports various C# language versions, from older specifications to the latest C# standards, enabling developers to build a wide range of applications, including console programs, libraries, graphical user interface (GUI) applications, and web services. It offers a rich set of command-line options for controlling compilation, referencing external assemblies, debugging, and optimizing output.

CAVEATS

Running compiled assemblies requires the Mono runtime to be installed on the system.

While aiming for high compatibility, certain advanced or platform-specific .NET features might exhibit differences or be unavailable when executed under Mono compared to Microsoft's .NET Framework or .NET Core environments.

RESPONSE FILES

mcs supports response files, which are plain text files containing compiler options. These files are typically passed to the compiler by prefixing their path with an @ symbol (e.g., @myoptions.rsp). This feature is particularly useful for managing long command lines or reusing common sets of compilation options.

CODE PAGES

The -codepage:ID option allows specifying the code page to use for interpreting source files. This is important for ensuring correct character encoding when source files are created with different encodings than the system's default.

HISTORY

The mcs compiler is a foundational component of the Mono project, initiated by Miguel de Icaza in 2001. Its primary objective was to create an open-source, cross-platform implementation of Microsoft's .NET Framework, enabling C# applications to run on Linux, macOS, and other Unix-like operating systems.

Over its development, mcs has consistently evolved to support new C# language features and .NET framework advancements, playing a crucial role in the adoption of C# beyond Windows environments before Microsoft's own open-sourcing of .NET Core.

SEE ALSO

mono(1), xbuild(1), gacutil(1), sn(1)

Copied to clipboard