Csc Task Compiles C# source into executables or modules. |
Description
> 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 `executable` parameter All parameters are optional: `<csc/>` should suffice to produce a debug build of all *.cs files. However, naming an `destFile`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. 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` elements 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>
Parameters
> Attribute | Description | Type | Requirement
> additionalmodules | Semicolon separated list of modules to refer to. | String | Optional
> debug | set the debug flag on or off. | boolean
> definitions | Semicolon separated list of defined constants. | String
> destdir | Set the destination directory of files to be compiled. | File
> destfile | Set the name of exe/library to create. | File
> docfile | file for generated XML documentation | File
> executable | 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 | String
> extraoptions | Any extra options which are not explicitly supported by this task. | String
> failonerror | If true, fail on compilation errors. | boolean
> filealign | Set the file alignment. Valid values are 0,512, 1024, 2048, 4096, 8192, and 16384, 0 means 'leave to the compiler' | int
> fullpaths | If true, print the full path of files on errors. | boolean
> includedefaultreferences | 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 | boolean
> incremental | set the incremental compilation flag on or off. | boolean
> mainclass | Sets the name of main class for executables. | String
> noconfig | 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 | boolean
> optimize | If true, enables optimization flag. | boolean
> outputfile | The output file. This is identical to the destFile attribute. | File
> referencefiles | Path of references to include. Wildcards should work. | Path
> references | Semicolon separated list of DLLs to refer to. | String
> srcdir | Set the source directory of the files to be compiled. | File
> targettype | set the target type to one of exe|library|module|winexe | "exe", "library", "module", "winexe"
> unsafe | If true, enables the unsafe keyword. | boolean
> utf8output | If true, require all compiler output to be in UTF8 format. | boolean
> warnlevel | Level of warning currently between 1 and 4 with 4 being the strictest. | int
> win32icon | Set the filename of icon to include. | File
> win32res | Sets the filename of a win32 resource (.RES) file to include. This is not a .NET resource, but what Windows is used to. | File
Parameters as nested elements
> define (org.apache.tools.ant.taskdefs.optional.dotnet.DotnetDefine)
> add a define to the list of definitions
> reference (org.apache.tools.ant.types.FileSet)
> add a new reference fileset to the compilation
> resource (org.apache.tools.ant.taskdefs.optional.dotnet.DotnetResource)
> link or embed a resource
> src (org.apache.tools.ant.types.FileSet)
> add a new source directory to the compile
Copyright © 2000-2005, The Apache Software Foundation. All Rights Reserved.