Sample Compilation Command Lines (Visual Basic)


Updated: July 20, 2015

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

As an alternative to compiling Visual Basic programs from within Visual Studio, you can compile from the command line to produce executable (.exe) files or dynamic-link library (.dll) files.

The Visual Basic command-line compiler supports a complete set of options that control input and output files, assemblies, and debug and preprocessor options. Each option is available in two interchangeable forms: -``option and /``option. This documentation shows only the /``option form.

The following table lists some sample command lines you can modify for your own use.

Compile File.vb and create File.exevbc /reference:Microsoft.VisualBasic.dll File.vb
Compile File.vb and create File.dllvbc /target:library File.vb
Compile File.vb and create My.exevbc /out:My.exe File.vb
Compile all Visual Basic files in the current directory, with optimizations on and the DEBUG symbol defined, producing File2.exevbc /define:DEBUG=1 /optimize /out:File2.exe *.vb
Compile all Visual Basic files in the current directory, producing a debug version of File2.dll without displaying the logo or warningsvbc /target:library /out:File2.dll /nowarn /nologo /debug *.vb
Compile all Visual Basic files in the current directory to Something.dllvbc /target:library /out:Something.dll *.vb

When compiling from the command line, you must explicitly reference the Microsoft Visual Basic run-time library through the /reference compiler option.

System_CAPS_ICON_tip.jpg Tip

When you build a project by using the Visual Studio IDE, you can display information about the associated vbc command with its compiler options in the output window. To display this information, open the Options Dialog Box, Projects and Solutions, Build and Run, and then set the MSBuild project build output verbosity to Normal or a higher level of verbosity. For more information, see How to: View, Save, and Configure Build Log Files.

Visual Basic Command-Line Compiler
Conditional Compilation