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

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