Info

This option is used to specify the name of the assembly to be created. By default, the assembly name is the same as the name of the initial input *.vb file.

/target:

exe

This option builds an executable console application. This is the default target, and thus may be omitted when building console applications.

/target:

: library

This option builds a single-file *.dll assembly.

/target:

:module

This option builds a module. Modules are elements of multifile assemblies (fully described in Chapter 15).

/target:

:winexe

This option builds an executable Windows application. Although you are free to build Windows-based applications using the /target:exe flag, the /target:winexe flag prevents a console window from appearing in the background.

To compile TestApp.vb into a console application named TestApp.exe, open a Visual Studio 2008 command prompt and change to the directory containing your *.vb source code file using the cd command:

cd c:\VbcExample

Next, enter the following command set (note that command-line flags must come before the name of the input files, not after):

vbc /target:exe TestApp.vb

Here I did not explicitly specify an /out flag, therefore the executable will be named TestApp.exe, given the name of the initial input file. However, if you wish to specify a unique name for your assembly, you could enter the following command:

vbc /target:exe /out:MyFirstApp.exe TestApp.vb

Also be aware that most of the VB 2008 compiler flags support an abbreviated version, such as /t rather than /target (you can view all abbreviations by entering vbc /? at the command prompt). For example, you can save yourself a few keystrokes by specifying the following:

vbc /t:exe TestApp.vb

Furthermore, given that the /t:exe flag is the default output used by the VB 2008 compiler, you could also compile TestApp.vb simply by typing the following:

vbc TestApp.vb

TestApp.exe can now be run from the command line by typing the name of the executable and pressing the Enter key. If all is well, you should see the message "Testing! 1, 2, 3" print out to the command window (see Figure 2-2).

SH Administrator Visual Studio 2008 Command Prompt

C:\My Books\VB and the Test!ngi 1, 2, 3

.NET Paltform 3rd Ed\Code\Chapter

2\VbcExample>TestApp.exe

C:\My Books\VB and the

.NET Paltform 3rd Ed\Code\Chapter

2\VbcExample>m

Was this article helpful?

0 0

Post a comment