corrade-vassal – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 vero 1 #region BSD License
2 /*
3 Copyright (c) 2004 - 2008
4 Matthew Holmes (matthew@wildfiregames.com),
5 Dan Moorehead (dan05a@gmail.com),
6 C.J. Adams-Collier (cjac@colliertech.org),
7  
8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions are
10 met:
11  
12 * Redistributions of source code must retain the above copyright
13 notice, this list of conditions and the following disclaimer.
14  
15 * Redistributions in binary form must reproduce the above copyright
16 notice, this list of conditions and the following disclaimer in the
17 documentation and/or other materials provided with the distribution.
18  
19 * The name of the author may not be used to endorse or promote
20 products derived from this software without specific prior written
21 permission.
22  
23 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
27 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
32 IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 POSSIBILITY OF SUCH DAMAGE.
34 */
35  
36 #endregion
37  
38 #region CVS Information
39 /*
40 * $Source$
41 * $Author: jhurliman $
42 * $Date: 2008-12-17 14:18:25 -0800 (Wed, 17 Dec 2008) $
43 * $Revision: 285 $
44 */
45 #endregion
46  
47 using System;
48 using System.Collections;
49 using System.Collections.Specialized;
50 using System.IO;
51 using System.Reflection;
52 using System.Text.RegularExpressions;
53  
54 using Prebuild.Core.Attributes;
55 using Prebuild.Core.Interfaces;
56 using Prebuild.Core.Nodes;
57 using Prebuild.Core.Utilities;
58  
59 namespace Prebuild.Core.Targets
60 {
61 /// <summary>
62 ///
63 /// </summary>
64 [Target("nant")]
65 public class NAntTarget : ITarget
66 {
67 #region Fields
68  
69 private Kernel m_Kernel;
70  
71 #endregion
72  
73 #region Private Methods
74  
75 private static string PrependPath(string path)
76 {
77 string tmpPath = Helper.NormalizePath(path, '/');
78 Regex regex = new Regex(@"(\w):/(\w+)");
79 Match match = regex.Match(tmpPath);
80 //if(match.Success || tmpPath[0] == '.' || tmpPath[0] == '/')
81 //{
82 tmpPath = Helper.NormalizePath(tmpPath);
83 //}
84 // else
85 // {
86 // tmpPath = Helper.NormalizePath("./" + tmpPath);
87 // }
88  
89 return tmpPath;
90 }
91  
92 private static string BuildReference(SolutionNode solution, ReferenceNode refr)
93 {
94 string ret = "";
95 if (solution.ProjectsTable.ContainsKey(refr.Name))
96 {
97 ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name];
98 string fileRef = FindFileReference(refr.Name, project);
99 string finalPath = Helper.NormalizePath(Helper.MakeFilePath("${build.dir}/", refr.Name, GetExtension(refr.Name)), '/');
100 ret += finalPath;
101 return ret;
102 }
103 else
104 {
105 ProjectNode project = (ProjectNode)refr.Parent;
106 string fileRef = FindFileReference(refr.Name, project);
107 string ext = GetExtension(refr.Name);
108  
109 if (refr.Path != null || fileRef != null)
110 {
111 string finalPath = (refr.Path != null) ? Helper.NormalizePath(Helper.MakeFilePath("${build.dir}/", refr.Name, ext), '/') : fileRef;
112  
113 ret += finalPath;
114 return ret;
115 }
116  
117 if (refr.Name.EndsWith(".exe") || refr.Name.EndsWith(".dll"))
118 ret += refr.Name;
119 else
120 ret += refr.Name + ".dll";
121 }
122 return ret;
123 }
124  
125 private static string GetExtension(string refrName)
126 {
127 if (refrName.EndsWith(".exe") || refrName.EndsWith(".dll"))
128 return String.Empty;
129 else
130 return "dll";
131 }
132  
133 private static string BuildReferencePath(SolutionNode solution, ReferenceNode refr)
134 {
135 string ret = "";
136 if (solution.ProjectsTable.ContainsKey(refr.Name))
137 {
138 ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name];
139 string fileRef = FindFileReference(refr.Name, project);
140 string finalPath = Helper.NormalizePath(Helper.MakeReferencePath("${build.dir}/"), '/');
141 ret += finalPath;
142 return ret;
143 }
144 else
145 {
146 ProjectNode project = (ProjectNode)refr.Parent;
147 string fileRef = FindFileReference(refr.Name, project);
148  
149 if (refr.Path != null || fileRef != null)
150 {
151 string finalPath = (refr.Path != null) ? Helper.NormalizePath(refr.Path, '/') : fileRef;
152 ret += finalPath;
153 return ret;
154 }
155  
156 try
157 {
158 Assembly assem = Assembly.Load(refr.Name);
159 if (assem != null)
160 {
161 ret += "";
162 }
163 else
164 {
165 ret += "";
166 }
167 }
168 catch (System.NullReferenceException e)
169 {
170 e.ToString();
171 ret += "";
172 }
173 }
174 return ret;
175 }
176  
177 private static string FindFileReference(string refName, ProjectNode project)
178 {
179 foreach (ReferencePathNode refPath in project.ReferencePaths)
180 {
181 string fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll");
182  
183 if (File.Exists(fullPath))
184 {
185 return fullPath;
186 }
187 }
188  
189 return null;
190 }
191  
192 /// <summary>
193 /// Gets the XML doc file.
194 /// </summary>
195 /// <param name="project">The project.</param>
196 /// <param name="conf">The conf.</param>
197 /// <returns></returns>
198 public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf)
199 {
200 if (conf == null)
201 {
202 throw new ArgumentNullException("conf");
203 }
204 if (project == null)
205 {
206 throw new ArgumentNullException("project");
207 }
208 string docFile = (string)conf.Options["XmlDocFile"];
209 // if(docFile != null && docFile.Length == 0)//default to assembly name if not specified
210 // {
211 // return Path.GetFileNameWithoutExtension(project.AssemblyName) + ".xml";
212 // }
213 return docFile;
214 }
215  
216 private void WriteProject(SolutionNode solution, ProjectNode project)
217 {
218 string projFile = Helper.MakeFilePath(project.FullPath, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build");
219 StreamWriter ss = new StreamWriter(projFile);
220  
221 m_Kernel.CurrentWorkingDirectory.Push();
222 Helper.SetCurrentDir(Path.GetDirectoryName(projFile));
223 bool hasDoc = false;
224  
225 using (ss)
226 {
227 ss.WriteLine("<?xml version=\"1.0\" ?>");
228 ss.WriteLine("<project name=\"{0}\" default=\"build\">", project.Name);
229 ss.WriteLine(" <target name=\"{0}\">", "build");
230 //ss.WriteLine(" <echo message=\"Build Directory is ${project::get-base-directory()}/${build.dir}\" />");
231 //ss.WriteLine(" <mkdir dir=\"${project::get-base-directory()}/${build.dir}\" />");
232 ss.WriteLine(" <echo message=\"Build Directory is ${build.dir}\" />");
233 ss.WriteLine(" <mkdir dir=\"${build.dir}\" />");
234  
235 ss.Write(" <csc");
236 ss.Write(" target=\"{0}\"", project.Type.ToString().ToLower());
237 ss.Write(" debug=\"{0}\"", "${build.debug}");
238 foreach (ConfigurationNode conf in project.Configurations)
239 {
240 if (conf.Options.KeyFile != "")
241 {
242 ss.Write(" keyfile=\"{0}\"", conf.Options.KeyFile);
243 break;
244 }
245 }
246 foreach (ConfigurationNode conf in project.Configurations)
247 {
248 ss.Write(" unsafe=\"{0}\"", conf.Options.AllowUnsafe);
249 break;
250 }
251 foreach (ConfigurationNode conf in project.Configurations)
252 {
253 ss.Write(" warnaserror=\"{0}\"", conf.Options.WarningsAsErrors);
254 break;
255 }
256 foreach (ConfigurationNode conf in project.Configurations)
257 {
258 ss.Write(" define=\"{0}\"", conf.Options.CompilerDefines);
259 break;
260 }
261 foreach (ConfigurationNode conf in project.Configurations)
262 {
263 ss.Write(" nostdlib=\"{0}\"", conf.Options["NoStdLib"]);
264 break;
265 }
266  
267 ss.Write(" main=\"{0}\"", project.StartupObject);
268  
269 foreach (ConfigurationNode conf in project.Configurations)
270 {
271 if (GetXmlDocFile(project, conf) != "")
272 {
273 //ss.Write(" doc=\"{0}\"", "${project::get-base-directory()}/${build.dir}/" + GetXmlDocFile(project, conf));
274 ss.Write(" doc=\"{0}\"", "${build.dir}/" + GetXmlDocFile(project, conf));
275 hasDoc = true;
276 }
277 break;
278 }
279 //ss.Write(" output=\"{0}", "${project::get-base-directory()}/${build.dir}/${project::get-name()}");
280 ss.Write(" output=\"{0}", "${build.dir}/${project::get-name()}");
281 if (project.Type == ProjectType.Library)
282 {
283 ss.Write(".dll\"");
284 }
285 else
286 {
287 ss.Write(".exe\"");
288 }
289 if (project.AppIcon != null && project.AppIcon.Length != 0)
290 {
291 ss.Write(" win32icon=\"{0}\"", Helper.NormalizePath(project.AppIcon, '/'));
292 }
293 ss.WriteLine(">");
294 ss.WriteLine(" <resources prefix=\"{0}\" dynamicprefix=\"true\" >", project.RootNamespace);
295 foreach (string file in project.Files)
296 {
297 switch (project.Files.GetBuildAction(file))
298 {
299 case BuildAction.EmbeddedResource:
300 ss.WriteLine(" {0}", "<include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />");
301 break;
302 default:
303 if (file.EndsWith(".resx") || (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings))
304 {
305 ss.WriteLine(" <include name=\"{0}\" />", file.Substring(0, file.LastIndexOf('.')) + ".resx");
306 }
307 break;
308 }
309 }
310 //if (project.Files.GetSubType(file).ToString() != "Code")
311 //{
312 // ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".resx");
313  
314 ss.WriteLine(" </resources>");
315 ss.WriteLine(" <sources failonempty=\"true\">");
316 foreach (string file in project.Files)
317 {
318 switch (project.Files.GetBuildAction(file))
319 {
320 case BuildAction.Compile:
321 if (!file.EndsWith(".resx"))
322 ss.WriteLine(" <include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />");
323 break;
324 default:
325 break;
326 }
327 }
328 ss.WriteLine(" </sources>");
329 ss.WriteLine(" <references basedir=\"${project::get-base-directory()}\">");
330 ss.WriteLine(" <lib>");
331 ss.WriteLine(" <include name=\"${project::get-base-directory()}\" />");
332 //ss.WriteLine(" <include name=\"${project::get-base-directory()}/${build.dir}\" />");
333 ss.WriteLine(" <include name=\"${build.dir}\" />");
334 ss.WriteLine(" </lib>");
335 foreach (ReferenceNode refr in project.References)
336 {
337 ss.WriteLine(" <include name=\"{0}", Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReference(solution, refr)) + "\" />", '/'));
338 }
339 ss.WriteLine(" </references>");
340  
341 ArrayList suppressWarningsArray = new ArrayList();
342 ss.WriteLine(" <nowarn>");
343 foreach (ConfigurationNode conf in project.Configurations)
344 {
345 foreach (string s in conf.Options.SuppressWarnings.Split(new char[] { ',', ' ' }))
346 {
347 // duplicate check
348 if (!String.IsNullOrEmpty(s) && !suppressWarningsArray.Contains(s))
349 {
350 suppressWarningsArray.Add(s);
351 ss.WriteLine(" <warning number=\"{0}\" />", s);
352 }
353 }
354 }
355 suppressWarningsArray.Clear();
356  
357 ss.WriteLine(" </nowarn>");
358  
359 ss.WriteLine(" </csc>");
360 ss.WriteLine(" </target>");
361  
362 ss.WriteLine(" <target name=\"clean\">");
363 ss.WriteLine(" <delete dir=\"${bin.dir}\" failonerror=\"false\" />");
364 ss.WriteLine(" <delete dir=\"${obj.dir}\" failonerror=\"false\" />");
365 ss.WriteLine(" </target>");
366  
367 ss.WriteLine(" <target name=\"doc\" description=\"Creates documentation.\">");
368 if (hasDoc)
369 {
370 ss.WriteLine(" <property name=\"doc.target\" value=\"\" />");
371 ss.WriteLine(" <if test=\"${platform::is-unix()}\">");
372 ss.WriteLine(" <property name=\"doc.target\" value=\"Web\" />");
373 ss.WriteLine(" </if>");
374 ss.WriteLine(" <ndoc failonerror=\"false\" verbose=\"true\">");
375 ss.WriteLine(" <assemblies basedir=\"${project::get-base-directory()}\">");
376 ss.Write(" <include name=\"${build.dir}/${project::get-name()}");
377 if (project.Type == ProjectType.Library)
378 {
379 ss.WriteLine(".dll\" />");
380 }
381 else
382 {
383 ss.WriteLine(".exe\" />");
384 }
385  
386 ss.WriteLine(" </assemblies>");
387 ss.WriteLine(" <summaries basedir=\"${project::get-base-directory()}\">");
388 ss.WriteLine(" <include name=\"${build.dir}/${project::get-name()}.xml\"/>");
389 ss.WriteLine(" </summaries>");
390 ss.WriteLine(" <referencepaths basedir=\"${project::get-base-directory()}\">");
391 ss.WriteLine(" <include name=\"${build.dir}\" />");
392 // foreach(ReferenceNode refr in project.References)
393 // {
394 // string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReferencePath(solution, refr)), '/');
395 // if (path != "")
396 // {
397 // ss.WriteLine(" <include name=\"{0}\" />", path);
398 // }
399 // }
400 ss.WriteLine(" </referencepaths>");
401 ss.WriteLine(" <documenters>");
402 ss.WriteLine(" <documenter name=\"MSDN\">");
403 ss.WriteLine(" <property name=\"OutputDirectory\" value=\"${build.dir}/doc/${project::get-name()}\" />");
404 ss.WriteLine(" <property name=\"OutputTarget\" value=\"${doc.target}\" />");
405 ss.WriteLine(" <property name=\"HtmlHelpName\" value=\"${project::get-name()}\" />");
406 ss.WriteLine(" <property name=\"IncludeFavorites\" value=\"False\" />");
407 ss.WriteLine(" <property name=\"Title\" value=\"${project::get-name()} SDK Documentation\" />");
408 ss.WriteLine(" <property name=\"SplitTOCs\" value=\"False\" />");
409 ss.WriteLine(" <property name=\"DefaulTOC\" value=\"\" />");
410 ss.WriteLine(" <property name=\"ShowVisualBasic\" value=\"True\" />");
411 ss.WriteLine(" <property name=\"AutoDocumentConstructors\" value=\"True\" />");
412 ss.WriteLine(" <property name=\"ShowMissingSummaries\" value=\"${build.debug}\" />");
413 ss.WriteLine(" <property name=\"ShowMissingRemarks\" value=\"${build.debug}\" />");
414 ss.WriteLine(" <property name=\"ShowMissingParams\" value=\"${build.debug}\" />");
415 ss.WriteLine(" <property name=\"ShowMissingReturns\" value=\"${build.debug}\" />");
416 ss.WriteLine(" <property name=\"ShowMissingValues\" value=\"${build.debug}\" />");
417 ss.WriteLine(" <property name=\"DocumentInternals\" value=\"False\" />");
418 ss.WriteLine(" <property name=\"DocumentPrivates\" value=\"False\" />");
419 ss.WriteLine(" <property name=\"DocumentProtected\" value=\"True\" />");
420 ss.WriteLine(" <property name=\"DocumentEmptyNamespaces\" value=\"${build.debug}\" />");
421 ss.WriteLine(" <property name=\"IncludeAssemblyVersion\" value=\"True\" />");
422 ss.WriteLine(" </documenter>");
423 ss.WriteLine(" </documenters>");
424 ss.WriteLine(" </ndoc>");
425 }
426 ss.WriteLine(" </target>");
427 ss.WriteLine("</project>");
428 }
429 m_Kernel.CurrentWorkingDirectory.Pop();
430 }
431  
432 private void WriteCombine(SolutionNode solution)
433 {
434 m_Kernel.Log.Write("Creating NAnt build files");
435 foreach (ProjectNode project in solution.Projects)
436 {
437 if (m_Kernel.AllowProject(project.FilterGroups))
438 {
439 m_Kernel.Log.Write("...Creating project: {0}", project.Name);
440 WriteProject(solution, project);
441 }
442 }
443  
444 m_Kernel.Log.Write("");
445 string combFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "build");
446 StreamWriter ss = new StreamWriter(combFile);
447  
448 m_Kernel.CurrentWorkingDirectory.Push();
449 Helper.SetCurrentDir(Path.GetDirectoryName(combFile));
450  
451 using (ss)
452 {
453 ss.WriteLine("<?xml version=\"1.0\" ?>");
454 ss.WriteLine("<project name=\"{0}\" default=\"build\">", solution.Name);
455 ss.WriteLine(" <echo message=\"Using '${nant.settings.currentframework}' Framework\"/>");
456 ss.WriteLine();
457  
458 //ss.WriteLine(" <property name=\"dist.dir\" value=\"dist\" />");
459 //ss.WriteLine(" <property name=\"source.dir\" value=\"source\" />");
460 ss.WriteLine(" <property name=\"bin.dir\" value=\"bin\" />");
461 ss.WriteLine(" <property name=\"obj.dir\" value=\"obj\" />");
462 ss.WriteLine(" <property name=\"doc.dir\" value=\"doc\" />");
463 ss.WriteLine(" <property name=\"project.main.dir\" value=\"${project::get-base-directory()}\" />");
464  
465 foreach (ConfigurationNode conf in solution.Configurations)
466 {
467 // Set the project.config to a non-debug configuration
468 if (conf.Options["DebugInformation"].ToString().ToLower() != "true")
469 {
470 ss.WriteLine(" <property name=\"project.config\" value=\"{0}\" />", conf.Name);
471 }
472 ss.WriteLine();
473 ss.WriteLine(" <target name=\"{0}\" description=\"\">", conf.Name);
474 ss.WriteLine(" <property name=\"project.config\" value=\"{0}\" />", conf.Name);
475 ss.WriteLine(" <property name=\"build.debug\" value=\"{0}\" />", conf.Options["DebugInformation"].ToString().ToLower());
476 ss.WriteLine(" </target>");
477 ss.WriteLine();
478 }
479  
480 ss.WriteLine(" <target name=\"net-1.1\" description=\"Sets framework to .NET 1.1\">");
481 ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"net-1.1\" />");
482 ss.WriteLine(" </target>");
483 ss.WriteLine();
484  
485 ss.WriteLine(" <target name=\"net-2.0\" description=\"Sets framework to .NET 2.0\">");
486 ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"net-2.0\" />");
487 ss.WriteLine(" </target>");
488 ss.WriteLine();
489  
490 ss.WriteLine(" <target name=\"net-3.5\" description=\"Sets framework to .NET 3.5\">");
491 ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"net-3.5\" />");
492 ss.WriteLine(" </target>");
493 ss.WriteLine();
494  
495 ss.WriteLine(" <target name=\"mono-1.0\" description=\"Sets framework to mono 1.0\">");
496 ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"mono-1.0\" />");
497 ss.WriteLine(" </target>");
498 ss.WriteLine();
499  
500 ss.WriteLine(" <target name=\"mono-2.0\" description=\"Sets framework to mono 2.0\">");
501 ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"mono-2.0\" />");
502 ss.WriteLine(" </target>");
503 ss.WriteLine();
504  
505 ss.WriteLine(" <target name=\"mono-3.5\" description=\"Sets framework to mono 3.5\">");
506 ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"mono-3.5\" />");
507 ss.WriteLine(" </target>");
508 ss.WriteLine();
509  
510 ss.WriteLine(" <target name=\"init\" description=\"\">");
511 ss.WriteLine(" <call target=\"${project.config}\" />");
512 ss.WriteLine(" <property name=\"sys.os.platform\"");
513 ss.WriteLine(" value=\"${platform::get-name()}\"");
514 ss.WriteLine(" />");
515 ss.WriteLine(" <echo message=\"Platform ${sys.os.platform}\" />");
516 ss.WriteLine(" <property name=\"build.dir\" value=\"${project::get-base-directory()}/${bin.dir}\" />");
517 ss.WriteLine(" </target>");
518 ss.WriteLine();
519  
520 ss.WriteLine(" <target name=\"clean\" description=\"\">");
521 ss.WriteLine(" <echo message=\"Deleting all builds from all configurations\" />");
522 //ss.WriteLine(" <delete dir=\"${dist.dir}\" failonerror=\"false\" />");
523 ss.WriteLine(" <delete dir=\"${bin.dir}\" failonerror=\"false\" />");
524 ss.WriteLine(" <delete dir=\"${obj.dir}\" failonerror=\"false\" />");
525 foreach (ProjectNode project in solution.Projects)
526 {
527 string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
528 ss.Write(" <nant buildfile=\"{0}\"",
529 Helper.NormalizePath(Helper.MakeFilePath(path, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build"), '/'));
530 ss.WriteLine(" target=\"clean\" />");
531 }
532 ss.WriteLine(" </target>");
533 ss.WriteLine();
534  
535 ss.WriteLine(" <target name=\"build\" depends=\"init\" description=\"\">");
536  
537 foreach (ProjectNode project in solution.ProjectsTableOrder)
538 {
539 string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
540 ss.Write(" <nant buildfile=\"{0}\"",
541 Helper.NormalizePath(Helper.MakeFilePath(path, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build"), '/'));
542 ss.WriteLine(" target=\"build\" />");
543 }
544 ss.WriteLine(" </target>");
545 ss.WriteLine();
546  
547 ss.WriteLine(" <target name=\"build-release\" depends=\"Release, init, build\" description=\"Builds in Release mode\" />");
548 ss.WriteLine();
549 ss.WriteLine(" <target name=\"build-debug\" depends=\"Debug, init, build\" description=\"Builds in Debug mode\" />");
550 ss.WriteLine();
551 //ss.WriteLine(" <target name=\"package\" depends=\"clean, doc, copyfiles, zip\" description=\"Builds in Release mode\" />");
552 ss.WriteLine(" <target name=\"package\" depends=\"clean, doc\" description=\"Builds all\" />");
553 ss.WriteLine();
554  
555 ss.WriteLine(" <target name=\"doc\" depends=\"build-release\">");
556 ss.WriteLine(" <echo message=\"Generating all documentation from all builds\" />");
557 foreach (ProjectNode project in solution.Projects)
558 {
559 string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
560 ss.Write(" <nant buildfile=\"{0}\"",
561 Helper.NormalizePath(Helper.MakeFilePath(path, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build"), '/'));
562 ss.WriteLine(" target=\"doc\" />");
563 }
564 ss.WriteLine(" </target>");
565 ss.WriteLine();
566 ss.WriteLine("</project>");
567 }
568  
569 m_Kernel.CurrentWorkingDirectory.Pop();
570 }
571  
572 private void CleanProject(ProjectNode project)
573 {
574 m_Kernel.Log.Write("...Cleaning project: {0}", project.Name);
575 string projectFile = Helper.MakeFilePath(project.FullPath, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build");
576 Helper.DeleteIfExists(projectFile);
577 }
578  
579 private void CleanSolution(SolutionNode solution)
580 {
581 m_Kernel.Log.Write("Cleaning NAnt build files for", solution.Name);
582  
583 string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "build");
584 Helper.DeleteIfExists(slnFile);
585  
586 foreach (ProjectNode project in solution.Projects)
587 {
588 CleanProject(project);
589 }
590  
591 m_Kernel.Log.Write("");
592 }
593  
594 #endregion
595  
596 #region ITarget Members
597  
598 /// <summary>
599 /// Writes the specified kern.
600 /// </summary>
601 /// <param name="kern">The kern.</param>
602 public void Write(Kernel kern)
603 {
604 if (kern == null)
605 {
606 throw new ArgumentNullException("kern");
607 }
608 m_Kernel = kern;
609 foreach (SolutionNode solution in kern.Solutions)
610 {
611 WriteCombine(solution);
612 }
613 m_Kernel = null;
614 }
615  
616 /// <summary>
617 /// Cleans the specified kern.
618 /// </summary>
619 /// <param name="kern">The kern.</param>
620 public virtual void Clean(Kernel kern)
621 {
622 if (kern == null)
623 {
624 throw new ArgumentNullException("kern");
625 }
626 m_Kernel = kern;
627 foreach (SolutionNode sol in kern.Solutions)
628 {
629 CleanSolution(sol);
630 }
631 m_Kernel = null;
632 }
633  
634 /// <summary>
635 /// Gets the name.
636 /// </summary>
637 /// <value>The name.</value>
638 public string Name
639 {
640 get
641 {
642 return "nant";
643 }
644 }
645  
646 #endregion
647 }
648 }