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 :)
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 |