C# Compiler (csc.exe)

The following table shows some of the common usages of the C# compiler:




keyfilename specifies the key file that contains the key pair for signing the assembly.


This option enables versioning of assemblies.


With this option, the compiler will emit debugging information in the output file.

/define: symbol or /d: symbol

This option is similar to C++. Use this option to define preprocessor symbols.


docname is the XML output file for the autogenerated XML comment embedded in C# code.


This option shows the command-line help for the C# compiler.


If there is more than one Main entry in different classes, you will have to specify the Main entry in which class you want the entry point of the application.


This option represents the output filename.

/reference: libname or /r: libname

This option allows single or multiple libraries be included with this compilation. For multiple libraries to be included, use a semicolon as the delimiter.

/target:exe|library|winexe or /t:exe|library|winexe

This option allows you to specify the type of the output: exe for console executables, library for DLLs, and winexe for Windows Form applications.


If you use unsafe keywords in your C# code, you will have to use this option when compiling your source.

Get .Net Framework Essentials now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.