VB.NET 1.1 Tutorial - Command Line Compiler Options


Most Visual Basic applications can be compiled without using any of the specialized compiler options. However, during the development process in particular, you may want to use some of the options that the compiler offers.

All of the compiler options are listed in the .NET Framework SDK Documentation that is shipped with the SDK. Here we will take a look at a few of the options.

The /out option

The /out compiler option specifies the name of the output file.

If you do not specify the name of the output file:

  1. An .exe will take its name from the source code file that contains the Main method.
  2. A .dll will take its name from the first source code file.

vbc /t:winexe /r:system.dll,system.windows.forms.dll /out:MyProject *.vb

The /target option

The /target compiler option can be specified in one of four forms:

  1. /target:exe - Create an console .exe application.
  2. /target:library - Create a dynamic-link library (DLL).
  3. /target:module - Create a module.
  4. /target:winexe - Create a Windows program.

The /target compiler option can be shortened to /t.

The /target:exe option causes the compiler to create an executable (EXE), console application. This option is the default, so if no /target: is supplied, this will be used. The executable file will be created with the .exe extension.

vbc /t:exe /r:system.dll file.vb

The /target:library option causes the compiler to create a dynamic-link library (DLL) rather than an executable file (EXE). The DLL will be created with the .dll extension.

vbc /t:library /r:system.dll file.vb

To not generate an assembly manifest, use the /target:module option. By default, the output file will have an extension of .netmodule.

vbc /t:module /r:system.dll file.vb

The /target:winexe option causes the compiler to create an executable (EXE), Windows program. The executable file will be created with the .exe extension. A Windows program is one that provides a user interface from either the .NET Framework library or with the Win32 APIs.

vbc /t:winexe /r:system.dll,system.windows.forms.dll file.vb

The /help option

This option sends a listing of compiler options, and a brief description of each option, to stdout. If this option is included in a compilation, no output file will be created and no compilation will take place.

vbc /help

References

For more information on the Visual Basic Compiler Options, visit MSDN at microsoft here

What Next?

Lets take a look at comments.

Return to the Tutorial Contents.