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

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