- 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 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 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.
- 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.
-
These tasks are deprecated and will be removed in a future
-release of Ant. They are now part of the .NET
-Antlib.
-
-Ant support for .NET goes back to before .NET was released, and
-continues to be expanded based on user demand. Users writing nothing but
-a .NET application, may want to look at the .NET-based
-NAnt project, that supports
-both the Microsoft and the Ximian managed Mono project's implementation of the
-.NET framework.
-
-
-Over time, the .NET tasks in Ant have tended to evolve to meet a few
-limited needs. Firstly, developers working with complex deployment problems may
-want to use ant to use the fairly advanced deployment tasks Ant ships
-with. Secondly, anyone who has a cross-platform project can use these
-tasks to cover the .NET side of the problem. Here, cross-platform can
-mean more than just Java and .NET: the C++ tasks in the ant-contrib
-project on sourceforge can be used with Ant to do native C++ and .NET
-cross development if that is your need. Finally, Ant support for .NET
-lets one automate .NET development under an automated build process,
-such as AntHill or Cruise Control.
-
-
-
-What this means is that the Ant tasks for .NET support do not get as
-much rigorous use as the Java tools, and are evolving more slowly -that
-includes the time for support calls to change. But as a consequence,
-developers working on .NET support have more freedom to play around with
-the code. It also means that the fairly unusual set of tasks supported
-by ant enable a few interesting operations that can not be performed any
-other way:
-
-
-
Integrating with a Java based SOAP Service -generating C# code from
-the server's WSDL and running it against the server.
-
-
Building and deploying a C#-based Web Service, then using the Apache
-Axis tasks to create JUnit tests to call the endpoints.
-
-
Patching .NET type libraries to work with more complex IDL than the
-basic <importtypelib> wrapper around tlbimport supports. Hence the
-disassembler and the reassembler.
-
-
-
-Needless to say, possible does not mean easy.
-Chapter 15 of
-Java Development with Ant covers the first of these, using the Ant1.5
-version of the tasks. Going the other way -generating Java client
-code and JUnit testcases is covered in
-The Wondrous curse
-of Interop. The final trick, IDL and Typelib abuse, is not
-documented as we do not want to encourage such an ugly practise. It,
-can, however, be done if absolutely necessary.
-
-
-
-There are some datatypes that are common to the core compiler classes:
-csc, vbc and jsharpc
-
-
Resource
-
-This is a resource that is included in the build. Ant uses this for
-dependency checking -if resources included this way have changed, the
-executable or library will be rebuilt.
-
-
-
-
Attribute
-
Description
-
Required
-
-
-
File
-
the resource to include
-
Yes
-
-
-
name
-
the name of the resource.
- Optional unless the resource is
- marked as public or private
-
No
-
-
-
embed
-
flag to control whether the resource
- is embedded in the assembly, or just linked to it
-
No -default is true
-
-
-
public
-
VB only: flag to control if a resource should be
- public or private. Set to true for public, false for private
- and leave undefined for for neither.
-
-This is a definition; in .NET these can either be defined or undefined,
-unlike C++ #defines, which can be either undefined or arbitrary text.
-The Ant compilation tasks can unconditionally add definitions, or
-conditionally set a compile-time definition if an ant property is
-defined or not.
-
-
-Dependency Logic: the tasks are not (yet) clever enough to remember what
-the last definitions were and trigger a rebuild when they change. Clean
-build the code when the defines are likely to be different.
-
-
-
-
Attribute
-
Description
-
Required
-
-
-
name
-
the name of the definition
-
Yes
-
-
-
if
-
name of a ant property to test for;
- the definition is only set if this property is defined.
-
No
-
-
-
unless
-
name of a ant property to test for;
- the definition is only set if this property is undefined.
-This revision goes along with NET 1.1, though there is no reason why
-it should not work on other versions.
-
-
-
-
vbc task
-
jsharpc task
-
mono support
-
ilasm
-
tlbimport
-
Reference filesets in the compiler tasks
-
definitions in the compiler tasks
-
multiple source filesets in the compiler tasks. If these are used, the
-implicit fileset is disabled
-
-
-The compile tasks: vbc, jsharpc, and csc, all contain lots of common code
-in a shared base class: if you can use one you should be able to use
-another.
-
-
Ant 1.5
-This revision goes along with NET 1.0 (SP1)
-
-
CSC: added filealign
-
CSC: added reference to office.dll
-
CSC: dependency checking! only if destFile is set!
-
WsdlToDotnet written
-
-
-
Version 0.5
-This revision goes along with NET 1.0 (SP1)
-
-
CSC: added filealign
-
CSC: added reference to office.dll
-
CSC: dependency checking! only if destFile is set!
-
WsdlToDotnet written
-
-
-
Version 0.4
-This is the beta-2 revision of the tasks.
-
-
ILASM: pulled the owner attribute, added keyfile for giving binaries a strong name
-(MD5 hash of the checksum)
-
-The changes here reflect Beta-1 of the dotnet SDK and experience of use in
-more complex projects. This build does not work with the older SDK,
-primarily because the automatic reference feature references libraries
-only found in the new SDK version.
-
-External changes
-
-
Recursive inclusion of .cs and .il files
-
-
Documentation enhanced, includes examples and details of all parameters
-
-
The csc task automatically includes the common dotnet assemblies, so
-there is no need to remember to refer to 'System.dll', 'System.Web.Services',
- etc. This feature can be disabled by setting the 'includeDefaultReferences'
- flag to false.
-
-
References can also be referred to using the ReferenceFiles parameter, which
-is an ant path specification. The old 'references' string is still retained.
-
An 'extraoptions' attribute enables the build file to include any CSC options
-which are not explicitly supported in the CSC task.
-
-
-Internal changes
-
-
Some minor refactoring (move common code a method)
-
Application of Jedits JavaStyle task resulted in a major reshaping of
-the codebase and the insertion of a blank line every second line. Significant
-effort was required to revert some (but not all) changes.
-
Removed throws clause from methods which can't throw exception
-
-
-The test harness has been expanded to include unicode source file
-(the build works but the rest of the system has 'issues' with high unicode
-package and method names)
-
-
Version 0.2
-First public edition, added to the ant cvs tree. Tested on the PDC build of
-the dotnet SDK only, and still immature. The command execution code was
-refactored out into a 'NetCommand' class for re-use. The Ilasm task was added
-at this time.
-
-
Version 0.1
-Initial proof of concept; very rudimentary support for CSC only.
-
-
-