Appendix E. The VB .NET Command-Line Compiler

With the release of the .NET Framework Software Development Kit (SDK), Visual Basic for the first time features a command-line compiler that allows you to create and compile Visual Basic components and applications apart from Visual Studio. Ironically, this means that one of VB .NET’s significant advances is the ability to use your favorite text editor, such as NotePad or WinEdit, to create VB .NET code. This appendix details the operation of the compiler, vbc.exe.

Compiler Basics

Syntactically, the compiler is fairly typical in that it uses command-line switches to control its operation. A command-line switch is designated by a slash or hyphen followed by a keyword. If the keyword takes an argument, it is separated from the keyword by a colon (:). For example:

vbc sample1.vb /target:library

supplies the library keyword as an argument to create a library file (that is, a DLL). If multiple arguments are required, they are separated from one another by commas. For example:

vbc sample1.vb /r:system.design.dll,system.messaging.dll

references the metadata in the system.design.dll and system.messaging.dll assemblies.

The minimal syntax required to compile a file named sample1.vb is:

vbc sample1.vb

This generates a console-mode application. You can specify the type of component or application you wish to generate by using the /target switch. To generate a Windows executable, you’d enter something like the following at the command line:

vbc sample1.vb ...

Get VB .NET Language in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.