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