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

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