C# Compiler Options

The C# compiler, csc.exe, compiles C# sources and incorporates resource files and separately compiled modules. It also allows you to specify conditional compilation options, XML documentation, and path information.


csc [options] files


csc foo.cs /r:bar.dll /win32res:foo.res
csc foo.cs /debug /define:TEMP


/?, /help

Displays usage information and exits.

@ file

Specifies a response file containing arguments to csc.exe.

/addmodule:file1 [; file2 ...]

Imports metadata from one or more named modules (files with the extension .netmodule). To create a module, use /target:module.


Specifies the base address at which to load DLLs.


Generates a text file that contains a bug report. Use this to report a bug in csc.exe.


If you specify /checked+, causes the runtime to throw an exception when an integer operation results in a value outside the range of the associated datatype. This only affects code that has not been wrapped in a checked or unchecked block of code. If you specify /checked-, an exception is not thrown.


Specifies the code page to use for all source files.

/d[efine]:symbol1 [; symbol2 ...]

Specify one or more symbols to define. This has the same effect as the #define preprocessor directive.


Enables or disables debugging information. You may specify /debug instead of /debug+. The default is /debug-.


Specifies the debug modes that ...

Get C# Language Pocket Reference now with O’Reilly online learning.

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