Compiles C# source into executables or modules.
csc.exe on Windows or mcs on other platforms must be on the execute path, unless another executable
or the full path to that executable is specified in the
executable
parameter
All parameters are optional: <csc/> should suffice to produce a debug
build of all *.cs files. However, naming an
destFilestops the
csc compiler from choosing an output name from random, and
allows the dependency checker to determine if the file is out of date.
The task is a directory based task, so attributes like
includes="*.cs"
and
excludes="broken.cs" can be used to control the files pulled
in. By default, all *.cs files from the project folder down are included in
the command. When this happens the output file -if not specified- is taken
as the first file in the list, which may be somewhat hard to control.
Specifying the output file with
destFile seems prudent.
For more complex source trees, nested
src elemements can be
supplied. When such an element is present, the implicit fileset is ignored.
This makes sense, when you think about it :)
References to external files can be made through the references attribute,
or (since Ant1.6), via nested <reference> filesets. With the latter,
the timestamps of the references are also used in the dependency
checking algorithm.
Example
<csc
optimize="true"
debug="false"
docFile="documentation.xml"
warnLevel="4"
unsafe="false"
targetType="exe"
incremental="false"
mainClass = "MainApp"
destFile="NetApp.exe"
>
<src dir="src" includes="*.cs" />
<reference file="${testCSC.dll}" />
<define name="RELEASE" />
<define name="DEBUG" if="debug.property"/>
<define name="def3" unless="def3.property"/>
</csc>
addCompilerSpecificOptions
public void addCompilerSpecificOptions(NetCommand command)
add Commands unique to C#.
- addCompilerSpecificOptions in interface DotnetCompile
command
- ongoing command
clear
public void clear()
full cleanup
- clear in interface DotnetCompile
createResourceParameter
protected String createResourceParameter(DotnetResource resource)
from a resource, get the resource param string
- createResourceParameter in interface DotnetCompile
resource
-
- a string containing the resource param, or a null string
to conditionally exclude a resource.
getDefinitionsParameter
protected String getDefinitionsParameter()
override the superclasses version of this method (which we call)
with a check for a definitions attribute, the contents of which
are appended to the list.
- getDefinitionsParameter in interface DotnetCompile
- The Definitions Parameter to CSC
getDocFileParameter
protected String getDocFileParameter()
get the argument or null for no argument needed
- The DocFile Parameter to CSC
getFileAlignParameter
protected String getFileAlignParameter()
get the argument or null for no argument needed
- The OutputFile Parameter to CSC
getFileExtension
public String getFileExtension()
This method indicates the filename extension for C# files.
- getFileExtension in interface DotnetCompile
- the file extension for C#, i.e., "cs" (without the dot).
getFullPathsParameter
protected String getFullPathsParameter()
Gets the fullPathsParameter attribute of the CSharp object
- The fullPathsParameter value or null if unset
getIncremental
public boolean getIncremental()
query the incrementalflag
- true if incremental compilation is turned on
getIncrementalParameter
protected String getIncrementalParameter()
get the incremental build argument
- The Incremental Parameter to CSC
getNoConfigParameter
protected String getNoConfigParameter()
Gets the noConfigParameter attribute of the CSharp object
- The noConfigParameter value
getReferenceDelimiter
public String getReferenceDelimiter()
Returns the delimiter which C# uses to separate references, i.e., a semi colon.
- getReferenceDelimiter in interface DotnetCompile
getUnsafe
public boolean getUnsafe()
query the Unsafe attribute
- The Unsafe value
getUnsafeParameter
protected String getUnsafeParameter()
get the argument or null for no argument needed
- The Unsafe Parameter to CSC
setDefinitions
public void setDefinitions(String params)
Semicolon separated list of defined constants.
params
- The new definitions value
setDocFile
public void setDocFile(File f)
file for generated XML documentation
f
- output file
setFileAlign
public void setFileAlign(int fileAlign)
Set the file alignment.
Valid values are 0,512, 1024, 2048, 4096, 8192,
and 16384, 0 means 'leave to the compiler'
setFullPaths
public void setFullPaths(boolean enabled)
If true, print the full path of files on errors.
enabled
- The new fullPaths value
setIncremental
public void setIncremental(boolean incremental)
set the incremental compilation flag on or off.
incremental
- on/off flag
setNoConfig
public void setNoConfig(boolean enabled)
A flag that tells the compiler not to read in the compiler
settings files 'csc.rsp' in its bin directory and then the local directory
enabled
- The new noConfig value
setOutputFile
public void setOutputFile(File params)
The output file. This is identical to the destFile attribute.
params
- The new outputFile value
setUnsafe
public void setUnsafe(boolean unsafe)
If true, enables the unsafe keyword.
unsafe
- The new Unsafe value