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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  1. <html>
  2. <head>
  3. <title>.NET Tasks</title>
  4. </head>
  5. <body bgcolor="#ffffff">
  6. <h1>.NET classes for Ant</h1>
  7. <h2>Vision</h2>
  8. <p>
  9. Make ant the definitive build tool for .NET projects, just
  10. as it is becoming for java projects
  11. </p>
  12. <h2>Detail</h2>
  13. <p>
  14. The emergent policy in big java projects is 'IDE for code and debug';
  15. Ant for builds, test and deployment. While IDEs are great for an
  16. individual development task, Ant not only rebuilds everything insanely
  17. fast, it has great support for modern deployment tasks -ftp upload,
  18. EJB servers, SQL commands, all can be done from a relatively simple
  19. XML declaration of what you want done. Also in a large project
  20. (especially open source) there is no means of dictating which IDE to use.
  21. Ant gives IDE independence, cross platform portability and ease of
  22. extensibility. </p>
  23. <p>
  24. Projects using .net should be able to use the same tool. This will
  25. avoid everyone being dependent on Visual Studio.net (if they have it)
  26. supplemented with makefiles and batch files. Anyone doing mixed java/dotnet
  27. development will be particulary grateful, as they can have a unified build
  28. process. </p>
  29. <p>
  30. If at sometime in the future bits of .net do appear on different platforms
  31. then ant based build files will migrate -once the ant tasks have been
  32. migrated and any hard codings of DOS-descendant file system conventions
  33. removed from the build.xml files.</p>
  34. <h2>Key .net Tasks</h2>
  35. <ol>
  36. <li>csc - csharp compiler - *.csc -&gt; output</li>
  37. <li>ilasm - IL assembler - *.il -&gt;.exe or .dll</li>
  38. <li>ResX - ResXToResources.exe .resx -&gt; .resources</li>
  39. <li>al - assembly linker (.dll) -&gt;</li>
  40. <li>Signcode - .exe + keys -&gt; .exe</li>
  41. <li>Resgen - .properties -&gt; .resources</li>
  42. <li>Type Library Exporter (TlbExp.exe) .dll -&gt; .tlb</li>
  43. <li>TlbImp.exe Type Library Importer </li>
  44. <li>RegAsm.exe Assembly Registration Tool .dll -&gt; .reg | registration</li>
  45. </ol>
  46. <h2>Ant Wrapper for net tasks</h2>
  47. Rarely used .net command line tools can be invoked manually. The key tasks
  48. to address are the common steps in a build process and those which benefit
  49. from the file pattern matching function.
  50. <p>
  51. The esoteric tasks can then supported on demand by those who need them.
  52. The initial .net tasks should provide a foundation for that demand creation
  53. to be simple. </p>
  54. <h2>Plan</h2>
  55. <ol>
  56. <li>code up C sharp task and distribute for feedback &amp; identify possible
  57. aid</li>
  58. <li>Use for a real end to end development task</li>
  59. <li>Add the next task I need (whatever that is)</li>
  60. <li>Refactor to produce a base class for .net tasks</li>
  61. <li>Leave it other people write all the other tasks</li>
  62. </ol>
  63. <h2>Risks</h2>
  64. <ul>
  65. <li>
  66. The .net SDK is unstable; the next builds will change the commands, arguments
  67. and behaviours. Probability: 100%. Impact: 2 days.</li>
  68. <li>Portable tasks turn out to be harder than envisaged
  69. (=reworking if/when non Win32 .net build tools appear)</li>
  70. </ul>
  71. <hr>
  72. <h2>Using Ant in .net projects</h2>
  73. To use the net tasks one needs
  74. <ul>
  75. <li> A Windows box (or any other platform which supports the .net build tools)</li>
  76. <li> JavaVM - Java1.1 or later; Java1.3 recommended.</li>
  77. <li> Ant downloaded and the environment and path variables set up so
  78. that typing 'ant' invokes ant via a batch file.</li>
  79. <li> An XML parser for ant. The usual distributions include an appropriate
  80. version crimson.jar and jaxp.jar.</li>
  81. <li> the .net tasks archive (dotnettasks.jar) included in the
  82. ant\lib directory</li>
  83. <li> The .net sdk installed with the binaries on the path. (Test: type CSC)</li>
  84. <li> A build.xml file to describe the build process</li>
  85. </ul>
  86. <hr>
  87. <h2> Change Log </h2>
  88. <h4>Version 0.4</h4>
  89. This is the beta-2 revision of the tasks.
  90. <ol>
  91. <li>ILASM: pulled the owner attribute, added keyfile for giving binaries a strong name
  92. (MD5 hash of the checksum)</li>
  93. <li>CSC: added win32res , noConfig, utf8output, fullpaths</li>
  94. <li>CSC: </li>
  95. </ol>
  96. <h4>Version 0.3</h4>
  97. The changes here reflect Beta-1 of the dotnet SDK and experience of use in
  98. more complex projects. This build does not work with the older SDK,
  99. primarily because the automatic reference feature references libraries
  100. only found in the new SDK version.
  101. <p>
  102. External changes</p>
  103. <ul>
  104. <li>Recursive inclusion of .cs and .il files</li>
  105. <li>Documentation enhanced, includes examples and details of all parameters</li>
  106. <li>The csc task automatically includes the common dotnet assemblies, so
  107. there is no need to remember to refer to 'System.dll', 'System.Web.Services',
  108. etc. This feature can be disabled by setting the 'includeDefaultReferences'
  109. flag to false. </li>
  110. <li> References can also be referred to using the ReferenceFiles parameter, which
  111. is an ant path specification. The old 'references' string is still retained.</li>
  112. <li> An 'extraoptions' attribute enables the build file to include any CSC options
  113. which are not explicitly supported in the CSC task. </li>
  114. </ul>
  115. Internal changes
  116. <ul>
  117. <li>Some minor refactoring (move common code a method)</li>
  118. <li>Application of Jedits JavaStyle task resulted in a major reshaping of
  119. the codebase and the insertion of a blank line every second line. Significant
  120. effort was required to revert some (but not all) changes.</li>
  121. <li>Removed throws clause from methods which can't throw exceptions </li>
  122. </ul>
  123. The test harness has been expanded to include unicode source file
  124. (the build works but the rest of the system has 'issues' with high unicode
  125. package and method names)
  126. <h4>Version 0.2</h4>
  127. First public edition, added to the ant cvs tree. Tested on the PDC build of
  128. the dotnet SDK only, and still immature. The command execution code was
  129. refactored out into a 'NetCommand' class for re-use. The Ilasm task was added
  130. at this time.
  131. <h4>Version 0.1</h4>
  132. Initial proof of concept; very rudimentary support for CSC only.
  133. <hr>
  134. <h2>Task: CSC</h2>
  135. This task compiles CSharp source into executables or modules.
  136. This task compiles CSharp source into executables or modules.
  137. The task will only work on win2K until other platforms support csc.exe or
  138. an equivalent. CSC.exe must be on the execute path too.
  139. <p>
  140. All parameters are optional: &lt;csc/&gt; should suffice to produce a debug
  141. build of all *.cs files. References to external files do require explicit
  142. enumeration, so are one of the first attributes to consider adding. </p>
  143. <p>
  144. The task is a directory based task, so attributes like <b>includes=&quot;**/*.cs&quot;</b> and
  145. <b>excludes=&quot;broken.cs&quot;</b> can be used to control the files pulled in. By default,
  146. all *.cs files from the project folder down are included in the command.
  147. When this happens the output file -if not specified-
  148. is taken as the first file in the list, which may be somewhat hard to control.
  149. Specifying the output file with <b>'outfile'</b> seems prudent. </p>
  150. <table border="1" cellpadding="2" cellspacing="0">
  151. <tr>
  152. <td valign="top"><b>Attribute</b></td>
  153. <td valign="top"><b>Description</b></td>
  154. <td align="center" valign="top"><b>Example Values</b></td>
  155. </tr>
  156. <tr>
  157. <td valign="top">additionalModules</td>
  158. <td valign="top">Semicolon separated list of modules to refer to</td>
  159. </tr>
  160. <tr>
  161. <td valign="top">defaultexcludes</td>
  162. <td valign="top">indicates whether default excludes should be used or not
  163. </td>
  164. <td valign="top">&quot;true&quot;(default) or &quot;false&quot;</td>
  165. </tr>
  166. <tr>
  167. <td valign="top">definitions</td>
  168. <td valign="top">defined constants</td>
  169. <td valign="top"> &quot;RELEASE;BETA1&quot;</td>
  170. </tr>
  171. <tr>
  172. <td valign="top">debug</td>
  173. <td valign="top">include debug information</td>
  174. <td valign="top">&quot;true&quot;(default) or &quot;false&quot;</td>
  175. </tr>
  176. <tr>
  177. <td valign="top">docFile</td>
  178. <td valign="top">name of file for documentation</td>
  179. <td valign="top">&quot;doc.xml&quot;</td>
  180. </tr>
  181. <tr>
  182. <td valign="top">excludes</td>
  183. <td valign="top">comma separated list of patterns of files that must be
  184. excluded. No files (except default excludes) are excluded when omitted.</td>
  185. </tr>
  186. <tr>
  187. <td valign="top">excludesfile</td>
  188. <td valign="top">the name of a file. Each line of this file is
  189. taken to be an exclude pattern</td>
  190. </tr>
  191. <tr>
  192. <td valign="top">extraOptions</td>
  193. <td valign="top">Any extra options which aren't explicitly
  194. supported by the CSharp task </td>
  195. <td>&quot;/warnaserror+ /baseaddress:0x12840000&quot;</td>
  196. </tr>
  197. <tr>
  198. <td valign="top">failOnError</td>
  199. <td valign="top">Should a failed compile halt the build?</td>
  200. <td valign="top">&quot;true&quot;(default) or &quot;false&quot;</td>
  201. </tr>
  202. <tr>
  203. <td valign="top">fullpaths</td>
  204. <td valign="top">print the full path of files on on errors</td>
  205. </tr>
  206. <tr>
  207. <td valign="top">includes</td>
  208. <td valign="top">comma separated list of patterns of files that must be
  209. included. All files are included when omitted.</td>
  210. </tr>
  211. <tr>
  212. <td valign="top">includeDefaultReferences</td>
  213. <td valign="top">Flag which when true automatically includes
  214. the common assemblies in dotnet beta1, and tells the compiler to link in
  215. mscore.dll
  216. </td>
  217. <td valign="top">&quot;true&quot;(default) or &quot;false&quot;</td>
  218. </tr>
  219. <tr>
  220. <td valign="top">includesfile</td>
  221. <td valign="top">the name of a file. Each line of this file is
  222. taken to be an include pattern</td>
  223. </tr>
  224. <tr>
  225. <td valign="top">incremental</td>
  226. <td valign="top">Incremental build flag. Avoid till it works</td>
  227. <td valign="top">&quot;true&quot; or &quot;false&quot;(default)</td>
  228. </tr>
  229. <tr>
  230. <td valign="top">mainClass</td>
  231. <td valign="top">name of main class for executables</td>
  232. <td valign="top">&quot;com.example.project.entrypoint&quot;</td>
  233. </tr>
  234. <tr>
  235. <td valign="top">noConfig</td>
  236. <td valign="top">a flag which tells the compiler not
  237. to read in the compiler settings files 'csc.rsp' in its
  238. bin directory and then the local directory</td>
  239. <td valign="top">&quot;true&quot; or &quot;false&quot;(default)</td>
  240. </tr>
  241. <tr>
  242. <td valign="top">optimize</td>
  243. <td valign="top">optimisation flag</td>
  244. <td valign="top">&quot;true&quot; or &quot;false&quot;(default)</td>
  245. </tr>
  246. <tr>
  247. <td valign="top">outputFile</td>
  248. <td valign="top">filename of output</td>
  249. <td valign="top">&quot;example.exe&quot;</td>
  250. </tr>
  251. <tr>
  252. <td valign="top">references</td>
  253. <td valign="top">Semicolon separated list of dlls to refer to</td>
  254. <td valign="top">&quot;mylib.dll;nunit.dll&quot;</td>
  255. </tr>
  256. <tr>
  257. <td valign="top">referenceFiles </td>
  258. <td valign="top">Ant Path descriptioon of references to include.
  259. Wildcards should work. </td>
  260. <td valign="top"></td>
  261. </tr>
  262. <tr>
  263. <td valign="top">srcDir</td>
  264. <td valign="top">source directory (default = project directory)</td>
  265. <td valign="top">&quot;.&quot;</td>
  266. </tr>
  267. <tr>
  268. <td valign="top">targetType</td>
  269. <td valign="top">Type of target</td>
  270. <td valign="top">&quot;exe&quot;, &quot;module&quot;, &quot;winexe&quot; or &quot;library&quot;</td>
  271. </tr>
  272. <tr>
  273. <td valign="top">unsafe</td>
  274. <td valign="top">enable the <b>unsafe</b> keyword</td>
  275. <td valign="top">&quot;true&quot; or &quot;false&quot;(default)</td>
  276. </tr>
  277. <tr>
  278. <td valign="top">utf8output</td>
  279. <td valign="top">require all compiler output to be in utf-8 format</td>
  280. <td valign="top">&quot;true&quot; or &quot;false&quot;(default)</td>
  281. </tr>
  282. <tr>
  283. <td valign="top">warnLevel</td>
  284. <td valign="top">level of warning currently between 1 and 4 with 4
  285. being the strictest. </td>
  286. <td valign="top">&quot;1&quot;-&quot;4&quot;</td>
  287. </tr>
  288. <tr>
  289. <td valign="top">win32Icon</td>
  290. <td valign="top">filename of icon to include</td>
  291. <td valign="top">&quot;res/myicon.ico&quot;</td>
  292. </tr>
  293. <tr>
  294. <td valign="top">win32res</td>
  295. <td valign="top">filename of a win32 resource (.RES)file to include
  296. This is not a .NET resource, but it what windows is used to.</td>
  297. <td valign="top">&quot;res/myapp.res&quot;</td>
  298. </tr>
  299. </table>
  300. <p>
  301. Example
  302. </p>
  303. <pre>&lt;csc
  304. optimize=&quot;true&quot;
  305. debug=&quot;false&quot;
  306. docFile=&quot;documentation.xml&quot;
  307. warnLevel=&quot;4&quot;
  308. unsafe=&quot;false&quot;
  309. targetType=&quot;exe&quot;
  310. incremental=&quot;false&quot;
  311. definitions=&quot;RELEASE&quot;
  312. excludes=&quot;src/unicode_class.cs&quot;
  313. mainClass = &quot;MainApp&quot;
  314. outputFile=&quot;NetApp.exe&quot;
  315. /&gt;
  316. </pre>
  317. <hr>
  318. <h2> Task: ilasm </h2>
  319. <p>Task to assemble .net 'Intermediate Language' files.
  320. The task will only work on windows until other platforms support csc.exe or
  321. an equivalent. ilasm.exe must be on the execute path too.
  322. </p>
  323. <p>
  324. All parameters are optional: &lt;il/&gt; should suffice to produce a debug
  325. build of all *.il files.
  326. The option set is roughly compatible with the CSharp class;
  327. even though the command line options are only vaguely
  328. equivalent. [The low level commands take things like /OUT=file,
  329. csc wants /out:file ... /verbose is used some places; /quiet here in
  330. ildasm... etc.] It would be nice if someone made all the command line
  331. tools consistent (and not as brittle as the java cmdline tools)
  332. </p>
  333. <p>
  334. The task is a directory based task, so attributes like <b>includes=&quot;*.il&quot;</b> and
  335. <b>excludes=&quot;broken.il&quot;</b> can be used to control the files pulled in.
  336. Each file is built on its own, producing an appropriately named output file unless
  337. manually specified with <b>outfile</b>
  338. </p>
  339. <table border="1" cellpadding="2" cellspacing="0">
  340. <tr>
  341. <td valign="top"><b>Attribute</b></td>
  342. <td valign="top"><b>Description</b></td>
  343. <td align="center" valign="top"><b>Example</b></td>
  344. </tr>
  345. <tr>
  346. <td valign="top">defaultexcludes</td>
  347. <td valign="top">indicates whether default excludes should be used or not
  348. (&quot;yes&quot;/&quot;no&quot;). Default excludes are used when omitted.</td>
  349. </tr>
  350. <tr>
  351. <td valign="top">debug</td>
  352. <td valign="top">include debug information</td>
  353. <td valign="top">true (default)</td>
  354. </tr>
  355. <tr>
  356. <td valign="top">excludes</td>
  357. <td valign="top">comma separated list of patterns of files that must be
  358. excluded. No files (except default excludes) are excluded when omitted.</td>
  359. </tr>
  360. <tr>
  361. <td valign="top">excludesfile</td>
  362. <td valign="top">the name of a file. Each line of this file is
  363. taken to be an exclude pattern</td>
  364. </tr>
  365. <tr>
  366. <td valign="top">extraOptions</td>
  367. <td valign="top">Any extra options which aren't explicitly
  368. supported by the ilasm task, primarily because they
  369. arent really documented: use ilasm /? to see them</td>
  370. <td></td>
  371. </tr>
  372. <tr>
  373. <td valign="top">failOnError</td>
  374. <td valign="top">Should a failed compile halt the build?</td>
  375. <td valign="top">&quot;true&quot;(default)</td>
  376. </tr>
  377. <tr>
  378. <td valign="top">fullpaths</td>
  379. <td valign="top">Should error text provide the full path to files</td>
  380. <td valign="top">&quot;true&quot;(default)</td>
  381. </tr>
  382. <tr>
  383. <td valign="top">includes</td>
  384. <td valign="top">comma separated list of patterns of files that must be
  385. included. All files are included when omitted.</td>
  386. </tr>
  387. <tr>
  388. <td valign="top">includesfile</td>
  389. <td valign="top">the name of a file. Each line of this file is
  390. taken to be an include pattern</td>
  391. </tr>
  392. <tr>
  393. <td valign="top">keyfile</td>
  394. <td valign="top">the name of a file containing a private key, with which
  395. the assembly output is checksumed and then MD5 signed
  396. to have a <i>strong name</i></td>
  397. </tr>
  398. <tr>
  399. <td valign="top">listing</td>
  400. <td valign="top">Produce a listing (off by default). Listings go to the
  401. current output stream</td>
  402. <td valign="top">&quot;on&quot;, &quot;off&quot; (default)</td>
  403. </tr>
  404. <tr>
  405. <td valign="top">outputFile</td>
  406. <td valign="top">filename of output</td>
  407. <td valign="top">&quot;example.exe&quot;</td>
  408. </tr>
  409. <tr>
  410. <td valign="top">resourceFile</td>
  411. <td valign="top">name of resource file to include</td>
  412. <td valign="top">&quot;resources.res&quot;</td>
  413. </tr>
  414. <tr>
  415. <td valign="top">srcDir</td>
  416. <td valign="top">source directory (default = project directory)</td>
  417. <td valign="top"></td>
  418. </tr>
  419. <tr>
  420. <td valign="top">targetType</td>
  421. <td valign="top">Type of target. library means DLL is output. </td>
  422. <td valign="top">&quot;exe&quot;(default), &quot;library&quot;</td>
  423. </tr>
  424. <tr>
  425. <td valign="top">verbose</td>
  426. <td valign="top">output progress messages</td>
  427. <td valign="top">&quot;on&quot;, &quot;off&quot; (default)</td>
  428. </tr>
  429. </table>
  430. <p>
  431. Example</p>
  432. <pre>&lt;ilasm
  433. outputFile=&quot;app.exe&quot;
  434. verbose=&quot;on&quot;
  435. listing=&quot;on&quot;
  436. owner=&quot;secret&quot;
  437. /&gt;
  438. </pre>
  439. <hr>
  440. <p align="center">Copyright &copy; 2000 Apache Software Foundation. All rights
  441. Reserved.</p>
  442. </body>
  443. </html>