C# Compiler Options Listed by Category

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

Optimization

Option Purpose
/filealign Specifies the size of sections in the output file.
/optimize Enables/disables optimizations.

Output Files

Option Purpose
/doc Specifies an XML file where processed documentation comments are to be written.
/out Specifies the output file.
/pdb Specifies the file name and location of the .pdb file.
/platform Specify the output platform.
/preferreduilang Specify a language for compiler output.
/refout Generate a reference assembly in addition to the primary assembly.
/refonly Generate a reference assembly instead of a primary assembly.
/target Specifies 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

Option Purpose
/addmodule Specifies one or more modules to be part of this assembly.
/delaysign Instructs the compiler to add the public key but to leave the assembly unsigned.
/keycontainer Specifies the name of the cryptographic key container.
/keyfile Specifies the filename containing the cryptographic key.
/lib Specifies the location of assemblies referenced by means of /reference.
/nostdlib Instructs the compiler not to import the standard library (mscorlib.dll).
/reference Imports metadata from a file that contains an assembly.
/analyzer Run the analyzers from this assembly (Short form: /a)
/additionalfile Names additional files that don't directly affect code generation but may be used by analyzers for producing errors or warnings.

Debugging/Error Checking

Option Purpose
/bugreport Creates a file that contains information that makes it easy to report a bug.
/checked Specifies whether integer arithmetic that overflows the bounds of the data type will cause an exception at run time.
/debug Instruct the compiler to emit debugging information.
/errorreport Sets error reporting behavior.
/fullpaths Specifies the absolute path to the file in compiler output.
/nowarn Suppresses the compiler's generation of specified warnings.
/warn Sets the warning level.
/warnaserror Promotes warnings to errors.
/ruleset:<file> Specify a ruleset file that disables specific diagnostics.

Preprocessor

Option Purpose
/define Defines preprocessor symbols.

Resources

Option Purpose
/link Makes COM type information in specified assemblies available to the project.
/linkresource Creates a link to a managed resource.
/resource Embeds a .NET Framework resource into the output file.
/win32icon Specifies an .ico file to insert into the output file.
/win32res Specifies a Win32 resource to insert into the output file.

Miscellaneous

Option Purpose
@ Specifies a response file.
/? Lists compiler options to stdout.
/baseaddress Specifies the preferred base address at which to load a DLL.
/codepage Specifies the code page to use for all source code files in the compilation.
/help Lists compiler options to stdout.
/highentropyva Specifies that the executable file supports address space layout randomization (ASLR).
/langversion Specify language version mode: Default, ISO-1, ISO-2, 3, 4, 5, 6, 7, 7.1, or Latest
/main Specifies the location of the Main method.
/noconfig Instructs the compiler not to compile with csc.rsp.
/nologo Suppresses compiler banner information.
/recurse Searches subdirectories for source files to compile.
/subsystemversion Specifies the minimum version of the subsystem that the executable file can use.
/unsafe Enables compilation of code that uses the unsafe keyword.
/utf8output Displays compiler output using UTF-8 encoding.
/parallel[+|-] 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.

Obsolete Options

Option Purpose
/incremental Enables incremental compilation.

See Also

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