blob: b715389edd894bd1c5acf93b58b31cdc5805feb2 [file] [log] [blame]
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<html>
<head>
<meta http-equiv="Content-Language" content="en-us"></meta>
<link rel="stylesheet" type="text/css" href="style.css">
<title>Csc Task</title>
</head>
<body>
<h2>Csc Task</h2>
<h3>Description</h3>
<p>Compiles C# source into executables or modules. csc.exe on
Windows or mcs on any other platform must be on the execute path,
unless another executable or the full path to that executable is
specified in the <tt>executable</tt> parameter </p>
<p>All parameters are optional: <code>&lt;csc/&gt;</code> should
suffice to produce a debug build of all *.cs files. However,
naming an <tt>destFile</tt> stops the csc compiler from choosing an
output name from random, and allows the dependency checker to
determine if the file is out of date. </p>
<p>The task is a directory based task, so attributes like
<b>includes="*.cs" </b> and <b>excludes="broken.cs"</b> 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 <tt>destFile</tt> seems
prudent. </p>
<p>For more complex source trees, nested <tt>src</tt> elements
can be supplied. When such an element is present, the implicit
fileset is ignored. This makes sense, when you think about it :)
</p>
<p>For historical reasons the pattern <code>**/*.cs</code> is
preset as includes list and you can not override it with an
explicit includes attribute. Use nested <code>&lt;src&gt;</code>
elements instead of the basedir attribute if you need more
control.</p> </p>
<p>References to external files can be made through the references
attribute, or via nested <code>&lt;reference&gt;</code>
filesets. With the latter, the timestamps of the references are
also used in the dependency checking algorithm. </p>
<h3><a name="attributes">Parameters</a></h3>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
<td valign="top"><b>Attribute</b></td>
<td valign="top"><b>Description</b></td>
<td valign="top"><b>Type</b></td>
<td align="center" valign="top"><b>Required</b></td>
</tr>
<tr>
<td valign="top">
additionalmodules
</td>
<td valign="top">
Semicolon separated list of modules to refer to.
</td>
<td valign="top">
String
</td>
<td valign="top" rowspan="26">
Optional
</td>
</tr>
<tr>
<td valign="top">
debug
</td>
<td valign="top">
set the debug flag on or off.
</td>
<td valign="top">
boolean
</td>
</tr>
<tr>
<td valign="top">
definitions
</td>
<td valign="top">
Semicolon separated list of defined constants.
</td>
<td valign="top">
String
</td>
</tr>
<tr>
<td valign="top">
destdir
</td>
<td valign="top">
Set the destination directory of files to be compiled.
</td>
<td valign="top">
File
</td>
</tr>
<tr>
<td valign="top">
destfile
</td>
<td valign="top">
Set the name of exe/library to create.
</td>
<td valign="top">
File
</td>
</tr>
<tr>
<td valign="top">
docfile
</td>
<td valign="top">
file for generated XML documentation
</td>
<td valign="top">
File
</td>
</tr>
<tr>
<td valign="top">
executable
</td>
<td valign="top">
set the name of the program, overriding the defaults. Can be
used to set the full path to a program, or to switch to an
alternate implementation of the command, such as the Mono or
Rotor versions -provided they use the same command line
arguments as the .NET framework edition
</td>
<td valign="top">
String
</td>
</tr>
<tr>
<td valign="top">
extraoptions
</td>
<td valign="top">
Any extra options which are not explicitly supported by this
task.
</td>
<td valign="top">
String
</td>
</tr>
<tr>
<td valign="top">
failonerror
</td>
<td valign="top">
If true, fail on compilation errors.
</td>
<td valign="top">
boolean
</td>
</tr>
<tr>
<td valign="top">
filealign
</td>
<td valign="top">
Set the file alignment. Valid values are 0,512, 1024, 2048,
4096, 8192, and 16384, 0 means 'leave to the compiler'
</td>
<td valign="top">
int
</td>
</tr>
<tr>
<td valign="top">
fullpaths
</td>
<td valign="top">
If true, print the full path of files on errors.
</td>
<td valign="top">
boolean
</td>
</tr>
<tr>
<td valign="top">
includedefaultreferences
</td>
<td valign="top">
If true, automatically includes the common assemblies in
dotnet, and tells the compiler to link in mscore.dll. set
the automatic reference inclusion flag on or off this flag
controls the /nostdlib option in CSC
</td>
<td valign="top">
boolean
</td>
</tr>
<tr>
<td valign="top">
incremental
</td>
<td valign="top">
set the incremental compilation flag on or off. If set to
true this will result in adding /incremental+ to the csc
command line which is not supported anymore in .NET 3.5.
</td>
<td valign="top">
boolean
</td>
</tr>
<tr>
<td valign="top">
mainclass
</td>
<td valign="top">
Sets the name of main class for executables.
</td>
<td valign="top">
String
</td>
</tr>
<tr>
<td valign="top">
noconfig
</td>
<td valign="top">
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
</td>
<td valign="top">
boolean
</td>
</tr>
<tr>
<td valign="top">
optimize
</td>
<td valign="top">
If true, enables optimization flag.
</td>
<td valign="top">
boolean
</td>
</tr>
<tr>
<td valign="top">
outputfile
</td>
<td valign="top">
The output file. This is identical to the destFile
attribute.
</td>
<td valign="top">
File
</td>
</tr>
<tr>
<td valign="top">
referencefiles
</td>
<td valign="top">
Path of references to include. Wildcards should work.
</td>
<td valign="top">
Path
</td>
</tr>
<tr>
<td valign="top">
references
</td>
<td valign="top">
Semicolon separated list of DLLs to refer to.
</td>
<td valign="top">
String
</td>
</tr>
<tr>
<td valign="top">
srcdir
</td>
<td valign="top">
Set the source directory of the files to be compiled.
</td>
<td valign="top">
File
</td>
</tr>
<tr>
<td valign="top">
targettype
</td>
<td valign="top">
set the target type to one of exe|library|module|winexe
</td>
<td valign="top">
"exe", "library", "module", "winexe"
</td>
</tr>
<tr>
<td valign="top">
unsafe
</td>
<td valign="top">
If true, enables the unsafe keyword.
</td>
<td valign="top">
boolean
</td>
</tr>
<tr>
<td valign="top">
utf8output
</td>
<td valign="top">
If true, require all compiler output to be in UTF8 format.
</td>
<td valign="top">
boolean
</td>
</tr>
<tr>
<td valign="top">
warnlevel
</td>
<td valign="top">
Level of warning currently between 1 and 4 with 4 being the
strictest.
</td>
<td valign="top">
int
</td>
</tr>
<tr>
<td valign="top">
win32icon
</td>
<td valign="top">
Set the filename of icon to include.
</td>
<td valign="top">
File
</td>
</tr>
<tr>
<td valign="top">
win32res
</td>
<td valign="top">
Sets the filename of a win32 resource (.RES) file to
include. This is not a .NET resource, but what Windows is
used to.
</td>
<td valign="top">
File
</td>
</tr>
<tr>
<td valign="top">
useresponsefile
</td>
<td valign="top">
Sets whether a response file instead of a command line only
invocation should be used. Defaults to false but Ant will
still use a response file if more than 64 command line
arguments would be used.
</td>
<td valign="top">
boolean
</td>
</tr>
</table>
<h3><a name="elements">Parameters as nested elements</a></h3>
<h4>define (org.apache.ant.dotnet.compile.DotnetDefine)</h4>
<p>add a define to the list of definitions</p>
<h4>reference (org.apache.tools.ant.types.FileSet)</h4>
<p>add a new reference fileset to the compilation</p>
<h4>resource (org.apache.ant.dotnet.compile.DotnetResource)</h4>
<p>link or embed a resource</p>
<h4>src (org.apache.tools.ant.types.FileSet)</h4>
<p>add a new source directory to the compile</p>
<h3>Examples</h3>
<pre>
&lt;csc optimize=&quot;true&quot; debug=&quot;false&quot;
docFile=&quot;documentation.xml&quot; warnLevel=&quot;4&quot;
unsafe=&quot;false&quot; targetType=&quot;exe&quot;
incremental=&quot;false&quot; mainClass = &quot;MainApp&quot;
destFile=&quot;NetApp.exe&quot; &gt;
&lt;src dir="src" includes="*.cs"/&gt;
&lt;reference file="${testCSC.dll}"/&gt;
&lt;define name="RELEASE"/&gt;
&lt;define name="DEBUG" if="debug.property"/&gt;
&lt;define name="def3" unless="def3.property"/&gt;
&lt;/csc&gt;
</pre>
<p class="copyright">
Apache Ant, Apache .NET Ant Library, Ant, .NET Ant Library, Apache, the Apache feather logo, and the Apache Ant project logos are trademarks of The Apache Software Foundation.
</p>
</body>
</html>