Csc.exe C# compiler


csc [options] files


Compiles C# sources and incorporates resource files and separately compiled modules. Also allows you to specify conditional compilation options, XML documentation, and path information.


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.

/addmodule :file1[; file2 ...]

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

/baseaddress :addr

Specifies the base address at which to load DLLs.

/bugreport :file

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


If you specify /checked+, the runtime throws an exception when an integer operation results in a value outside the range of the associated data type. 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.

/codepage :id

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 are supported by the generated assembly. The full option is the default and allows you to perform source code debugging when attaching a debugger to the program before or after it is started. The pdbonly option only permits source code debugging if you start the program under control of the debugger. If you attach the debugger to the program after it is started, it displays only native assembly in the debugger.

/doc :file

Specify the XML documentation file to generate.

/filealign :size

Specifies the size, in bytes, of sections in the output file. Valid sizes are 512, 1024, 2048, 4096, 8192, and 16384.


Use fully qualified filenames in error messages.


Enables or disables incremental compilation. By default, incremental compilation is off.

/lib :dir1[; dir2 ...]

Specifies directories to search for assemblies imported with the /reference option.

/linkres[ource] :file[ ,id]

Specifies a .NET resource (and optional identifier) to link to the generated assembly. Not valid with /target:module.

/m[ain] :type

Specifies the name of the type that contains the entry point. This is only valid for executables. The entry point method must be named Main, and must be declared static.


Do not use the global or local configuration file (csc.rsp). You can find the global csc.rsp file in %SystemRoot%\Microsoft.NET\Framework\VERSION, in which VERSION is a version of the .NET Framework. This file contains default arguments for the C# compiler, including the list of assemblies that are imported by default. If you create a file named csc.rsp in the same directory as your source code, it is processed after the global configuration file.


Suppresses display of the banner and copyright messages.


With /nostdlib+ or /nostdlib, the C# compiler will not import mscorlib.dll, which defines the fundamental types used in .NET and most of the System namespace.

/nowarn :number1[; number2 ...]

Specifies a list of warning numbers to ignore. Do not include the alphabetic part of the warning. For example, to suppress warning CS0169, use /nowarn:169.


Enables or disables compiler optimizations. By default, optimizations are enabled.

/out :file

Specifies the output filename.

/recurse :wildcard

Recursively searches directories for source code files matching wildcard (which may include directory names).

/r[eference] :file1[; file2 ...]

Imports metadata from one or more named assemblies. Generally used with DLLs, but you may also specify executables.

/res[ource] :file[ ,id]

Specifies a .NET resource (and optional identifier) to embed in the generated assembly.

/t[arget] :format

Specifies the format of the output file. The valid formats are library (DLL library), module (a library without an assembly manifest), exe (console application), or winexe (Windows application).


Enables or disables (the default) unsafe code. Unsafe code is enclosed in a block marked by the unsafe keyword.


Displays compiler console output using UTF-8 encoding.

/w[arn] :level

Sets the compiler warning level from 0 (no warnings) to 4 (the default, all warnings).


Enables or disables (the default) treating warnings as errors (warnings halt compilation).

/win32icon :file

Specifies an icon (.ico) file to use as the application's icon.

/win32res :file

Specifies a Win32 resource (.res) file to insert in the output file.

    Part II: Programming with the .NET Framework
    Part IV: API Quick Reference