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.5 KiB

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