Professional ASP.NET 1.1 [Electronic resources]

Alex Homeret

نسخه متنی -صفحه : 244/ 37
نمايش فراداده

The .NET Language Compilers

When working within the Visual Studio .NET environment, you don't need to worry about the compiler, because the editor takes care of compilation. Likewise, when simply developing ASP.NET pages, you can rely on the framework to compile pages as required. However, when building components or controls, you'd want to compile code into a DLL, so you need to know how the compiler works.

There is a separate compiler for each language, but luckily, you use them all in the same way, and most of the switches and flags are identical. The compilers are:

csc for C#.

vbc for Visual Basic .NET.

jsc for JScript.NET.

These are automatically part of the .NET installation, and are invoked from the command line. For example:

vbc /t:library /out:..\bin\People.dll /r:system.dll person.vb programmer.vb

This compiles the

person.vb and

programmer.vb source files into an assembly named

People.dll .

Compiler switches fall into two usage categories. The first includes those that enable or disable an option: in this case, the switch or the switch name followed by plus enables the option, and the switch name followed by minus disables it. For example:

/cls

Enables the option

/cls+

Enables the option

/cls-

Disables the option

The second category contains switches that specify a file or reference. Here a colon (

: ) separates the switch and the argument. For example:

/out:..\bin\People.dll

The full list of options including a list of which languages the option is supported in is as follows:

Option

Language

Description

@

All

Specify the file containing the compiler options.

/?

/help

All

Display the options, without compiling any code.

/addmodule:module

VB / C#

Reference metadata from the specified

module .

/autoref

JScript

Automatically reference assemblies based on imported namespaces and fully qualified names. This defaults to

on .

/baseaddress:number

VB / C#

Specify, as a hexadecimal

number , the base address of the DLL.

/bugreport:file

VB / C#

Create a

file containing information that can be used when filing bug reports.

/checked

C#

Generate overflow checks

/codepage:id

JScript / C#

Specify the code page

id used in source files.

/debug

All

Add debugging information to the created file. This is required if you need to debug into components.

/define:symbols

All

Define conditional compiler constants. You can define multiple constants by separating them with commas. For example:

/define:DBTracing=True,CustomErr

ors=False

/doc:file

C#

Emit the XML documentation in the source files into the named

file .

/delaysign

VB

Delay-sign the assembly, using only the public part of the strong name key.

/fast

JScript

Disable language features to allow better code generation.

/filealign:n

C#

Specify the alignment used for output file sections.

/fullpaths

C#

Generate fully qualified paths.

/imports:list

VB

Import a namespace from the specified assembly.

/incr

/incremental

C#

Enable or disable incremental compilation.

/keycontainer

VB

Create a unique container name for a key. Used when generating shared components as it inserts a public key into the assembly manifest, and signs the assembly with a private key. Can be used with the

sn utility which manages keys.

/keyfile

VB

Specify the file containing the public and private keys to be added to a shared component. This can be used with the

sn utility, which manages keys.

/lcid:id

JScript

Use the specified locale

id for the default code page and messages.

/lib:directories

C# / JScript

Specify additional

directories to search for references.

/libpath:directories

VB

Specify additional

directories to search for references.

/linkres:resinfo

/linkresource:resinfo

All

Create a link to a resource file. The first argument is the file name containing the resource, and an optional second argument specifies the identifier in the resource file. For example:

/linkresource:Wrox.resource,Auth

orBio

/m:type

/main:type

C# / VB

Specify the class or module

type that contains the main start-up procedure.

/noconfig

C#

Do not auto-include

CSC.RSP file.

/nologo

C# / VB

Don't show the copyright banner during compile. This makes it a lot easier to see compilation messages.

/nowarn

VB

Disable warnings.

/nostdlib

C# / JScript

Enable or disable the import of the standard library

mscorlib.dll compilation.

/nowarn:list

C#

Disable warning messages specified in the

list .

/optimize

C# / VB

Enable or disable compiler optimizations.

/optioncompare:type

VB

Specify the

type of comparison used for strings. The values are

text or

binary (the default). For example:

optioncompare:text

/optionexplicit

VB

Enable (the default) or disable explicit variable declaration.

/optionstrict

VB

Enables (the default) or disables strict type conversions. In strict mode the only implicit conversions are those that widen types (for example an integer to a long).

/out:file

All

Specify the name of the output

file . By default a DLL will take its name from the first sourcecode file, and an EXE will take its name from the file containing the main procedure.

/print

JScript

Enable or disable provision of the

print() function.

/quiet

VB

Quiet output mode.

/recurse:wildcard

C# / VB

Recurse through subdirectories compiling files. For example:

vbc /target:library /out:Foo.dll

/recurse:inc\*.vb

/r:list

/reference:list

All

Reference metadata from the specified file

list . For multiple files use a semi-colon (

; ) to separate them.

/removeintchecks

VB

Enable or disable (the default) overflow error checking for integer variables.

/res:resinfo

/resource:resinfo

All

Embed a resource into the assembly. The first argument is the file name containing the resource, and an optional second argument specifies the identifier in the resource file. For example:

/resource:Wrox.resource,AuthorBio

/rootnamespace

VB

Indicate the namespace in which all type declarations will appear.

/target:type

All

Indicate the

type of file to be created. This can be one of:

exe , for a console application

library , for a DLL

module, for a module

winexe , for a Windows application

The

module option is not applicable in JScript .NET.

/time

C#

Display the project compile-times.

/unsafe

C#

Enable or disable unsafe code.

/utf8output

All

Output compiler messages in UTF-8 encoding.

/verbose

VB

Enable or disable verbose error and information messages.

/versionsafe

JScript

Enable or disable specification of default for members that aren't marked as

override or

new .

/w:n

/warn:n

C# / JScript

Set the warning level to

n .

/warnaserror

All

Enable or disable the treatment of warnings as errors.

/win32icon:file

C# / VB

Specify the icon

file (

.ico ) to be added to the resource.

/win32res:file

/win32resource:file

All

Insert a Win32 resource

file into the target.