source: release-kits/lirk3/resources/gs3-release-maker/ant/docs/manual/OptionalTasks/dotnet.html@ 14982

Last change on this file since 14982 was 14982, checked in by oranfry, 16 years ago

initial import of LiRK3

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