C# Compiler Options Listed by Category


Updated: July 20, 2015

For the latest documentation on Visual Studio 2017 RC, see Visual Studio 2017 RC Documentation.

The following compiler options are sorted by category. For an alphabetical list, see C# Compiler Options Listed Alphabetically.


/filealignSpecifies the size of sections in the output file.
/optimizeEnables/disables optimizations.

Output Files

/docSpecifies an XML file where processed documentation comments are to be written.
/outSpecifies the output file.
/pdbSpecifies the file name and location of the .pdb file.
/platformSpecify the output platform.
/preferreduilangSpecify a language for compiler output.
/targetSpecifies the format of the output file using one of five options: /target:appcontainerexe, /target:exe, /target:library, /target:module, /target:winexe, or /target:winmdobj.
/modulename:<string>Specify the name of the source module

.NET Framework Assemblies

/addmoduleSpecifies one or more modules to be part of this assembly.
/delaysignInstructs the compiler to add the public key but to leave the assembly unsigned.
/keycontainerSpecifies the name of the cryptographic key container.
/keyfileSpecifies the filename containing the cryptographic key.
/libSpecifies the location of assemblies referenced by means of /reference.
/nostdlibInstructs the compiler not to import the standard library (mscorlib.dll).
/referenceImports metadata from a file that contains an assembly.
/analyzerRun the analyzers from this assembly (Short form: /a)
/additionalfileNames additional files that don't directly affect code generation but may be used by analyzers for producing errors or warnings.

Debugging/Error Checking

/bugreportCreates a file that contains information that makes it easy to report a bug.
/checkedSpecifies whether integer arithmetic that overflows the bounds of the data type will cause an exception at run time.
/debugInstruct the compiler to emit debugging information.
/errorreportSets error reporting behavior.
/fullpathsSpecifies the absolute path to the file in compiler output.
/nowarnSuppresses the compiler's generation of specified warnings.
/warnSets the warning level.
/warnaserrorPromotes warnings to errors.
/ruleset:<file>Specify a ruleset file that disables specific diagnostics.


/defineDefines preprocessor symbols.


/linkMakes COM type information in specified assemblies available to the project.
/linkresourceCreates a link to a managed resource.
/resourceEmbeds a .NET Framework resource into the output file.
/win32iconSpecifies an .ico file to insert into the output file.
/win32resSpecifies a Win32 resource to insert into the output file.


@Specifies a response file.
/?Lists compiler options to stdout.
/baseaddressSpecifies the preferred base address at which to load a DLL.
/codepageSpecifies the code page to use for all source code files in the compilation.
/helpLists compiler options to stdout.
/highentropyvaSpecifies that the executable file supports address space layout randomization (ASLR).
/langversionSpecify language version mode: ISO-1, ISO-2, 3, 4, 5, 6, or Default
/mainSpecifies the location of the Main method.
/noconfigInstructs the compiler not to compile with csc.rsp.
/nologoSuppresses compiler banner information.
/recurseSearches subdirectories for source files to compile.
/subsystemversionSpecifies the minimum version of the subsystem that the executable file can use.
/unsafeEnables compilation of code that uses the unsafe keyword.
/utf8outputDisplays compiler output using UTF-8 encoding.
/parallel[+&#124;-]Specifies whether to use concurrent build (+).
/checksumalgorithm:<alg>Specify the algorithm for calculating the source file checksum stored in PDB. Supported values are: SHA1 (default) or SHA256.
/incrementalEnables incremental compilation.

C# Compiler Options
C# Compiler Options Listed Alphabetically
How to: Set Environment Variables for the Visual Studio Command Line