org.apache.tools.ant.taskdefs.optional.dotnet
public class CSharp extends DotnetCompile
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 :)
For historical reasons the pattern
**
/*.cs
is preset as includes list and
you can not override it with an explicit includes attribute. Use
nested <src>
elements instead of the basedir
attribute if you need more control.
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>
Since: Ant 1.3
UNKNOWN: name="csc" category="dotnet"
Field Summary | |
---|---|
protected boolean | unsafe
enable unsafe code flag. |
Constructor Summary | |
---|---|
CSharp()
constructor inits everything and set up the search pattern |
Method Summary | |
---|---|
void | addCompilerSpecificOptions(NetCommand command)
add Commands unique to C#. |
void | clear()
full cleanup |
protected String | createResourceParameter(DotnetResource resource)
from a resource, get the resource param string |
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. |
protected String | getDocFileParameter()
get the argument or null for no argument needed
|
protected String | getFileAlignParameter()
get the argument or null for no argument needed
|
String | getFileExtension()
This method indicates the filename extension for C# files. |
protected String | getFullPathsParameter()
Gets the fullPathsParameter attribute of the CSharp object
|
boolean | getIncremental()
query the incrementalflag
|
protected String | getIncrementalParameter()
get the incremental build argument
|
protected String | getNoConfigParameter()
Gets the noConfigParameter attribute of the CSharp object
|
String | getReferenceDelimiter()
Returns the delimiter which C# uses to separate references, i.e., a semi colon. |
boolean | getUnsafe()
query the Unsafe attribute
|
protected String | getUnsafeParameter()
get the argument or null for no argument needed
|
void | setDefinitions(String params)
Semicolon separated list of defined constants.
|
void | setDocFile(File f)
file for generated XML documentation
|
void | setFileAlign(int fileAlign)
Set the file alignment.
|
void | setFullPaths(boolean enabled)
If true, print the full path of files on errors.
|
void | setIncremental(boolean incremental)
set the incremental compilation flag on or off.
|
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
|
void | setOutputFile(File params)
The output file. |
void | setUnsafe(boolean unsafe)
If true, enables the unsafe keyword.
|
Parameters: command ongoing command
Parameters: resource
Returns: a string containing the resource param, or a null string to conditionally exclude a resource.
Returns: The Definitions Parameter to CSC
Returns: The DocFile Parameter to CSC
Returns: The OutputFile Parameter to CSC
Returns: the file extension for C#, i.e., "cs" (without the dot).
Returns: The fullPathsParameter value or null if unset
Returns: true if incremental compilation is turned on
Returns: The Incremental Parameter to CSC
Returns: The noConfigParameter value
Returns: The Unsafe value
Returns: The Unsafe Parameter to CSC
Parameters: params The new definitions value
Parameters: f output file
Parameters: enabled The new fullPaths value
Parameters: incremental on/off flag
Parameters: enabled The new noConfig value
Parameters: params The new outputFile value
Parameters: unsafe The new Unsafe value