Visual Basic compiler options listed by category

The Visual Basic command-line compiler is provided as an alternative to compiling programs from within the Visual Studio integrated development environment (IDE). The following is a list of the Visual Basic command-line compiler options sorted by functional category.

Every compiler option is available in two forms: -option and /option. The documentation only shows the -option form.

Compiler output

Option Purpose
-nologo Suppresses compiler banner information.
-utf8output Displays compiler output using UTF-8 encoding.
-verbose Outputs extra information during compilation.
-modulename:<string> Specify the name of the source module
-preferreduilang Specify a language for compiler output.

Optimization

Option Purpose
-filealign Specifies where to align the sections of the output file.
-optimize Enables/disables optimizations.

Output files

Option Purpose
-doc Process documentation comments to an XML file.
-deterministic Causes the compiler to output an assembly whose binary content is identical across compilations if inputs are identical.
-netcf Sets the compiler to target the .NET Compact Framework.
-out Specifies an output file.
-refonly Outputs only a reference assembly.
-refout Specifies the output path of a reference assembly.
-target Specifies the format of the output.

.NET assemblies

Option Purpose
-addmodule Causes the compiler to make all type information from the specified file(s) available to the project you are currently compiling.
-delaysign Specifies whether the assembly will be fully or partially signed.
-imports Imports a namespace from a specified assembly.
-keycontainer Specifies a key container name for a key pair to give an assembly a strong name.
-keyfile Specifies a file containing a key or key pair to give an assembly a strong name.
-libpath Specifies the location of assemblies referenced by the -reference option.
-reference Imports metadata from an assembly.
-moduleassemblyname Specifies the name of the assembly that a module will be a part of.
-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.
-debug Produces debugging information.
-nowarn Suppresses the compiler's ability to generate warnings.
-quiet Prevents the compiler from displaying code for syntax-related errors and warnings.
-removeintchecks Disables integer overflow checking.
-warnaserror Promotes warnings to errors.
-ruleset:<file> Specify a ruleset file that disables specific diagnostics.

Help

Option Purpose
-? Displays the compiler options. This command is the same as specifying the -help option. No compilation occurs.
-help Displays the compiler options. This command is the same as specifying the -? option. No compilation occurs.

Language

Option Purpose
-langversion Specify language version: 9|9.0|10|10.0|11|11.0.
-optionexplicit Enforces explicit declaration of variables.
-optionstrict Enforces strict type semantics.
-optioncompare Specifies whether string comparisons should be binary or use locale-specific text semantics.
-optioninfer Enables the use of local type inference in variable declarations.

Preprocessor

Option Purpose
-define Defines symbols for conditional compilation.

Resources

Option Purpose
-linkresource Creates a link to a managed resource.
-resource Embeds a managed resource in an assembly.
-win32icon Inserts an .ico file into the output file.
-win32resource Inserts a Win32 resource into the output file.

Miscellaneous

Option Purpose
@ (Specify Response File) Specifies a response file.
-baseaddress Specifies the base address of a DLL.
-codepage Specifies the code page to use for all source code files in the compilation.
-errorreport Specifies how the Visual Basic compiler should report internal compiler errors.
-highentropyva Tells the Windows kernel whether a particular executable supports high entropy Address Space Layout Randomization (ASLR).
-main Specifies the class that contains the Sub Main procedure to use at startup.
-noconfig Do not compile with Vbc.rsp
-nostdlib Causes the compiler not to reference the standard libraries.
-nowin32manifest Instructs the compiler not to embed any application manifest into the executable file.
-platform Specifies the processor platform the compiler targets for the output file.
-recurse Searches subdirectories for source files to compile.
-rootnamespace Specifies a namespace for all type declarations.
-sdkpath Specifies the location of Mscorlib.dll and Microsoft.VisualBasic.dll.
-vbruntime Specifies that the compiler should compile without a reference to the Visual Basic Runtime Library, or with a reference to a specific runtime library.
-win32manifest Identifies a user-defined Win32 application manifest file to be embedded into a project's portable executable (PE) file.
-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.
Due to collision problems with SHA1, Microsoft recommends SHA256 or better.

See also