Section H.2. Command-Line Switches


H.2. Command-Line Switches

The VB compiler supports the following command-line switches .

H.2.1. Output Filename and File Type

Switch

Description

/out:<file>

Defines the output filename. If not present, the output file will have the same root filename as the first input file. <file> need not include a file extension.

/target:<type>

or:

/t:<type>

Defines the type of file to be generated by the compiler. <type> can be any of the following keywords: exe (to create a console application), winexe (to create a Windows application), library (to create a library assembly in a DLL), or module (to create a ".netmodule" file that can be added to an assembly). If the switch is not present, <type> defaults to exe.


H.2.2. Input Files

Switch

Description

/addmodule:<file>

Includes the ".netmodule" file named <file> in the output file. May include multiple comma-separated files.

/libpath:<path>

Specifies the directory or directories to search for metadata references (which are specified by the /reference switch) that are not found in either the current directory or the CLR's system directory. <path> is a list of directories, with multiple directories separated by semicolons. You can also use /libpath multiple times to add additional paths. By default, the global assembly cache is automatically searched for references.

/recurse:<[dir\]wildcard>

Compiles all files in the current directory and its subdirectories according to the wildcard specifications. For example:

     vbc /recurse:*.vb /t:library         /out:mylibrary.lib 

If you use the /recurse switch, you do not have to name a specific file to compile; however, if you do, it should not match the specification provided as an argument to the /recurse switch. To start from a directory other than the current directory, prepend the wildcard with the directory path.

/reference:<file>

or:

/r:<file>

References metadata from the assemblies contained in <file>. May include multiple comma-separated files. Each filename in <file> must include a file extension.

/sdkpath:<path>

New in 2005. Indicates the location of the main .NET library files mscorlib.dll and microsoft.visualbasic.dll. <path> indicates the folder. This switch is often used with the /netcf switch.


H.2.3. Resources

Switch

Description

/linkresource:<resinfo>

or:

/linkres:<resinfo>

Links to a managed resource file without embedding it in the output file. <resinfo> has the form:

 <file>[,<name>[,public|private]] 

where <file> is the filename of the resource, <name> is the logical name used to load the resource, and the public and private keywords determine whether the resource is public or private in the assembly manifest. By default, resources are public.

/resource:<resinfo>

or:

/res:<resinfo>

Embeds the managed resource or resources named <resinfo> in the output file. <resinfo> takes the form:

 <file>[,<name>[,public|private]] 

where <file> is the filename of the resource, <name> is the logical name used to load the resource, and the public and private keywords determine whether the resource is public or private in the assembly manifest. By default, resources are public. The /resource switch cannot be used with the /target:module switch.

/win32icon:<file>

Indicates the path to the Win32 icon (.ico) file for the output file.

/win32resource:<file>

Indicates the path to a Win32 resource (.res) file to insert into the output file.


H.2.4. Code Generation

Switch

Description

/netcf

New in 2005. Tells the compiler to target the .NET Compact Framework. This switch is often used with the /sdkpath switch.

/optimize[+|-]

Enables (+) or disables () the compiler's code optimizers. Optimizing generates smaller binary files that offer improved efficiency and performance but are more difficult to debug. Its default value is on (+). /optimize is equivalent to /optimize+.

/platform:<type>

New in 2005. Indicates the target processor platform. The <type> argument is one of the following: anycpu (any CPU), x86 (Intel 32-bit compatible processor), x64 (AMD 64-bit processor), or Itanium (Intel 64-bit processor). The default is to target any CPU.

/removeintchecks[+|-]

Enables (-) or disables (+) integer overflow checks. (Yes, the options do seem reversed.) The default is to enable these checks (-), which improves safety but reduces performance. /removeintchecks is equivalent to /removeintchecks+.


H.2.5. Debugging

Switch

Description

/debug[+|-]

Instructs the compiler to include (+) or exclude (-) debugging information in the compiled output file. The default value is /debug-, which suppresses the generation of debug information. /debug+ and /debug are equivalent.

/debug:full

or:

/debug:pdbonly

Defines the form of debugging information output by the compiler. The full option generates full debugging information and allows a debugger to be attached to the running program; this is the default value if debugging is enabled. The pdbonly option generates a debug symbol (.pdb) file only. It supports source-code debugging when the program is started in the debugger but displays assembler only when the running program is attached to the debugger.


H.2.6. Errors and Warnings

Switch

Description

/bugreport:<file>

Generates a file named <file> that contains information needed to report a compiler bug. May be used with the /errorreport switch.

/errorreport:<type>

New in 2005. Indicates how internal errors in the compiler should be reported to Microsoft. The values for <type> include: prompt (ask whether to send the error to Microsoft or not, pending security settings), send (if security settings allow, send the error report to Microsoft automatically), and none (output errors to a text file, but do not report them to Microsoft). If this switch is not used, none is the default. May be used with the /bugreport switch.

/nowarn[:<warnList>]

Disables compiler-generated warnings about nonfatal code errors. New variation in 2005: You can include a comma-separated list of warning codes, <warnlist>, to suppress specific compiler warnings.

/unify

New in 2005. Suppresses warnings concerning mismatched assembly version numbers.

/warnaserror[+|-]

Instructs the compiler to abort (+) or continue (-) when encountering normally nonfatal code errors. That is, when this option is enabled, the compiler treats warnings as errors, preventing the code from compiling. Its default value is off (-). /warnaserror is equivalent to /warnaserror+.


H.2.7. Language

Switch

Description

/define:<symbol>

or:

/d:<symbol>

Declares global conditional compiler constants. <symbol> has the form name=value, with multiple name-value pairs separated by commas. See the Conditional Compilation Constants section later in this appendix for information on predefined constants.

/imports:<namespace>

Globally imports namespaces, eliminating the need to define them with individual Imports statements. <namespace> is a comma-delimited list of namespaces.

/optioncompare:<type>

Indicates the method used for string comparison. The values for <type> include: binary (case-sensitive comparisons) and text (case-insensitive comparisons). The default value is binary. This switch sets the default application-wide setting; it does not override any explicit Option Compare statements found in individual source-code files.

/optionexplicit[+|-]

Indicates that variables must be explicitly defined (+) or not (-) before they are used. The default setting is on (+). This switch sets the default application-wide setting; it does not override any explicit Option Explicit statements found in individual source-code files. /optionexplicit is the same as /optionexplicit+.

/optionstrict[+|-]

Indicates that implicit narrowing conversions should be allowed (-) or rejected (+) by the compiler. The default setting is off (-). This switch sets the default application-wide setting; it does not override any explicit Option Strict statements found in individual source-code files. /optionstrict is the same as /optionstrict.

/rootnamespace:<namespace>

Defines a root namespace for all type declarations. This means that an Imports statement need not be used to import the root namespace, and that the relative path of a type (starting from the root namespace) can be used in place of its fully qualified name. Any Imports statements, however, must contain the fully qualified namespace name.


H.2.8. Miscellaneous

Switch

Description

/help

or:

/?

Displays information on compiler option usage.

/nologo

Suppresses the display of the compiler's copyright banner.

/quiet

Turns on quiet output mode; the compiler displays less information about errors than it does ordinarily. Specifically, it withholds the display of errant source code from error messages.

/verbose[+|-]

Causes the compiler to emit verbose (+) or standard (-) status and error messages. The default setting is off (-). /verbose is the same as /verbose+.


H.2.9. Advanced

Switch

Description

/baseaddress:<number>

Specifies the default base address at which a DLL library should be loaded. Runtime performance increases when all loaded DLLs for an application have a unique base address. <number> is a hexadecimal address.

/codepage:<id>

New in 2005. Indicates the code page that the compiler should use when generating the output file. <id> is the numeric identifier of the code page to use.

/delaysign[+|-]

Indicates whether the generated assembly will be fully signed (-) or partially signed (+). Partially signed assemblies use only the public portion of the strong name key. The default setting is fully signed (-). The /delaysign option must be used with either the /keycontainer or /keyfile switch.

/doc[+|-]

New in 2005. Indicates whether the compiler should generate an XML documentation file (+) or not (-). The default is to not generate the file (-). If generated, the XML file shares the same base name as the compiled output file but with a ".xml" extension.

/doc:<file>

New in 2005. Indicates that the compiler should generate an XML documentation file. <file> is the name of the file to generate.

/filealign:<number>

New in 2005. Specifies the boundary size used to align sections of the compiled output in bytes. <number> must be one of the following values: 512, 1024, 2048, 4096, or 8192.

/keycontainer:<container>

Specifies a strong-name key container with the assembly's key pair. The name of the container is indicated by <container>. May be used with the /delaysign switch.

/keyfile:<file>

Specifies the file containing a key or key pair that will be used to give an assembly a strong name. The file name is indicated by <file>. May be used with the /delaysign switch.

/main:<class>

or:

/m:<class>

Specifies the class or module that contains Sub Main, the entry point for applications and components. This switch is particularly useful if more than one class or module in a project has a subroutine named Main. <class> can be a module name (optionally prefixed with a namespace) or a Windows Form class.

/noconfig

New in 2005. The vbc.rsp file, a response file found in the same directory as vbc.exe, contains default configuration settings for use by the compiler. This switch instructs the compiler to ignore the vbc.rsp file. See the Using a Response File section below for information on response files and their contents.

/nostdlib

New in 2005. By default, the compiler references the Mscorlib.dll, System.dll, and Microsoft.VisualBasic.dll assembly files when compiling source code. This switch instructs the compiler to ignore these assembly files.

/utf8output[+|-]

Emits compiler output in UTF8 character encoding (+) or with default encoding (-). UTF8 encoding is useful when local settings prevent compiler output from being displayed correctly on the console. The default value is off (-). /utf8output is the same as /utf8output+.





Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net