You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

dotnet.html 9.9 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <html>
  2. <head>
  3. <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
  4. <title>.NET Tasks</title>
  5. </head>
  6. <h1>.NET tasks</h1>
  7. <h2>Introduction</h2>
  8. <p><strong>These tasks are deprecated and will be removed in a future
  9. release of Ant. They are now part of the <a
  10. href="http://ant.apache.org/antlibs/dotnet/index.html">.NET
  11. Antlib</a>.</strong></p>
  12. Ant support for .NET goes back to before .NET was released, and
  13. continues to be expanded based on user demand. Users writing nothing but
  14. a .NET application, may want to look at the .NET-based
  15. <A href="http://nant.sourceforge.net/">NAnt</A> project, that supports
  16. both the Microsoft and the Ximian managed <A
  17. href="http://go-mono.com/">Mono</A> project's implementation of the
  18. .NET framework.
  19. <p>
  20. Over time, the .NET tasks in Ant have tended to evolve to meet a few
  21. limited needs. Firstly, developers working with complex deployment problems may
  22. want to use ant to use the fairly advanced deployment tasks Ant ships
  23. with. Secondly, anyone who has a cross-platform project can use these
  24. tasks to cover the .NET side of the problem. Here, cross-platform can
  25. mean more than just Java and .NET: the C++ tasks in the ant-contrib
  26. project on sourceforge can be used with Ant to do native C++ and .NET
  27. cross development if that is your need. Finally, Ant support for .NET
  28. lets one automate .NET development under an automated build process,
  29. such as AntHill or Cruise Control.
  30. <p>
  31. What this means is that the Ant tasks for .NET support do not get as
  32. much rigorous use as the Java tools, and are evolving more slowly -that
  33. includes the time for support calls to change. But as a consequence,
  34. developers working on .NET support have more freedom to play around with
  35. the code. It also means that the fairly unusual set of tasks supported
  36. by ant enable a few interesting operations that can not be performed any
  37. other way:
  38. <ol>
  39. <li>Integrating with a Java based SOAP Service -generating C# code from
  40. the server's WSDL and running it against the server.
  41. </li>
  42. <li>Building and deploying a C#-based Web Service, then using the Apache
  43. Axis tasks to create JUnit tests to call the endpoints.
  44. <li>Patching .NET type libraries to work with more complex IDL than the
  45. basic <code>&lt;importtypelib&gt;</code> wrapper around tlbimport supports. Hence the
  46. disassembler and the reassembler.
  47. </li>
  48. </ol>
  49. Needless to say, possible does not mean easy.
  50. <A href="http://www.manning.com/hatcher/chap15.pdf">Chapter 15</A> of
  51. Java Development with Ant covers the first of these, using the Ant1.5
  52. version of the tasks. Going the other way -generating Java client
  53. code and JUnit testcases is covered in
  54. <A href="http://www.iseran.com/Steve/papers/interop/">The Wondrous curse
  55. of Interop</A>. The final trick, IDL and Typelib abuse, is not
  56. documented as we do not want to encourage such an ugly practise. It,
  57. can, however, be done if absolutely necessary.
  58. <h3>Task List</h3>
  59. <table border="0" >
  60. <tr>
  61. <td><b>Task</b></td>
  62. <td><b>Description</b></td>
  63. </tr>
  64. <tr>
  65. <td><a href="csc.html">csc</a></td>
  66. <td>Compiles C# code</td>
  67. </tr>
  68. <tr>
  69. <td><a href="vbc.html">vbc</a></td>
  70. <td>Compiles VB.NET code</td>
  71. </tr>
  72. <tr>
  73. <td><a href="jsharpc.html">jsharpc</a></td>
  74. <td>Compiles J# files</td>
  75. </tr>
  76. <tr>
  77. <td><a href="ildasm.html">ildasm</a></td>
  78. <td>Disassembles .NET executables and libraries</td>
  79. </tr>
  80. <tr>
  81. <td><a href="ilasm.html">ilasm</a></td>
  82. <td>Assembles .il files</td>
  83. </tr>
  84. <tr>
  85. <td><a href="wsdltodotnet.html">wsdltodotnet</a></td>
  86. <td>Generates .NET code (C# or VB) from a WSDL file</td>
  87. </tr>
  88. <tr>
  89. <td><a href="importtypelib.html">importtypelib</a></td>
  90. <td>Imports a COM type library into .NET</td>
  91. </tr>
  92. </table>
  93. <hr>
  94. <h3>Common .NET Datatypes </h3>
  95. There are some datatypes that are common to the core compiler classes:
  96. csc, vbc and jsharpc
  97. <h4>Resource</h4>
  98. This is a resource that is included in the build. Ant uses this for
  99. dependency checking -if resources included this way have changed, the
  100. executable or library will be rebuilt.
  101. <p>
  102. <table border="1" cellpadding="2" cellspacing="0">
  103. <tr>
  104. <td valign="top"><b>Attribute</b></td>
  105. <td valign="top"><b>Description</b></td>
  106. <td align="center" valign="top"><b>Required</b></td>
  107. </tr>
  108. <tr>
  109. <td valign="top">File</td>
  110. <td valign="top">the resource to include</td>
  111. <td align="center" valign="top">Yes</td>
  112. </tr>
  113. <tr>
  114. <td valign="top">name</td>
  115. <td valign="top">the name of the resource.
  116. Optional unless the resource is
  117. marked as public or private</td>
  118. <td align="center" valign="top">No</td>
  119. </tr>
  120. <tr>
  121. <td valign="top">embed</td>
  122. <td valign="top">flag to control whether the resource
  123. is embedded in the assembly, or just linked to it</td>
  124. <td align="center" valign="top">No -default is true</td>
  125. </tr>
  126. <tr>
  127. <td valign="top">public</td>
  128. <td valign="top">VB only: flag to control if a resource should be
  129. public or private. Set to true for public, false for private
  130. and leave undefined for for neither. </td>
  131. <td align="center" valign="top">No</td>
  132. </tr>
  133. </table>
  134. <h5>Examples</h5>
  135. <pre>
  136. &lt;resource file="app.ico" name="icon"/&gt;
  137. &lt;resource file="splash.jpg"/&gt;
  138. &lt;resource name="splash" file="splash.jpg" public="false"/&gt;
  139. </pre>
  140. <h4>Define</h4>
  141. This is a definition; in .NET these can either be defined or undefined,
  142. unlike C++ #defines, which can be either undefined or arbitrary text.
  143. The Ant compilation tasks can unconditionally add definitions, or
  144. conditionally set a compile-time definition if an ant property is
  145. defined or not.
  146. <p>
  147. Dependency Logic: the tasks are not (yet) clever enough to remember what
  148. the last definitions were and trigger a rebuild when they change. Clean
  149. build the code when the defines are likely to be different.
  150. <p>
  151. <table border="1" cellpadding="2" cellspacing="0">
  152. <tr>
  153. <td valign="top"><b>Attribute</b></td>
  154. <td valign="top"><b>Description</b></td>
  155. <td align="center" valign="top"><b>Required</b></td>
  156. </tr>
  157. <tr>
  158. <td valign="top">name</td>
  159. <td valign="top">the name of the definition</td>
  160. <td align="center" valign="top">Yes</td>
  161. </tr>
  162. <tr>
  163. <td valign="top">if</td>
  164. <td valign="top">name of a ant property to test for;
  165. the definition is only set if this property is defined.</td>
  166. <td align="center" valign="top">No</td>
  167. </tr>
  168. <tr>
  169. <td valign="top">unless</td>
  170. <td valign="top">name of a ant property to test for;
  171. the definition is only set if this property is undefined.</td>
  172. <td align="center" valign="top">No</td>
  173. </tr>
  174. </table>
  175. <h5>Examples</h5>
  176. <pre>
  177. &lt;define name="unsafe"/&gt;
  178. &lt;define name="debug" if="build.debug"/&gt;
  179. &lt;define name="dotnet" unless="build.mono"/&gt;
  180. </pre>
  181. <hr>
  182. <h3> Change Log </h3>
  183. <h4>Ant1.6</h4>
  184. This revision goes along with NET 1.1, though there is no reason why
  185. it should not work on other versions.
  186. <p>
  187. <ol>
  188. <li>vbc task</li>
  189. <li>jsharpc task</li>
  190. <li>mono support</li>
  191. <li>ilasm</li>
  192. <li>tlbimport</li>
  193. <li>Reference filesets in the compiler tasks</li>
  194. <li>definitions in the compiler tasks</li>
  195. <li>multiple source filesets in the compiler tasks. If these are used, the
  196. implicit fileset is disabled</li>
  197. </ol>
  198. The compile tasks: vbc, jsharpc, and csc, all contain lots of common code
  199. in a shared base class: if you can use one you should be able to use
  200. another.
  201. <h4>Ant 1.5</h4>
  202. This revision goes along with NET 1.0 (SP1)
  203. <ol>
  204. <li>CSC: added filealign</li>
  205. <li>CSC: added reference to office.dll</li>
  206. <li>CSC: dependency checking! only if destFile is set!
  207. <li>WsdlToDotnet written
  208. </ol>
  209. <h4>Version 0.5</h4>
  210. This revision goes along with NET 1.0 (SP1)
  211. <ol>
  212. <li>CSC: added filealign</li>
  213. <li>CSC: added reference to office.dll</li>
  214. <li>CSC: dependency checking! only if destFile is set!
  215. <li>WsdlToDotnet written
  216. </ol>
  217. <h4>Version 0.4</h4>
  218. This is the beta-2 revision of the tasks.
  219. <ol>
  220. <li>ILASM: pulled the owner attribute, added keyfile for giving binaries a strong name
  221. (MD5 hash of the checksum)</li>
  222. <li>CSC: added win32res , noConfig, utf8output, fullpaths</li>
  223. <li>CSC: </li>
  224. </ol>
  225. <h4>Version 0.3</h4>
  226. The changes here reflect Beta-1 of the dotnet SDK and experience of use in
  227. more complex projects. This build does not work with the older SDK,
  228. primarily because the automatic reference feature references libraries
  229. only found in the new SDK version.
  230. <p>
  231. External changes</p>
  232. <ul>
  233. <li>Recursive inclusion of .cs and .il files</li>
  234. <li>Documentation enhanced, includes examples and details of all parameters</li>
  235. <li>The csc task automatically includes the common dotnet assemblies, so
  236. there is no need to remember to refer to 'System.dll', 'System.Web.Services',
  237. etc. This feature can be disabled by setting the 'includeDefaultReferences'
  238. flag to false. </li>
  239. <li> References can also be referred to using the ReferenceFiles parameter, which
  240. is an ant path specification. The old 'references' string is still retained.</li>
  241. <li> An 'extraoptions' attribute enables the build file to include any CSC options
  242. which are not explicitly supported in the CSC task. </li>
  243. </ul>
  244. Internal changes
  245. <ul>
  246. <li>Some minor refactoring (move common code a method)</li>
  247. <li>Application of Jedits JavaStyle task resulted in a major reshaping of
  248. the codebase and the insertion of a blank line every second line. Significant
  249. effort was required to revert some (but not all) changes.</li>
  250. <li>Removed throws clause from methods which can't throw exception
  251. </ul>
  252. The test harness has been expanded to include unicode source file
  253. (the build works but the rest of the system has 'issues' with high unicode
  254. package and method names)
  255. <h4>Version 0.2</h4>
  256. First public edition, added to the ant cvs tree. Tested on the PDC build of
  257. the dotnet SDK only, and still immature. The command execution code was
  258. refactored out into a 'NetCommand' class for re-use. The Ilasm task was added
  259. at this time.
  260. <h4>Version 0.1</h4>
  261. Initial proof of concept; very rudimentary support for CSC only.
  262. <p align="center">Copyright &copy; 2000-2005 The Apache Software Foundation. All rights
  263. Reserved.</p>
  264. </body>
  265. </html>