aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Prebuild/src/Core/Targets
diff options
context:
space:
mode:
Diffstat (limited to 'Prebuild/src/Core/Targets')
-rw-r--r--Prebuild/src/Core/Targets/AutotoolsTarget.cs926
-rw-r--r--Prebuild/src/Core/Targets/DebugTarget.cs102
-rw-r--r--Prebuild/src/Core/Targets/MonoDevelopTarget.cs458
-rw-r--r--Prebuild/src/Core/Targets/NAntTarget.cs621
-rw-r--r--Prebuild/src/Core/Targets/SharpDevelop2Target.cs90
-rw-r--r--Prebuild/src/Core/Targets/SharpDevelopTarget.cs437
-rw-r--r--Prebuild/src/Core/Targets/VS2002Target.cs96
-rw-r--r--Prebuild/src/Core/Targets/VS2003Target.cs633
-rw-r--r--Prebuild/src/Core/Targets/VS2005Target.cs869
9 files changed, 4232 insertions, 0 deletions
diff --git a/Prebuild/src/Core/Targets/AutotoolsTarget.cs b/Prebuild/src/Core/Targets/AutotoolsTarget.cs
new file mode 100644
index 0000000..2b4a678
--- /dev/null
+++ b/Prebuild/src/Core/Targets/AutotoolsTarget.cs
@@ -0,0 +1,926 @@
1#region BSD License
2/*
3
4Copyright (c) 2004 - 2006
5Matthew Holmes (matthew@wildfiregames.com),
6Dan Moorehead (dan05a@gmail.com),
7Dave Hudson (jendave@yahoo.com),
8C.J. Adams-Collier (cjcollier@colliertech.org),
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are
12met:
13
14* Redistributions of source code must retain the above copyright
15notice, this list of conditions and the following disclaimer.
16
17* Redistributions in binary form must reproduce the above copyright
18notice, this list of conditions and the following disclaimer in the
19documentation and/or other materials provided with the distribution.
20
21* The name of the author may not be used to endorse or promote
22products derived from this software without specific prior written
23permission.
24
25THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
26IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
27WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
29INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
33STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
34IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35POSSIBILITY OF SUCH DAMAGE.
36
37*/
38#endregion
39
40#region CVS Information
41/*
42 * $Source$
43 * $Author: jendave $
44 * $Date: 2006-07-28 22:43:24 -0700 (Fri, 28 Jul 2006) $
45 * $Revision: 136 $
46 */
47#endregion
48
49using System;
50using System.Collections;
51using System.Collections.Specialized;
52using System.IO;
53using System.Reflection;
54using System.Text;
55using System.Text.RegularExpressions;
56
57using Prebuild.Core.Attributes;
58using Prebuild.Core.Interfaces;
59using Prebuild.Core.Nodes;
60using Prebuild.Core.Parse;
61using Prebuild.Core.Utilities;
62
63namespace Prebuild.Core.Targets
64{
65 /// <summary>
66 ///
67 /// </summary>
68 [Target("autotools")]
69 public class AutotoolsTarget : ITarget
70 {
71 #region Fields
72
73 private Kernel m_Kernel;
74
75 #endregion
76
77 #region Private Methods
78
79 private static string PrependPath(string path)
80 {
81 string tmpPath = Helper.NormalizePath(path, '/');
82 Regex regex = new Regex(@"(\w):/(\w+)");
83 Match match = regex.Match(tmpPath);
84 if(match.Success || tmpPath[0] == '.' || tmpPath[0] == '/')
85 {
86 tmpPath = Helper.NormalizePath(tmpPath);
87 }
88 else
89 {
90 tmpPath = Helper.NormalizePath("./" + tmpPath);
91 }
92
93 return tmpPath;
94 }
95
96 private static string BuildReference(SolutionNode solution, ReferenceNode refr)
97 {
98 string ret = "";
99 if(solution.ProjectsTable.ContainsKey(refr.Name))
100 {
101 ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name];
102 string fileRef = FindFileReference(refr.Name, project);
103 string finalPath = Helper.NormalizePath(Helper.MakeFilePath(project.FullPath + "/$(BUILD_DIR)/$(CONFIG)/", refr.Name, "dll"), '/');
104 ret += finalPath;
105 return ret;
106 }
107 else
108 {
109 ProjectNode project = (ProjectNode)refr.Parent;
110 string fileRef = FindFileReference(refr.Name, project);
111
112 if(refr.Path != null || fileRef != null)
113 {
114 string finalPath = (refr.Path != null) ? Helper.NormalizePath(refr.Path + "/" + refr.Name + ".dll", '/') : fileRef;
115 ret += Path.Combine(project.Path, finalPath);
116 return ret;
117 }
118
119 try
120 {
121 //Assembly assem = Assembly.Load(refr.Name);
122 //if (assem != null)
123 //{
124 // int index = refr.Name.IndexOf(",");
125 // if ( index > 0)
126 // {
127 // ret += assem.Location;
128 // //Console.WriteLine("Location1: " + assem.Location);
129 // }
130 // else
131 // {
132 // ret += (refr.Name + ".dll");
133 // //Console.WriteLine("Location2: " + assem.Location);
134 // }
135 //}
136 //else
137 //{
138 int index = refr.Name.IndexOf(",");
139 if ( index > 0)
140 {
141 ret += refr.Name.Substring(0, index) + ".dll";
142 //Console.WriteLine("Location3: " + assem.Location);
143 }
144 else
145 {
146 ret += (refr.Name + ".dll");
147 //Console.WriteLine("Location4: " + assem.Location);
148 }
149 //}
150 }
151 catch (System.NullReferenceException e)
152 {
153 e.ToString();
154 int index = refr.Name.IndexOf(",");
155 if ( index > 0)
156 {
157 ret += refr.Name.Substring(0, index) + ".dll";
158 //Console.WriteLine("Location5: " + assem.Location);
159 }
160 else
161 {
162 ret += (refr.Name + ".dll");
163 //Console.WriteLine("Location6: " + assem.Location);
164 }
165 }
166 }
167 return ret;
168 }
169
170 private static string BuildReferencePath(SolutionNode solution, ReferenceNode refr)
171 {
172 string ret = "";
173 if(solution.ProjectsTable.ContainsKey(refr.Name))
174 {
175 ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name];
176 string finalPath = Helper.NormalizePath(Helper.MakeReferencePath(project.FullPath + "/${build.dir}/"), '/');
177 ret += finalPath;
178 return ret;
179 }
180 else
181 {
182 ProjectNode project = (ProjectNode)refr.Parent;
183 string fileRef = FindFileReference(refr.Name, project);
184
185
186 if(refr.Path != null || fileRef != null)
187 {
188 string finalPath = (refr.Path != null) ? Helper.NormalizePath(refr.Path, '/') : fileRef;
189 ret += finalPath;
190 return ret;
191 }
192
193 try
194 {
195 Assembly assem = Assembly.Load(refr.Name);
196 if (assem != null)
197 {
198 ret += "";
199 }
200 else
201 {
202 ret += "";
203 }
204 }
205 catch (System.NullReferenceException e)
206 {
207 e.ToString();
208 ret += "";
209 }
210 }
211 return ret;
212 }
213
214 private static string FindFileReference(string refName, ProjectNode project)
215 {
216 foreach(ReferencePathNode refPath in project.ReferencePaths)
217 {
218 string fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll");
219
220 if(File.Exists(fullPath))
221 {
222 return fullPath;
223 }
224 }
225
226 return null;
227 }
228
229 /// <summary>
230 /// Gets the XML doc file.
231 /// </summary>
232 /// <param name="project">The project.</param>
233 /// <param name="conf">The conf.</param>
234 /// <returns></returns>
235 public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf)
236 {
237 if( conf == null )
238 {
239 throw new ArgumentNullException("conf");
240 }
241 if( project == null )
242 {
243 throw new ArgumentNullException("project");
244 }
245 string docFile = (string)conf.Options["XmlDocFile"];
246 // if(docFile != null && docFile.Length == 0)//default to assembly name if not specified
247 // {
248 // return Path.GetFileNameWithoutExtension(project.AssemblyName) + ".xml";
249 // }
250 return docFile;
251 }
252
253 /// <summary>
254 /// Normalizes the path.
255 /// </summary>
256 /// <param name="path">The path.</param>
257 /// <returns></returns>
258 public static string NormalizePath(string path)
259 {
260 if(path == null)
261 {
262 return "";
263 }
264
265 StringBuilder tmpPath;
266
267 if (Core.Parse.Preprocessor.GetOS() == "Win32")
268 {
269 tmpPath = new StringBuilder(path.Replace('\\', '/'));
270 tmpPath.Replace("/", @"\\");
271 }
272 else
273 {
274 tmpPath = new StringBuilder(path.Replace('\\', '/'));
275 tmpPath = tmpPath.Replace('/', Path.DirectorySeparatorChar);
276 }
277 return tmpPath.ToString();
278 }
279
280 private void WriteProject(SolutionNode solution, ProjectNode project)
281 {
282 string projFile = Helper.MakeFilePath(project.FullPath, "Include", "am");
283 StreamWriter ss = new StreamWriter(projFile);
284 ss.NewLine = "\n";
285
286 m_Kernel.CurrentWorkingDirectory.Push();
287 Helper.SetCurrentDir(Path.GetDirectoryName(projFile));
288
289 using(ss)
290 {
291 ss.WriteLine(Helper.AssemblyFullName(project.AssemblyName, project.Type) + ":");
292 ss.WriteLine("\tmkdir -p " + Helper.MakePathRelativeTo(solution.FullPath, project.Path) + "/$(BUILD_DIR)/$(CONFIG)/");
293 foreach(string file in project.Files)
294 {
295 if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings)
296 {
297 ss.Write("\tresgen ");
298 ss.Write(Helper.NormalizePath(Path.Combine(project.Path, file.Substring(0, file.LastIndexOf('.')) + ".resx "), '/'));
299 if (project.Files.GetResourceName(file) != "")
300 {
301 ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + project.Files.GetResourceName(file) + ".resources"), '/'));
302 }
303 else
304 {
305 ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + file.Substring(0, file.LastIndexOf('.')) + ".resources"), '/'));
306 }
307 }
308 }
309 ss.WriteLine("\t$(CSC)\t/out:" + Helper.MakePathRelativeTo(solution.FullPath, project.Path) + "/$(BUILD_DIR)/$(CONFIG)/" + Helper.AssemblyFullName(project.AssemblyName, project.Type) + " \\");
310 ss.WriteLine("\t\t/target:" + project.Type.ToString().ToLower() + " \\");
311 if (project.References.Count > 0)
312 {
313 ss.Write("\t\t/reference:");
314 bool firstref = true;
315 foreach(ReferenceNode refr in project.References)
316 {
317 if (firstref)
318 {
319 firstref = false;
320 }
321 else
322 {
323 ss.Write(",");
324 }
325 ss.Write("{0}", Helper.NormalizePath(Helper.MakePathRelativeTo(solution.FullPath, BuildReference(solution, refr)), '/'));
326 }
327 ss.WriteLine(" \\");
328 }
329 //ss.WriteLine("\t\tProperties/AssemblyInfo.cs \\");
330
331 foreach(string file in project.Files)
332 {
333 switch(project.Files.GetBuildAction(file))
334 {
335 case BuildAction.EmbeddedResource:
336 ss.Write("\t\t/resource:");
337 ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, file), '/') + " \\");
338 break;
339 default:
340 if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings)
341 {
342 ss.Write("\t\t/resource:");
343 if (project.Files.GetResourceName(file) != "")
344 {
345 ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + project.Files.GetResourceName(file) + ".resources"), '/') + "," + project.RootNamespace + "." + project.Files.GetResourceName(file) + ".resources" + " \\");
346 }
347 else
348 {
349 ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + file.Substring(0, file.LastIndexOf('.')) + ".resources"), '/') + "," + project.RootNamespace + "." + file.Substring(0, file.LastIndexOf('.')) + ".resources" + " \\");
350 }
351 }
352 break;
353 }
354 }
355
356 foreach(ConfigurationNode conf in project.Configurations)
357 {
358 if (conf.Options.KeyFile !="")
359 {
360 ss.WriteLine("\t\t/keyfile:" + Helper.NormalizePath(Path.Combine(project.Path, conf.Options.KeyFile), '/') + " \\");
361 break;
362 }
363 }
364 foreach(ConfigurationNode conf in project.Configurations)
365 {
366 if (conf.Options.AllowUnsafe)
367 {
368 ss.WriteLine("\t\t/unsafe \\");
369 break;
370 }
371 }
372 if (project.AppIcon != "")
373 {
374 ss.WriteLine("\t\t/win32icon:" + Helper.NormalizePath(Path.Combine(project.Path, project.AppIcon), '/') + " \\");
375 }
376
377 foreach(ConfigurationNode conf in project.Configurations)
378 {
379 ss.WriteLine("\t\t/define:{0}", conf.Options.CompilerDefines.Replace(';', ',') + " \\");
380 break;
381 }
382
383 foreach(ConfigurationNode conf in project.Configurations)
384 {
385 if (GetXmlDocFile(project, conf) !="")
386 {
387 ss.WriteLine("\t\t/doc:" + Helper.MakePathRelativeTo(solution.FullPath, project.Path) + "/$(BUILD_DIR)/$(CONFIG)/" + project.Name + ".xml \\");
388 break;
389 }
390 }
391 foreach(string file in project.Files)
392 {
393 switch(project.Files.GetBuildAction(file))
394 {
395 case BuildAction.Compile:
396 ss.WriteLine("\t\t\\");
397 ss.Write("\t\t" + NormalizePath(Path.Combine(Helper.MakePathRelativeTo(solution.FullPath, project.Path), file)));
398 break;
399 default:
400 break;
401 }
402 }
403 ss.WriteLine();
404 ss.WriteLine();
405
406 if (project.Type == ProjectType.Library)
407 {
408 ss.WriteLine("install-data-local:");
409 ss.WriteLine(" echo \"$(GACUTIL) /i bin/Release/" + project.Name + ".dll /f $(GACUTIL_FLAGS)\"; \\");
410 ss.WriteLine(" $(GACUTIL) /i bin/Release/" + project.Name + ".dll /f $(GACUTIL_FLAGS) || exit 1;");
411 ss.WriteLine();
412 ss.WriteLine("uninstall-local:");
413 ss.WriteLine(" echo \"$(GACUTIL) /u " + project.Name + " $(GACUTIL_FLAGS)\"; \\");
414 ss.WriteLine(" $(GACUTIL) /u " + project.Name + " $(GACUTIL_FLAGS) || exit 1;");
415 ss.WriteLine();
416 }
417 ss.WriteLine("CLEANFILES = $(BUILD_DIR)/$(CONFIG)/" + Helper.AssemblyFullName(project.AssemblyName, project.Type) + " $(BUILD_DIR)/$(CONFIG)/" + project.AssemblyName + ".mdb $(BUILD_DIR)/$(CONFIG)/" + project.AssemblyName + ".pdb " + project.AssemblyName + ".xml");
418 ss.WriteLine("EXTRA_DIST = \\");
419 ss.Write(" $(FILES)");
420 foreach(ConfigurationNode conf in project.Configurations)
421 {
422 if (conf.Options.KeyFile != "")
423 {
424 ss.Write(" \\");
425 ss.WriteLine("\t" + conf.Options.KeyFile);
426 }
427 break;
428 }
429 }
430 m_Kernel.CurrentWorkingDirectory.Pop();
431 }
432 bool hasLibrary = false;
433
434 private void WriteCombine(SolutionNode solution)
435 {
436
437 /* TODO: These vars should be pulled from the prebuild.xml file */
438 string releaseVersion = "2.0.0";
439 string assemblyVersion = "2.1.0.0";
440 string description =
441 "Tao Framework " + solution.Name + " Binding For .NET";
442
443 hasLibrary = false;
444 m_Kernel.Log.Write("Creating Autotools make files");
445 foreach(ProjectNode project in solution.Projects)
446 {
447 if(m_Kernel.AllowProject(project.FilterGroups))
448 {
449 m_Kernel.Log.Write("...Creating makefile: {0}", project.Name);
450 WriteProject(solution, project);
451 }
452 }
453
454 m_Kernel.Log.Write("");
455 string combFile = Helper.MakeFilePath(solution.FullPath, "Makefile", "am");
456 StreamWriter ss = new StreamWriter(combFile);
457 ss.NewLine = "\n";
458
459 m_Kernel.CurrentWorkingDirectory.Push();
460 Helper.SetCurrentDir(Path.GetDirectoryName(combFile));
461
462 using(ss)
463 {
464 foreach(ProjectNode project in solution.ProjectsTableOrder)
465 {
466 if (project.Type == ProjectType.Library)
467 {
468 hasLibrary = true;
469 break;
470 }
471 }
472
473 if (hasLibrary)
474 {
475 ss.Write("pkgconfig_in_files = ");
476 foreach(ProjectNode project in solution.ProjectsTableOrder)
477 {
478 if (project.Type == ProjectType.Library)
479 {
480 string combFilepc = Helper.MakeFilePath(solution.FullPath, project.Name, "pc.in");
481 ss.Write(" " + project.Name + ".pc.in ");
482 StreamWriter sspc = new StreamWriter(combFilepc);
483 sspc.NewLine = "\n";
484 using(sspc)
485 {
486 sspc.WriteLine("prefix=@prefix@");
487 sspc.WriteLine("exec_prefix=${prefix}");
488 sspc.WriteLine("libdir=${exec_prefix}/lib");
489 sspc.WriteLine();
490 sspc.WriteLine("Name: @PACKAGE_NAME@");
491 sspc.WriteLine("Description: @DESCRIPTION@");
492 sspc.WriteLine("Version: @ASSEMBLY_VERSION@");
493 sspc.WriteLine("Libs: -r:${libdir}/mono/gac/@PACKAGE_NAME@/@ASSEMBLY_VERSION@__@PUBKEY@/@PACKAGE_NAME@.dll");
494 }
495 }
496 }
497
498 ss.WriteLine();
499 ss.WriteLine("pkgconfigdir=$(prefix)/lib/pkgconfig");
500 ss.WriteLine("pkgconfig_DATA=$(pkgconfig_in_files:.pc.in=.pc)");
501 }
502 ss.WriteLine();
503 foreach(ProjectNode project in solution.ProjectsTableOrder)
504 {
505 string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
506 ss.WriteLine("-include x {0}",
507 Helper.NormalizePath(Helper.MakeFilePath(path, "Include", "am"),'/'));
508 }
509 ss.WriteLine();
510 ss.WriteLine("all: \\");
511 ss.Write("\t");
512 foreach(ProjectNode project in solution.ProjectsTableOrder)
513 {
514 string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
515 ss.Write(Helper.AssemblyFullName(project.AssemblyName, project.Type) + " ");
516
517 }
518 ss.WriteLine();
519 if (hasLibrary)
520 {
521 ss.WriteLine("EXTRA_DIST = \\");
522 ss.WriteLine("\t$(pkgconfig_in_files)");
523 }
524 else
525 {
526 ss.WriteLine("EXTRA_DIST = ");
527 }
528 ss.WriteLine();
529 ss.WriteLine("DISTCLEANFILES = \\");
530 ss.WriteLine("\tconfigure \\");
531 ss.WriteLine("\tMakefile.in \\");
532 ss.WriteLine("\taclocal.m4");
533 }
534 combFile = Helper.MakeFilePath(solution.FullPath, "configure", "ac");
535 StreamWriter ts = new StreamWriter(combFile);
536 ts.NewLine = "\n";
537 using(ts)
538 {
539 if (this.hasLibrary)
540 {
541 foreach(ProjectNode project in solution.ProjectsTableOrder)
542 {
543 if (project.Type == ProjectType.Library)
544 {
545 ts.WriteLine("AC_INIT(" + project.Name + ".pc.in)");
546 break;
547 }
548 }
549 }
550 else
551 {
552 ts.WriteLine("AC_INIT(Makefile.am)");
553 }
554 ts.WriteLine("AC_PREREQ(2.53)");
555 ts.WriteLine("AC_CANONICAL_SYSTEM");
556
557 ts.WriteLine("PACKAGE_NAME={0}", solution.Name);
558 ts.WriteLine("PACKAGE_VERSION={0}", releaseVersion);
559 ts.WriteLine("DESCRIPTION=\"{0}\"", description);
560 ts.WriteLine("AC_SUBST(DESCRIPTION)");
561 ts.WriteLine("AM_INIT_AUTOMAKE([$PACKAGE_NAME],[$PACKAGE_VERSION],[$DESCRIPTION])");
562
563 ts.WriteLine("ASSEMBLY_VERSION={0}", assemblyVersion);
564 ts.WriteLine("AC_SUBST(ASSEMBLY_VERSION)");
565
566 ts.WriteLine("PUBKEY=`sn -t $PACKAGE_NAME.snk | grep 'Public Key Token' | awk -F: '{print $2}' | sed -e 's/^ //'`");
567 ts.WriteLine("AC_SUBST(PUBKEY)");
568
569 ts.WriteLine();
570 ts.WriteLine("AM_MAINTAINER_MODE");
571 ts.WriteLine();
572 ts.WriteLine("dnl AC_PROG_INTLTOOL([0.25])");
573 ts.WriteLine();
574 ts.WriteLine("AC_PROG_INSTALL");
575 ts.WriteLine();
576 ts.WriteLine("MONO_REQUIRED_VERSION=1.1");
577 ts.WriteLine();
578 ts.WriteLine("AC_MSG_CHECKING([whether we're compiling from CVS])");
579 ts.WriteLine("if test -f \"$srcdir/.cvs_version\" ; then");
580 ts.WriteLine(" from_cvs=yes");
581 ts.WriteLine("else");
582 ts.WriteLine(" if test -f \"$srcdir/.svn\" ; then");
583 ts.WriteLine(" from_cvs=yes");
584 ts.WriteLine(" else");
585 ts.WriteLine(" from_cvs=no");
586 ts.WriteLine(" fi");
587 ts.WriteLine("fi");
588 ts.WriteLine();
589 ts.WriteLine("AC_MSG_RESULT($from_cvs)");
590 ts.WriteLine();
591 ts.WriteLine("AC_PATH_PROG(MONO, mono)");
592 ts.WriteLine("AC_PATH_PROG(GMCS, gmcs)");
593 ts.WriteLine("AC_PATH_PROG(GACUTIL, gacutil)");
594 ts.WriteLine();
595 ts.WriteLine("AC_MSG_CHECKING([for mono])");
596 ts.WriteLine("dnl if test \"x$MONO\" = \"x\" ; then");
597 ts.WriteLine("dnl AC_MSG_ERROR([Can't find \"mono\" in your PATH])");
598 ts.WriteLine("dnl else");
599 ts.WriteLine(" AC_MSG_RESULT([found])");
600 ts.WriteLine("dnl fi");
601 ts.WriteLine();
602 ts.WriteLine("AC_MSG_CHECKING([for gmcs])");
603 ts.WriteLine("dnl if test \"x$GMCS\" = \"x\" ; then");
604 ts.WriteLine("dnl AC_MSG_ERROR([Can't find \"gmcs\" in your PATH])");
605 ts.WriteLine("dnl else");
606 ts.WriteLine(" AC_MSG_RESULT([found])");
607 ts.WriteLine("dnl fi");
608 ts.WriteLine();
609 //ts.WriteLine("AC_MSG_CHECKING([for gacutil])");
610 //ts.WriteLine("if test \"x$GACUTIL\" = \"x\" ; then");
611 //ts.WriteLine(" AC_MSG_ERROR([Can't find \"gacutil\" in your PATH])");
612 //ts.WriteLine("else");
613 //ts.WriteLine(" AC_MSG_RESULT([found])");
614 //ts.WriteLine("fi");
615 ts.WriteLine();
616 ts.WriteLine("AC_SUBST(PATH)");
617 ts.WriteLine("AC_SUBST(LD_LIBRARY_PATH)");
618 ts.WriteLine();
619 ts.WriteLine("dnl CSFLAGS=\"-debug -nowarn:1574\"");
620 ts.WriteLine("CSFLAGS=\"\"");
621 ts.WriteLine("AC_SUBST(CSFLAGS)");
622 ts.WriteLine();
623 // ts.WriteLine("AC_MSG_CHECKING(--disable-sdl argument)");
624 // ts.WriteLine("AC_ARG_ENABLE(sdl,");
625 // ts.WriteLine(" [ --disable-sdl Disable Sdl interface.],");
626 // ts.WriteLine(" [disable_sdl=$disableval],");
627 // ts.WriteLine(" [disable_sdl=\"no\"])");
628 // ts.WriteLine("AC_MSG_RESULT($disable_sdl)");
629 // ts.WriteLine("if test \"$disable_sdl\" = \"yes\"; then");
630 // ts.WriteLine(" AC_DEFINE(FEAT_SDL)");
631 // ts.WriteLine("fi");
632 ts.WriteLine();
633 ts.WriteLine("dnl Find pkg-config");
634 ts.WriteLine("AC_PATH_PROG(PKGCONFIG, pkg-config, no)");
635 ts.WriteLine("if test \"x$PKG_CONFIG\" = \"xno\"; then");
636 ts.WriteLine(" AC_MSG_ERROR([You need to install pkg-config])");
637 ts.WriteLine("fi");
638 ts.WriteLine();
639 ts.WriteLine("PKG_CHECK_MODULES(MONO_DEPENDENCY, mono >= $MONO_REQUIRED_VERSION, has_mono=true, has_mono=false)");
640 ts.WriteLine("BUILD_DIR=\"bin\"");
641 ts.WriteLine("AC_SUBST(BUILD_DIR)");
642 ts.WriteLine("CONFIG=\"Release\"");
643 ts.WriteLine("AC_SUBST(CONFIG)");
644 ts.WriteLine();
645 ts.WriteLine("if test \"x$has_mono\" = \"xtrue\"; then");
646 ts.WriteLine(" AC_PATH_PROG(RUNTIME, mono, no)");
647 ts.WriteLine(" AC_PATH_PROG(CSC, gmcs, no)");
648 ts.WriteLine(" if test `uname -s` = \"Darwin\"; then");
649 ts.WriteLine(" LIB_PREFIX=");
650 ts.WriteLine(" LIB_SUFFIX=.dylib");
651 ts.WriteLine(" else");
652 ts.WriteLine(" LIB_PREFIX=.so");
653 ts.WriteLine(" LIB_SUFFIX=");
654 ts.WriteLine(" fi");
655 ts.WriteLine("else");
656 ts.WriteLine(" AC_PATH_PROG(CSC, csc.exe, no)");
657 ts.WriteLine(" if test x$CSC = \"xno\"; then");
658 ts.WriteLine(" AC_MSG_ERROR([You need to install either mono or .Net])");
659 ts.WriteLine(" else");
660 ts.WriteLine(" RUNTIME=");
661 ts.WriteLine(" LIB_PREFIX=");
662 ts.WriteLine(" LIB_SUFFIX=.dylib");
663 ts.WriteLine(" fi");
664 ts.WriteLine("fi");
665 ts.WriteLine();
666 ts.WriteLine("AC_SUBST(LIB_PREFIX)");
667 ts.WriteLine("AC_SUBST(LIB_SUFFIX)");
668 ts.WriteLine();
669 ts.WriteLine("AC_SUBST(BASE_DEPENDENCIES_CFLAGS)");
670 ts.WriteLine("AC_SUBST(BASE_DEPENDENCIES_LIBS)");
671 ts.WriteLine();
672 ts.WriteLine("dnl Find monodoc");
673 ts.WriteLine("MONODOC_REQUIRED_VERSION=1.0");
674 ts.WriteLine("AC_SUBST(MONODOC_REQUIRED_VERSION)");
675 ts.WriteLine("PKG_CHECK_MODULES(MONODOC_DEPENDENCY, monodoc >= $MONODOC_REQUIRED_VERSION, enable_monodoc=yes, enable_monodoc=no)");
676 ts.WriteLine();
677 ts.WriteLine("if test \"x$enable_monodoc\" = \"xyes\"; then");
678 ts.WriteLine(" AC_PATH_PROG(MONODOC, monodoc, no)");
679 ts.WriteLine(" if test x$MONODOC = xno; then");
680 ts.WriteLine(" enable_monodoc=no");
681 ts.WriteLine(" fi");
682 ts.WriteLine("else");
683 ts.WriteLine(" MONODOC=");
684 ts.WriteLine("fi");
685 ts.WriteLine();
686 ts.WriteLine("AC_SUBST(MONODOC)");
687 ts.WriteLine("AM_CONDITIONAL(ENABLE_MONODOC, test \"x$enable_monodoc\" = \"xyes\")");
688 ts.WriteLine();
689 ts.WriteLine("AC_PATH_PROG(GACUTIL, gacutil, no)");
690 ts.WriteLine("if test \"x$GACUTIL\" = \"xno\" ; then");
691 ts.WriteLine(" AC_MSG_ERROR([No gacutil tool found])");
692 ts.WriteLine("fi");
693 ts.WriteLine();
694 // foreach(ProjectNode project in solution.ProjectsTableOrder)
695 // {
696 // if (project.Type == ProjectType.Library)
697 // {
698 // }
699 // }
700 ts.WriteLine("GACUTIL_FLAGS='/package $(PACKAGE_NAME) /gacdir $(DESTDIR)$(prefix)'");
701 ts.WriteLine("AC_SUBST(GACUTIL_FLAGS)");
702 ts.WriteLine();
703 ts.WriteLine("winbuild=no");
704 ts.WriteLine("case \"$host\" in");
705 ts.WriteLine(" *-*-mingw*|*-*-cygwin*)");
706 ts.WriteLine(" winbuild=yes");
707 ts.WriteLine(" ;;");
708 ts.WriteLine("esac");
709 ts.WriteLine("AM_CONDITIONAL(WINBUILD, test x$winbuild = xyes)");
710 ts.WriteLine();
711 // ts.WriteLine("dnl Check for SDL");
712 // ts.WriteLine();
713 // ts.WriteLine("AC_PATH_PROG([SDL_CONFIG], [sdl-config])");
714 // ts.WriteLine("have_sdl=no");
715 // ts.WriteLine("if test -n \"${SDL_CONFIG}\"; then");
716 // ts.WriteLine(" have_sdl=yes");
717 // ts.WriteLine(" SDL_CFLAGS=`$SDL_CONFIG --cflags`");
718 // ts.WriteLine(" SDL_LIBS=`$SDL_CONFIG --libs`");
719 // ts.WriteLine(" #");
720 // ts.WriteLine(" # sdl-config sometimes emits an rpath flag pointing at its library");
721 // ts.WriteLine(" # installation directory. We don't want this, as it prevents users from");
722 // ts.WriteLine(" # linking sdl-viewer against, for example, a locally compiled libGL when a");
723 // ts.WriteLine(" # version of the library also exists in SDL's library installation");
724 // ts.WriteLine(" # directory, typically /usr/lib.");
725 // ts.WriteLine(" #");
726 // ts.WriteLine(" SDL_LIBS=`echo $SDL_LIBS | sed 's/-Wl,-rpath,[[^ ]]* //'`");
727 // ts.WriteLine("fi");
728 // ts.WriteLine("AC_SUBST([SDL_CFLAGS])");
729 // ts.WriteLine("AC_SUBST([SDL_LIBS])");
730 ts.WriteLine();
731 ts.WriteLine("AC_OUTPUT([");
732 ts.WriteLine("Makefile");
733 // TODO: this does not work quite right.
734 //ts.WriteLine("Properties/AssemblyInfo.cs");
735 foreach(ProjectNode project in solution.ProjectsTableOrder)
736 {
737 if (project.Type == ProjectType.Library)
738 {
739 ts.WriteLine(project.Name + ".pc");
740 }
741 // string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
742 // ts.WriteLine(Helper.NormalizePath(Helper.MakeFilePath(path, "Include"),'/'));
743 }
744 ts.WriteLine("])");
745 ts.WriteLine();
746 ts.WriteLine("#po/Makefile.in");
747 ts.WriteLine();
748 ts.WriteLine("echo \"---\"");
749 ts.WriteLine("echo \"Configuration summary\"");
750 ts.WriteLine("echo \"\"");
751 ts.WriteLine("echo \" * Installation prefix: $prefix\"");
752 ts.WriteLine("echo \" * compiler: $CSC\"");
753 ts.WriteLine("echo \" * Documentation: $enable_monodoc ($MONODOC)\"");
754 ts.WriteLine("echo \" * Package Name: $PACKAGE_NAME\"");
755 ts.WriteLine("echo \" * Version: $PACKAGE_VERSION\"");
756 ts.WriteLine("echo \" * Public Key: $PUBKEY\"");
757 ts.WriteLine("echo \"\"");
758 ts.WriteLine("echo \"---\"");
759 ts.WriteLine();
760 }
761
762 ts.NewLine = "\n";
763 foreach (ProjectNode project in solution.ProjectsTableOrder)
764 {
765 if (project.GenerateAssemblyInfoFile)
766 {
767 GenerateAssemblyInfoFile(solution, combFile);
768 }
769 }
770 }
771
772 private static void GenerateAssemblyInfoFile(SolutionNode solution, string combFile)
773 {
774 System.IO.Directory.CreateDirectory(Helper.MakePathRelativeTo(solution.FullPath, "Properties"));
775 combFile = Helper.MakeFilePath(solution.FullPath + "/Properties/", "AssemblyInfo.cs", "in");
776 StreamWriter ai = new StreamWriter(combFile);
777
778 using (ai)
779 {
780 ai.WriteLine("#region License");
781 ai.WriteLine("/*");
782 ai.WriteLine("MIT License");
783 ai.WriteLine("Copyright (c)2003-2006 Tao Framework Team");
784 ai.WriteLine("http://www.taoframework.com");
785 ai.WriteLine("All rights reserved.");
786 ai.WriteLine("");
787 ai.WriteLine("Permission is hereby granted, free of charge, to any person obtaining a copy");
788 ai.WriteLine("of this software and associated documentation files (the \"Software\"), to deal");
789 ai.WriteLine("in the Software without restriction, including without limitation the rights");
790 ai.WriteLine("to use, copy, modify, merge, publish, distribute, sublicense, and/or sell");
791 ai.WriteLine("copies of the Software, and to permit persons to whom the Software is");
792 ai.WriteLine("furnished to do so, subject to the following conditions:");
793 ai.WriteLine("");
794 ai.WriteLine("The above copyright notice and this permission notice shall be included in all");
795 ai.WriteLine("copies or substantial portions of the Software.");
796 ai.WriteLine("");
797 ai.WriteLine("THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR");
798 ai.WriteLine("IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,");
799 ai.WriteLine("FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE");
800 ai.WriteLine("AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER");
801 ai.WriteLine("LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,");
802 ai.WriteLine("OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE");
803 ai.WriteLine("SOFTWARE.");
804 ai.WriteLine("*/");
805 ai.WriteLine("#endregion License");
806 ai.WriteLine("");
807 ai.WriteLine("using System;");
808 ai.WriteLine("using System.Reflection;");
809 ai.WriteLine("using System.Runtime.InteropServices;");
810 ai.WriteLine("using System.Security;");
811 ai.WriteLine("using System.Security.Permissions;");
812 ai.WriteLine("");
813 ai.WriteLine("[assembly: AllowPartiallyTrustedCallers]");
814 ai.WriteLine("[assembly: AssemblyCompany(\"Tao Framework -- http://www.taoframework.com\")]");
815 ai.WriteLine("[assembly: AssemblyConfiguration(\"Retail\")]");
816 ai.WriteLine("[assembly: AssemblyCopyright(\"Copyright (c)2003-2006 Tao Framework Team. All rights reserved.\")]");
817 ai.WriteLine("[assembly: AssemblyCulture(\"\")]");
818 ai.WriteLine("[assembly: AssemblyDefaultAlias(\"@PACKAGE_NAME@\")]");
819 ai.WriteLine("[assembly: AssemblyDelaySign(false)]");
820 ai.WriteLine("[assembly: AssemblyDescription(\"@DESCRIPTION@\")]");
821 ai.WriteLine("[assembly: AssemblyFileVersion(\"@ASSEMBLY_VERSION@\")]");
822 ai.WriteLine("[assembly: AssemblyInformationalVersion(\"@ASSEMBLY_VERSION@\")]");
823 ai.WriteLine("[assembly: AssemblyKeyName(\"\")]");
824 ai.WriteLine("[assembly: AssemblyProduct(\"@PACKAGE_NAME@.dll\")]");
825 ai.WriteLine("[assembly: AssemblyTitle(\"@DESCRIPTION@\")]");
826 ai.WriteLine("[assembly: AssemblyTrademark(\"Tao Framework -- http://www.taoframework.com\")]");
827 ai.WriteLine("[assembly: AssemblyVersion(\"@ASSEMBLY_VERSION@\")]");
828 ai.WriteLine("[assembly: CLSCompliant(true)]");
829 ai.WriteLine("[assembly: ComVisible(false)]");
830 ai.WriteLine("[assembly: SecurityPermission(SecurityAction.RequestMinimum, Flags = SecurityPermissionFlag.Execution)]");
831 ai.WriteLine("[assembly: SecurityPermission(SecurityAction.RequestMinimum, Flags = SecurityPermissionFlag.SkipVerification)]");
832 ai.WriteLine("[assembly: SecurityPermission(SecurityAction.RequestMinimum, Flags = SecurityPermissionFlag.UnmanagedCode)]");
833
834 }
835 //return combFile;
836 }
837
838 private void CleanProject(ProjectNode project)
839 {
840 m_Kernel.Log.Write("...Cleaning project: {0}", project.Name);
841 string projectFile = Helper.MakeFilePath(project.FullPath, "Include", "am");
842 Helper.DeleteIfExists(projectFile);
843 }
844
845 private void CleanSolution(SolutionNode solution)
846 {
847 m_Kernel.Log.Write("Cleaning Autotools make files for", solution.Name);
848
849 string slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile", "am");
850 Helper.DeleteIfExists(slnFile);
851
852 slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile", "in");
853 Helper.DeleteIfExists(slnFile);
854
855 slnFile = Helper.MakeFilePath(solution.FullPath, "configure", "ac");
856 Helper.DeleteIfExists(slnFile);
857
858 slnFile = Helper.MakeFilePath(solution.FullPath, "configure");
859 Helper.DeleteIfExists(slnFile);
860
861 slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile");
862 Helper.DeleteIfExists(slnFile);
863
864 foreach(ProjectNode project in solution.Projects)
865 {
866 CleanProject(project);
867 }
868
869 m_Kernel.Log.Write("");
870 }
871
872 #endregion
873
874 #region ITarget Members
875
876 /// <summary>
877 /// Writes the specified kern.
878 /// </summary>
879 /// <param name="kern">The kern.</param>
880 public void Write(Kernel kern)
881 {
882 if( kern == null )
883 {
884 throw new ArgumentNullException("kern");
885 }
886 m_Kernel = kern;
887 foreach(SolutionNode solution in kern.Solutions)
888 {
889 WriteCombine(solution);
890 }
891 m_Kernel = null;
892 }
893
894 /// <summary>
895 /// Cleans the specified kern.
896 /// </summary>
897 /// <param name="kern">The kern.</param>
898 public virtual void Clean(Kernel kern)
899 {
900 if( kern == null )
901 {
902 throw new ArgumentNullException("kern");
903 }
904 m_Kernel = kern;
905 foreach(SolutionNode sol in kern.Solutions)
906 {
907 CleanSolution(sol);
908 }
909 m_Kernel = null;
910 }
911
912 /// <summary>
913 /// Gets the name.
914 /// </summary>
915 /// <value>The name.</value>
916 public string Name
917 {
918 get
919 {
920 return "autotools";
921 }
922 }
923
924 #endregion
925 }
926}
diff --git a/Prebuild/src/Core/Targets/DebugTarget.cs b/Prebuild/src/Core/Targets/DebugTarget.cs
new file mode 100644
index 0000000..6baa623
--- /dev/null
+++ b/Prebuild/src/Core/Targets/DebugTarget.cs
@@ -0,0 +1,102 @@
1#region BSD License
2/*
3Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com)
4
5Redistribution and use in source and binary forms, with or without modification, are permitted
6provided that the following conditions are met:
7
8* Redistributions of source code must retain the above copyright notice, this list of conditions
9 and the following disclaimer.
10* Redistributions in binary form must reproduce the above copyright notice, this list of conditions
11 and the following disclaimer in the documentation and/or other materials provided with the
12 distribution.
13* The name of the author may not be used to endorse or promote products derived from this software
14 without specific prior written permission.
15
16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
17BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
22IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23*/
24#endregion
25
26#region CVS Information
27/*
28 * $Source$
29 * $Author: jendave $
30 * $Date: 2006-09-20 09:42:51 +0200 (on, 20 sep 2006) $
31 * $Revision: 164 $
32 */
33#endregion
34
35using System;
36
37using Prebuild.Core.Attributes;
38using Prebuild.Core.Interfaces;
39using Prebuild.Core.Nodes;
40
41#if (DEBUG && _DEBUG_TARGET)
42namespace Prebuild.Core.Targets
43{
44 [Target("debug")]
45 public class DebugTarget : ITarget
46 {
47#region Fields
48
49 private Kernel m_Kernel = null;
50
51#endregion
52
53#region ITarget Members
54
55 public void Write()
56 {
57 foreach(SolutionNode s in m_Kernel.Solutions)
58 {
59 Console.WriteLine("Solution [ {0}, {1} ]", s.Name, s.Path);
60 foreach(string file in s.Files)
61{
62 Console.WriteLine("\tFile [ {0} ]", file);
63}
64
65 foreach(ProjectNode proj in s.Projects)
66 {
67 Console.WriteLine("\tProject [ {0}, {1}. {2} ]", proj.Name, proj.Path, proj.Language);
68 foreach(string file in proj.Files)
69 Console.WriteLine("\t\tFile [ {0} ]", file);
70 }
71 }
72 }
73
74 public void Clean()
75 {
76 Console.WriteLine("Not implemented");
77 }
78
79 public string Name
80 {
81 get
82 {
83 return "debug";
84 }
85 }
86
87 public Kernel Kernel
88 {
89 get
90 {
91 return m_Kernel;
92 }
93 set
94 {
95 m_Kernel = value;
96 }
97 }
98
99#endregion
100 }
101}
102#endif
diff --git a/Prebuild/src/Core/Targets/MonoDevelopTarget.cs b/Prebuild/src/Core/Targets/MonoDevelopTarget.cs
new file mode 100644
index 0000000..8620e4b
--- /dev/null
+++ b/Prebuild/src/Core/Targets/MonoDevelopTarget.cs
@@ -0,0 +1,458 @@
1#region BSD License
2/*
3Copyright (c) 2004 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com)
4
5Redistribution and use in source and binary forms, with or without modification, are permitted
6provided that the following conditions are met:
7
8* Redistributions of source code must retain the above copyright notice, this list of conditions
9 and the following disclaimer.
10* Redistributions in binary form must reproduce the above copyright notice, this list of conditions
11 and the following disclaimer in the documentation and/or other materials provided with the
12 distribution.
13* The name of the author may not be used to endorse or promote products derived from this software
14 without specific prior written permission.
15
16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
17BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
22IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23*/
24#endregion
25
26#region CVS Information
27/*
28 * $Source$
29 * $Author: jendave $
30 * $Date: 2007-02-13 22:07:07 +0100 (ti, 13 feb 2007) $
31 * $Revision: 206 $
32 */
33#endregion
34
35using System;
36using System.Collections;
37using System.Collections.Specialized;
38using System.IO;
39using System.Reflection;
40using System.Text.RegularExpressions;
41
42using Prebuild.Core.Attributes;
43using Prebuild.Core.Interfaces;
44using Prebuild.Core.Nodes;
45using Prebuild.Core.Utilities;
46
47namespace Prebuild.Core.Targets
48{
49 /// <summary>
50 ///
51 /// </summary>
52 [Target("monodev")]
53 public class MonoDevelopTarget : ITarget
54 {
55 #region Fields
56
57 private Kernel m_Kernel;
58
59 #endregion
60
61 #region Private Methods
62
63 private static string PrependPath(string path)
64 {
65 string tmpPath = Helper.NormalizePath(path, '/');
66 Regex regex = new Regex(@"(\w):/(\w+)");
67 Match match = regex.Match(tmpPath);
68 if(match.Success || tmpPath[0] == '.' || tmpPath[0] == '/')
69 {
70 tmpPath = Helper.NormalizePath(tmpPath);
71 }
72 else
73 {
74 tmpPath = Helper.NormalizePath("./" + tmpPath);
75 }
76
77 return tmpPath;
78 }
79
80 private static string BuildReference(SolutionNode solution, ReferenceNode refr)
81 {
82 string ret = "<ProjectReference type=\"";
83 if(solution.ProjectsTable.ContainsKey(refr.Name))
84 {
85 ret += "Project\"";
86 ret += " localcopy=\"" + refr.LocalCopy.ToString() + "\" refto=\"" + refr.Name + "\" />";
87 }
88 else
89 {
90 ProjectNode project = (ProjectNode)refr.Parent;
91 string fileRef = FindFileReference(refr.Name, project);
92
93 if(refr.Path != null || fileRef != null)
94 {
95 ret += "Assembly\" refto=\"";
96
97 string finalPath = (refr.Path != null) ? Helper.MakeFilePath(refr.Path, refr.Name, "dll") : fileRef;
98
99 ret += finalPath;
100 ret += "\" localcopy=\"" + refr.LocalCopy.ToString() + "\" />";
101 return ret;
102 }
103
104 ret += "Gac\"";
105 ret += " localcopy=\"" + refr.LocalCopy.ToString() + "\"";
106 ret += " refto=\"";
107 try
108 {
109 //Assembly assem = Assembly.Load(refr.Name);
110 //ret += assem.FullName;
111 ret += refr.Name;
112 }
113 catch (System.NullReferenceException e)
114 {
115 e.ToString();
116 ret += refr.Name;
117 }
118 ret += "\" />";
119 }
120
121 return ret;
122 }
123
124 private static string FindFileReference(string refName, ProjectNode project)
125 {
126 foreach(ReferencePathNode refPath in project.ReferencePaths)
127 {
128 string fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll");
129
130 if(File.Exists(fullPath))
131 {
132 return fullPath;
133 }
134 }
135
136 return null;
137 }
138
139 /// <summary>
140 /// Gets the XML doc file.
141 /// </summary>
142 /// <param name="project">The project.</param>
143 /// <param name="conf">The conf.</param>
144 /// <returns></returns>
145 public static string GenerateXmlDocFile(ProjectNode project, ConfigurationNode conf)
146 {
147 if( conf == null )
148 {
149 throw new ArgumentNullException("conf");
150 }
151 if( project == null )
152 {
153 throw new ArgumentNullException("project");
154 }
155 string docFile = (string)conf.Options["XmlDocFile"];
156 if(docFile != null && docFile.Length == 0)//default to assembly name if not specified
157 {
158 return "False";
159 }
160 return "True";
161 }
162
163 private void WriteProject(SolutionNode solution, ProjectNode project)
164 {
165 string csComp = "Mcs";
166 string netRuntime = "Mono";
167 if(project.Runtime == ClrRuntime.Microsoft)
168 {
169 csComp = "Csc";
170 netRuntime = "MsNet";
171 }
172
173 string projFile = Helper.MakeFilePath(project.FullPath, project.Name, "mdp");
174 StreamWriter ss = new StreamWriter(projFile);
175
176 m_Kernel.CurrentWorkingDirectory.Push();
177 Helper.SetCurrentDir(Path.GetDirectoryName(projFile));
178
179 using(ss)
180 {
181 ss.WriteLine(
182 "<Project name=\"{0}\" description=\"\" standardNamespace=\"{1}\" newfilesearch=\"None\" enableviewstate=\"True\" fileversion=\"2.0\" language=\"C#\" clr-version=\"Net_2_0\" ctype=\"DotNetProject\">",
183 project.Name,
184 project.RootNamespace
185 );
186
187 int count = 0;
188
189 ss.WriteLine(" <Configurations active=\"{0}\">", solution.ActiveConfig);
190
191 foreach(ConfigurationNode conf in project.Configurations)
192 {
193 ss.WriteLine(" <Configuration name=\"{0}\" ctype=\"DotNetProjectConfiguration\">", conf.Name);
194 ss.Write(" <Output");
195 ss.Write(" directory=\"{0}\"", Helper.EndPath(Helper.NormalizePath(".\\" + conf.Options["OutputPath"].ToString())));
196 ss.Write(" assembly=\"{0}\"", project.AssemblyName);
197 ss.Write(" executeScript=\"{0}\"", conf.Options["RunScript"]);
198 //ss.Write(" executeBeforeBuild=\"{0}\"", conf.Options["PreBuildEvent"]);
199 //ss.Write(" executeAfterBuild=\"{0}\"", conf.Options["PostBuildEvent"]);
200 if (conf.Options["PreBuildEvent"] != null && conf.Options["PreBuildEvent"].ToString().Length != 0)
201 {
202 ss.Write(" executeBeforeBuild=\"{0}\"", Helper.NormalizePath(conf.Options["PreBuildEvent"].ToString()));
203 }
204 else
205 {
206 ss.Write(" executeBeforeBuild=\"{0}\"", conf.Options["PreBuildEvent"]);
207 }
208 if (conf.Options["PostBuildEvent"] != null && conf.Options["PostBuildEvent"].ToString().Length != 0)
209 {
210 ss.Write(" executeAfterBuild=\"{0}\"", Helper.NormalizePath(conf.Options["PostBuildEvent"].ToString()));
211 }
212 else
213 {
214 ss.Write(" executeAfterBuild=\"{0}\"", conf.Options["PostBuildEvent"]);
215 }
216 ss.Write(" executeBeforeBuildArguments=\"{0}\"", conf.Options["PreBuildEventArgs"]);
217 ss.Write(" executeAfterBuildArguments=\"{0}\"", conf.Options["PreBuildEventArgs"]);
218 ss.WriteLine(" />");
219
220 ss.Write(" <Build");
221 ss.Write(" debugmode=\"True\"");
222 if (project.Type == ProjectType.WinExe)
223 {
224 ss.Write(" target=\"{0}\"", ProjectType.Exe.ToString());
225 }
226 else
227 {
228 ss.Write(" target=\"{0}\"", project.Type);
229 }
230 ss.WriteLine(" />");
231
232 ss.Write(" <Execution");
233 ss.Write(" runwithwarnings=\"True\"");
234 ss.Write(" consolepause=\"True\"");
235 ss.Write(" runtime=\"{0}\"", netRuntime);
236 ss.Write(" clr-version=\"Net_2_0\"");
237 ss.WriteLine(" />");
238
239 ss.Write(" <CodeGeneration");
240 ss.Write(" compiler=\"{0}\"", csComp);
241 ss.Write(" warninglevel=\"{0}\"", conf.Options["WarningLevel"]);
242 ss.Write(" nowarn=\"{0}\"", conf.Options["SuppressWarnings"]);
243 ss.Write(" includedebuginformation=\"{0}\"", conf.Options["DebugInformation"]);
244 ss.Write(" optimize=\"{0}\"", conf.Options["OptimizeCode"]);
245 ss.Write(" unsafecodeallowed=\"{0}\"", conf.Options["AllowUnsafe"]);
246 ss.Write(" generateoverflowchecks=\"{0}\"", conf.Options["CheckUnderflowOverflow"]);
247 ss.Write(" mainclass=\"{0}\"", project.StartupObject);
248 ss.Write(" target=\"{0}\"", project.Type);
249 ss.Write(" definesymbols=\"{0}\"", conf.Options["CompilerDefines"]);
250 ss.Write(" generatexmldocumentation=\"{0}\"", GenerateXmlDocFile(project, conf));
251 ss.Write(" win32Icon=\"{0}\"", project.AppIcon);
252 ss.Write(" ctype=\"CSharpCompilerParameters\"");
253 ss.WriteLine(" />");
254 ss.WriteLine(" </Configuration>");
255
256 count++;
257 }
258 ss.WriteLine(" </Configurations>");
259
260 ss.Write(" <DeploymentInformation");
261 ss.Write(" target=\"\"");
262 ss.Write(" script=\"\"");
263 ss.Write(" strategy=\"File\"");
264 ss.WriteLine(">");
265 ss.WriteLine(" <excludeFiles />");
266 ss.WriteLine(" </DeploymentInformation>");
267
268 ss.WriteLine(" <Contents>");
269 foreach(string file in project.Files)
270 {
271 string buildAction = "Compile";
272 switch(project.Files.GetBuildAction(file))
273 {
274 case BuildAction.None:
275 buildAction = "Nothing";
276 break;
277
278 case BuildAction.Content:
279 buildAction = "Exclude";
280 break;
281
282 case BuildAction.EmbeddedResource:
283 buildAction = "EmbedAsResource";
284 break;
285
286 default:
287 buildAction = "Compile";
288 break;
289 }
290
291 // Sort of a hack, we try and resolve the path and make it relative, if we can.
292 string filePath = PrependPath(file);
293 ss.WriteLine(" <File name=\"{0}\" subtype=\"Code\" buildaction=\"{1}\" dependson=\"\" data=\"\" />", filePath, buildAction);
294 }
295 ss.WriteLine(" </Contents>");
296
297 ss.WriteLine(" <References>");
298 foreach(ReferenceNode refr in project.References)
299 {
300 ss.WriteLine(" {0}", BuildReference(solution, refr));
301 }
302 ss.WriteLine(" </References>");
303
304
305 ss.WriteLine("</Project>");
306 }
307
308 m_Kernel.CurrentWorkingDirectory.Pop();
309 }
310
311 private void WriteCombine(SolutionNode solution)
312 {
313 m_Kernel.Log.Write("Creating MonoDevelop combine and project files");
314 foreach(ProjectNode project in solution.Projects)
315 {
316 if(m_Kernel.AllowProject(project.FilterGroups))
317 {
318 m_Kernel.Log.Write("...Creating project: {0}", project.Name);
319 WriteProject(solution, project);
320 }
321 }
322
323 m_Kernel.Log.Write("");
324 string combFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "mds");
325 StreamWriter ss = new StreamWriter(combFile);
326
327 m_Kernel.CurrentWorkingDirectory.Push();
328 Helper.SetCurrentDir(Path.GetDirectoryName(combFile));
329
330 int count = 0;
331
332 using(ss)
333 {
334 ss.WriteLine("<Combine name=\"{0}\" fileversion=\"2.0\" description=\"\">", solution.Name);
335
336 count = 0;
337 foreach(ConfigurationNode conf in solution.Configurations)
338 {
339 if(count == 0)
340 {
341 ss.WriteLine(" <Configurations active=\"{0}\">", conf.Name);
342 }
343
344 ss.WriteLine(" <Configuration name=\"{0}\" ctype=\"CombineConfiguration\">", conf.Name);
345 foreach(ProjectNode project in solution.Projects)
346 {
347 ss.WriteLine(" <Entry configuration=\"{1}\" build=\"True\" name=\"{0}\" />", project.Name, conf.Name);
348 }
349 ss.WriteLine(" </Configuration>");
350
351 count++;
352 }
353 ss.WriteLine(" </Configurations>");
354
355 count = 0;
356
357 foreach(ProjectNode project in solution.Projects)
358 {
359 if(count == 0)
360 ss.WriteLine(" <StartMode startupentry=\"{0}\" single=\"True\">", project.Name);
361
362 ss.WriteLine(" <Execute type=\"None\" entry=\"{0}\" />", project.Name);
363 count++;
364 }
365 ss.WriteLine(" </StartMode>");
366
367 ss.WriteLine(" <Entries>");
368 foreach(ProjectNode project in solution.Projects)
369 {
370 string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
371 ss.WriteLine(" <Entry filename=\"{0}\" />",
372 Helper.MakeFilePath(path, project.Name, "mdp"));
373 }
374 ss.WriteLine(" </Entries>");
375
376 ss.WriteLine("</Combine>");
377 }
378
379 m_Kernel.CurrentWorkingDirectory.Pop();
380 }
381
382 private void CleanProject(ProjectNode project)
383 {
384 m_Kernel.Log.Write("...Cleaning project: {0}", project.Name);
385 string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, "mdp");
386 Helper.DeleteIfExists(projectFile);
387 }
388
389 private void CleanSolution(SolutionNode solution)
390 {
391 m_Kernel.Log.Write("Cleaning MonoDevelop combine and project files for", solution.Name);
392
393 string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "mds");
394 Helper.DeleteIfExists(slnFile);
395
396 foreach(ProjectNode project in solution.Projects)
397 {
398 CleanProject(project);
399 }
400
401 m_Kernel.Log.Write("");
402 }
403
404 #endregion
405
406 #region ITarget Members
407
408 /// <summary>
409 /// Writes the specified kern.
410 /// </summary>
411 /// <param name="kern">The kern.</param>
412 public void Write(Kernel kern)
413 {
414 if( kern == null )
415 {
416 throw new ArgumentNullException("kern");
417 }
418 m_Kernel = kern;
419 foreach(SolutionNode solution in kern.Solutions)
420 {
421 WriteCombine(solution);
422 }
423 m_Kernel = null;
424 }
425
426 /// <summary>
427 /// Cleans the specified kern.
428 /// </summary>
429 /// <param name="kern">The kern.</param>
430 public virtual void Clean(Kernel kern)
431 {
432 if( kern == null )
433 {
434 throw new ArgumentNullException("kern");
435 }
436 m_Kernel = kern;
437 foreach(SolutionNode sol in kern.Solutions)
438 {
439 CleanSolution(sol);
440 }
441 m_Kernel = null;
442 }
443
444 /// <summary>
445 /// Gets the name.
446 /// </summary>
447 /// <value>The name.</value>
448 public string Name
449 {
450 get
451 {
452 return "sharpdev";
453 }
454 }
455
456 #endregion
457 }
458}
diff --git a/Prebuild/src/Core/Targets/NAntTarget.cs b/Prebuild/src/Core/Targets/NAntTarget.cs
new file mode 100644
index 0000000..bd366dc
--- /dev/null
+++ b/Prebuild/src/Core/Targets/NAntTarget.cs
@@ -0,0 +1,621 @@
1#region BSD License
2/*
3Copyright (c) 2004 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com)
4
5Redistribution and use in source and binary forms, with or without modification, are permitted
6provided that the following conditions are met:
7
8* Redistributions of source code must retain the above copyright notice, this list of conditions
9 and the following disclaimer.
10* Redistributions in binary form must reproduce the above copyright notice, this list of conditions
11 and the following disclaimer in the documentation and/or other materials provided with the
12 distribution.
13* The name of the author may not be used to endorse or promote products derived from this software
14 without specific prior written permission.
15
16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
17BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
22IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23*/
24#endregion
25
26#region CVS Information
27/*
28 * $Source$
29 * $Author: jendave $
30 * $Date: 2007-02-13 21:58:03 +0100 (ti, 13 feb 2007) $
31 * $Revision: 205 $
32 */
33#endregion
34
35using System;
36using System.Collections;
37using System.Collections.Specialized;
38using System.IO;
39using System.Reflection;
40using System.Text.RegularExpressions;
41
42using Prebuild.Core.Attributes;
43using Prebuild.Core.Interfaces;
44using Prebuild.Core.Nodes;
45using Prebuild.Core.Utilities;
46
47namespace Prebuild.Core.Targets
48{
49 /// <summary>
50 ///
51 /// </summary>
52 [Target("nant")]
53 public class NAntTarget : ITarget
54 {
55 #region Fields
56
57 private Kernel m_Kernel;
58
59 #endregion
60
61 #region Private Methods
62
63 private static string PrependPath(string path)
64 {
65 string tmpPath = Helper.NormalizePath(path, '/');
66 Regex regex = new Regex(@"(\w):/(\w+)");
67 Match match = regex.Match(tmpPath);
68 //if(match.Success || tmpPath[0] == '.' || tmpPath[0] == '/')
69 //{
70 tmpPath = Helper.NormalizePath(tmpPath);
71 //}
72// else
73// {
74// tmpPath = Helper.NormalizePath("./" + tmpPath);
75// }
76
77 return tmpPath;
78 }
79
80 private static string BuildReference(SolutionNode solution, ReferenceNode refr)
81 {
82 string ret = "";
83 if(solution.ProjectsTable.ContainsKey(refr.Name))
84 {
85 ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name];
86 string fileRef = FindFileReference(refr.Name, project);
87 string finalPath = Helper.NormalizePath(Helper.MakeFilePath(project.FullPath + "/${build.dir}/", refr.Name, "dll"), '/');
88 ret += finalPath;
89 return ret;
90 }
91 else
92 {
93 ProjectNode project = (ProjectNode)refr.Parent;
94 string fileRef = FindFileReference(refr.Name, project);
95
96 if(refr.Path != null || fileRef != null)
97 {
98 string finalPath = (refr.Path != null) ? Helper.NormalizePath(refr.Path + "/" + refr.Name + ".dll", '/') : fileRef;
99 ret += finalPath;
100 return ret;
101 }
102
103 try
104 {
105 //Assembly assem = Assembly.Load(refr.Name);
106 //if (assem != null)
107 //{
108 //ret += (refr.Name + ".dll");
109 //}
110 //else
111 //{
112 ret += (refr.Name + ".dll");
113 //}
114 }
115 catch (System.NullReferenceException e)
116 {
117 e.ToString();
118 ret += refr.Name + ".dll";
119 }
120 }
121 return ret;
122 }
123
124 private static string BuildReferencePath(SolutionNode solution, ReferenceNode refr)
125 {
126 string ret = "";
127 if(solution.ProjectsTable.ContainsKey(refr.Name))
128 {
129 ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name];
130 string fileRef = FindFileReference(refr.Name, project);
131 string finalPath = Helper.NormalizePath(Helper.MakeReferencePath(project.FullPath + "/${build.dir}/"), '/');
132 ret += finalPath;
133 return ret;
134 }
135 else
136 {
137 ProjectNode project = (ProjectNode)refr.Parent;
138 string fileRef = FindFileReference(refr.Name, project);
139
140 if(refr.Path != null || fileRef != null)
141 {
142 string finalPath = (refr.Path != null) ? Helper.NormalizePath(refr.Path, '/') : fileRef;
143 ret += finalPath;
144 return ret;
145 }
146
147 try
148 {
149 Assembly assem = Assembly.Load(refr.Name);
150 if (assem != null)
151 {
152 ret += "";
153 }
154 else
155 {
156 ret += "";
157 }
158 }
159 catch (System.NullReferenceException e)
160 {
161 e.ToString();
162 ret += "";
163 }
164 }
165 return ret;
166 }
167
168 private static string FindFileReference(string refName, ProjectNode project)
169 {
170 foreach(ReferencePathNode refPath in project.ReferencePaths)
171 {
172 string fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll");
173
174 if(File.Exists(fullPath))
175 {
176 return fullPath;
177 }
178 }
179
180 return null;
181 }
182
183 /// <summary>
184 /// Gets the XML doc file.
185 /// </summary>
186 /// <param name="project">The project.</param>
187 /// <param name="conf">The conf.</param>
188 /// <returns></returns>
189 public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf)
190 {
191 if( conf == null )
192 {
193 throw new ArgumentNullException("conf");
194 }
195 if( project == null )
196 {
197 throw new ArgumentNullException("project");
198 }
199 string docFile = (string)conf.Options["XmlDocFile"];
200 // if(docFile != null && docFile.Length == 0)//default to assembly name if not specified
201 // {
202 // return Path.GetFileNameWithoutExtension(project.AssemblyName) + ".xml";
203 // }
204 return docFile;
205 }
206
207 private void WriteProject(SolutionNode solution, ProjectNode project)
208 {
209 string projFile = Helper.MakeFilePath(project.FullPath, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build");
210 StreamWriter ss = new StreamWriter(projFile);
211
212 m_Kernel.CurrentWorkingDirectory.Push();
213 Helper.SetCurrentDir(Path.GetDirectoryName(projFile));
214 bool hasDoc = false;
215
216 using(ss)
217 {
218 ss.WriteLine("<?xml version=\"1.0\" ?>");
219 ss.WriteLine("<project name=\"{0}\" default=\"build\">", project.Name);
220 ss.WriteLine(" <target name=\"{0}\">", "build");
221 ss.WriteLine(" <echo message=\"Build Directory is ${project::get-base-directory()}/${build.dir}\" />");
222 ss.WriteLine(" <mkdir dir=\"${project::get-base-directory()}/${build.dir}\" />");
223 ss.WriteLine(" <copy todir=\"${project::get-base-directory()}/${build.dir}\">");
224 ss.WriteLine(" <fileset basedir=\"${project::get-base-directory()}\">");
225 foreach(ReferenceNode refr in project.References)
226 {
227 if (refr.LocalCopy)
228 {
229 ss.WriteLine(" <include name=\"{0}", Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReference(solution, refr))+"\" />", '/'));
230 }
231 }
232 ss.WriteLine(" </fileset>");
233 ss.WriteLine(" </copy>");
234 ss.Write(" <csc");
235 ss.Write(" target=\"{0}\"", project.Type.ToString().ToLower());
236 ss.Write(" debug=\"{0}\"", "${build.debug}");
237 foreach(ConfigurationNode conf in project.Configurations)
238 {
239 if (conf.Options.KeyFile !="")
240 {
241 ss.Write(" keyfile=\"{0}\"", conf.Options.KeyFile);
242 break;
243 }
244 }
245 foreach(ConfigurationNode conf in project.Configurations)
246 {
247 ss.Write(" unsafe=\"{0}\"", conf.Options.AllowUnsafe);
248 break;
249 }
250 foreach(ConfigurationNode conf in project.Configurations)
251 {
252 ss.Write(" define=\"{0}\"", conf.Options.CompilerDefines);
253 break;
254 }
255 foreach(ConfigurationNode conf in project.Configurations)
256 {
257 if (GetXmlDocFile(project, conf) !="")
258 {
259 ss.Write(" doc=\"{0}\"", "${project::get-base-directory()}/${build.dir}/" + GetXmlDocFile(project, conf));
260 hasDoc = true;
261 }
262 break;
263 }
264 ss.Write(" output=\"{0}", "${project::get-base-directory()}/${build.dir}/${project::get-name()}");
265 if (project.Type == ProjectType.Library)
266 {
267 ss.Write(".dll\"");
268 }
269 else
270 {
271 ss.Write(".exe\"");
272 }
273 if(project.AppIcon != null && project.AppIcon.Length != 0)
274 {
275 ss.Write(" win32icon=\"{0}\"", Helper.NormalizePath(project.AppIcon,'/'));
276 }
277 ss.WriteLine(">");
278 ss.WriteLine(" <resources prefix=\"{0}\" dynamicprefix=\"true\" >", project.RootNamespace);
279 foreach (string file in project.Files)
280 {
281 switch (project.Files.GetBuildAction(file))
282 {
283 case BuildAction.EmbeddedResource:
284 ss.WriteLine(" {0}", "<include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />");
285 break;
286 default:
287 if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings)
288 {
289 ss.WriteLine(" <include name=\"{0}\" />", file.Substring(0, file.LastIndexOf('.')) + ".resx");
290 }
291 break;
292 }
293 }
294 //if (project.Files.GetSubType(file).ToString() != "Code")
295 //{
296 // ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".resx");
297
298 ss.WriteLine(" </resources>");
299 ss.WriteLine(" <sources failonempty=\"true\">");
300 foreach(string file in project.Files)
301 {
302 switch(project.Files.GetBuildAction(file))
303 {
304 case BuildAction.Compile:
305 ss.WriteLine(" <include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />");
306 break;
307 default:
308 break;
309 }
310 }
311 ss.WriteLine(" </sources>");
312 ss.WriteLine(" <references basedir=\"${project::get-base-directory()}\">");
313 ss.WriteLine(" <lib>");
314 ss.WriteLine(" <include name=\"${project::get-base-directory()}\" />");
315 ss.WriteLine(" <include name=\"${project::get-base-directory()}/${build.dir}\" />");
316 ss.WriteLine(" </lib>");
317 foreach(ReferenceNode refr in project.References)
318 {
319 ss.WriteLine(" <include name=\"{0}", Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReference(solution, refr))+"\" />", '/'));
320 }
321 ss.WriteLine(" </references>");
322
323 ss.WriteLine(" </csc>");
324
325 foreach (ConfigurationNode conf in project.Configurations)
326 {
327 if (!String.IsNullOrEmpty(conf.Options.OutputPath))
328 {
329 string targetDir = Helper.NormalizePath(conf.Options.OutputPath, '/');
330
331 ss.WriteLine(" <echo message=\"Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/" + targetDir + "\" />");
332
333 ss.WriteLine(" <mkdir dir=\"${project::get-base-directory()}/" + targetDir + "\"/>");
334
335 ss.WriteLine(" <copy todir=\"${project::get-base-directory()}/" + targetDir + "\">");
336 ss.WriteLine(" <fileset basedir=\"${project::get-base-directory()}/${build.dir}/\" >");
337 ss.WriteLine(" <include name=\"*.dll\"/>");
338 ss.WriteLine(" <include name=\"*.exe\"/>");
339 ss.WriteLine(" </fileset>");
340 ss.WriteLine(" </copy>");
341 break;
342 }
343 }
344
345 ss.WriteLine(" </target>");
346
347 ss.WriteLine(" <target name=\"clean\">");
348 ss.WriteLine(" <delete dir=\"${bin.dir}\" failonerror=\"false\" />");
349 ss.WriteLine(" <delete dir=\"${obj.dir}\" failonerror=\"false\" />");
350 ss.WriteLine(" </target>");
351
352 ss.WriteLine(" <target name=\"doc\" description=\"Creates documentation.\">");
353 if (hasDoc)
354 {
355 ss.WriteLine(" <property name=\"doc.target\" value=\"\" />");
356 ss.WriteLine(" <if test=\"${platform::is-unix()}\">");
357 ss.WriteLine(" <property name=\"doc.target\" value=\"Web\" />");
358 ss.WriteLine(" </if>");
359 ss.WriteLine(" <ndoc failonerror=\"false\" verbose=\"true\">");
360 ss.WriteLine(" <assemblies basedir=\"${project::get-base-directory()}\">");
361 ss.Write(" <include name=\"${build.dir}/${project::get-name()}");
362 if (project.Type == ProjectType.Library)
363 {
364 ss.WriteLine(".dll\" />");
365 }
366 else
367 {
368 ss.WriteLine(".exe\" />");
369 }
370
371 ss.WriteLine(" </assemblies>");
372 ss.WriteLine(" <summaries basedir=\"${project::get-base-directory()}\">");
373 ss.WriteLine(" <include name=\"${build.dir}/${project::get-name()}.xml\"/>");
374 ss.WriteLine(" </summaries>");
375 ss.WriteLine(" <referencepaths basedir=\"${project::get-base-directory()}\">");
376 ss.WriteLine(" <include name=\"${build.dir}\" />");
377 // foreach(ReferenceNode refr in project.References)
378 // {
379 // string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReferencePath(solution, refr)), '/');
380 // if (path != "")
381 // {
382 // ss.WriteLine(" <include name=\"{0}\" />", path);
383 // }
384 // }
385 ss.WriteLine(" </referencepaths>");
386 ss.WriteLine(" <documenters>");
387 ss.WriteLine(" <documenter name=\"MSDN\">");
388 ss.WriteLine(" <property name=\"OutputDirectory\" value=\"${project::get-base-directory()}/${build.dir}/doc/${project::get-name()}\" />");
389 ss.WriteLine(" <property name=\"OutputTarget\" value=\"${doc.target}\" />");
390 ss.WriteLine(" <property name=\"HtmlHelpName\" value=\"${project::get-name()}\" />");
391 ss.WriteLine(" <property name=\"IncludeFavorites\" value=\"False\" />");
392 ss.WriteLine(" <property name=\"Title\" value=\"${project::get-name()} SDK Documentation\" />");
393 ss.WriteLine(" <property name=\"SplitTOCs\" value=\"False\" />");
394 ss.WriteLine(" <property name=\"DefaulTOC\" value=\"\" />");
395 ss.WriteLine(" <property name=\"ShowVisualBasic\" value=\"True\" />");
396 ss.WriteLine(" <property name=\"AutoDocumentConstructors\" value=\"True\" />");
397 ss.WriteLine(" <property name=\"ShowMissingSummaries\" value=\"${build.debug}\" />");
398 ss.WriteLine(" <property name=\"ShowMissingRemarks\" value=\"${build.debug}\" />");
399 ss.WriteLine(" <property name=\"ShowMissingParams\" value=\"${build.debug}\" />");
400 ss.WriteLine(" <property name=\"ShowMissingReturns\" value=\"${build.debug}\" />");
401 ss.WriteLine(" <property name=\"ShowMissingValues\" value=\"${build.debug}\" />");
402 ss.WriteLine(" <property name=\"DocumentInternals\" value=\"False\" />");
403 ss.WriteLine(" <property name=\"DocumentPrivates\" value=\"False\" />");
404 ss.WriteLine(" <property name=\"DocumentProtected\" value=\"True\" />");
405 ss.WriteLine(" <property name=\"DocumentEmptyNamespaces\" value=\"${build.debug}\" />");
406 ss.WriteLine(" <property name=\"IncludeAssemblyVersion\" value=\"True\" />");
407 ss.WriteLine(" </documenter>");
408 ss.WriteLine(" </documenters>");
409 ss.WriteLine(" </ndoc>");
410 }
411 ss.WriteLine(" </target>");
412 ss.WriteLine("</project>");
413 }
414 m_Kernel.CurrentWorkingDirectory.Pop();
415 }
416
417 private void WriteCombine(SolutionNode solution)
418 {
419 m_Kernel.Log.Write("Creating NAnt build files");
420 foreach(ProjectNode project in solution.Projects)
421 {
422 if(m_Kernel.AllowProject(project.FilterGroups))
423 {
424 m_Kernel.Log.Write("...Creating project: {0}", project.Name);
425 WriteProject(solution, project);
426 }
427 }
428
429 m_Kernel.Log.Write("");
430 string combFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "build");
431 StreamWriter ss = new StreamWriter(combFile);
432
433 m_Kernel.CurrentWorkingDirectory.Push();
434 Helper.SetCurrentDir(Path.GetDirectoryName(combFile));
435
436 using(ss)
437 {
438 ss.WriteLine("<?xml version=\"1.0\" ?>");
439 ss.WriteLine("<project name=\"{0}\" default=\"build\">", solution.Name);
440 ss.WriteLine(" <echo message=\"Using '${nant.settings.currentframework}' Framework\"/>");
441 ss.WriteLine();
442
443 //ss.WriteLine(" <property name=\"dist.dir\" value=\"dist\" />");
444 //ss.WriteLine(" <property name=\"source.dir\" value=\"source\" />");
445 ss.WriteLine(" <property name=\"bin.dir\" value=\"bin\" />");
446 ss.WriteLine(" <property name=\"obj.dir\" value=\"obj\" />");
447 ss.WriteLine(" <property name=\"doc.dir\" value=\"doc\" />");
448 ss.WriteLine(" <property name=\"project.main.dir\" value=\"${project::get-base-directory()}\" />");
449
450 foreach(ConfigurationNode conf in solution.Configurations)
451 {
452 // Set the project.config to a non-debug configuration
453 if( conf.Options["DebugInformation"].ToString().ToLower() != "true" )
454 {
455 ss.WriteLine(" <property name=\"project.config\" value=\"{0}\" />", conf.Name);
456 }
457 ss.WriteLine();
458 ss.WriteLine(" <target name=\"{0}\" description=\"\">", conf.Name);
459 ss.WriteLine(" <property name=\"project.config\" value=\"{0}\" />", conf.Name);
460 ss.WriteLine(" <property name=\"build.debug\" value=\"{0}\" />", conf.Options["DebugInformation"].ToString().ToLower());
461 ss.WriteLine(" </target>");
462 ss.WriteLine();
463 }
464
465 ss.WriteLine(" <target name=\"net-1.1\" description=\"Sets framework to .NET 1.1\">");
466 ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"net-1.1\" />");
467 ss.WriteLine(" </target>");
468 ss.WriteLine();
469
470 ss.WriteLine(" <target name=\"net-2.0\" description=\"Sets framework to .NET 2.0\">");
471 ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"net-2.0\" />");
472 ss.WriteLine(" </target>");
473 ss.WriteLine();
474
475 ss.WriteLine(" <target name=\"mono-2.0\" description=\"Sets framework to mono 2.0\">");
476 ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"mono-2.0\" />");
477 ss.WriteLine(" </target>");
478 ss.WriteLine();
479
480 ss.WriteLine(" <target name=\"mono-1.0\" description=\"Sets framework to mono 1.0\">");
481 ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"mono-1.0\" />");
482 ss.WriteLine(" </target>");
483 ss.WriteLine();
484
485 ss.WriteLine(" <target name=\"init\" description=\"\">");
486 ss.WriteLine(" <call target=\"${project.config}\" />");
487 ss.WriteLine(" <sysinfo />");
488 ss.WriteLine(" <echo message=\"Platform ${sys.os.platform}\" />");
489 ss.WriteLine(" <property name=\"build.dir\" value=\"${bin.dir}/${project.config}\" />");
490 ss.WriteLine(" </target>");
491 ss.WriteLine();
492
493 ss.WriteLine(" <target name=\"clean\" description=\"\">");
494 ss.WriteLine(" <echo message=\"Deleting all builds from all configurations\" />");
495 //ss.WriteLine(" <delete dir=\"${dist.dir}\" failonerror=\"false\" />");
496 ss.WriteLine(" <delete dir=\"${bin.dir}\" failonerror=\"false\" />");
497 ss.WriteLine(" <delete dir=\"${obj.dir}\" failonerror=\"false\" />");
498 foreach(ProjectNode project in solution.Projects)
499 {
500 string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
501 ss.Write(" <nant buildfile=\"{0}\"",
502 Helper.NormalizePath(Helper.MakeFilePath(path, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build"),'/'));
503 ss.WriteLine(" target=\"clean\" />");
504 }
505 ss.WriteLine(" </target>");
506 ss.WriteLine();
507
508 ss.WriteLine(" <target name=\"build\" depends=\"init\" description=\"\">");
509
510 foreach(ProjectNode project in solution.ProjectsTableOrder)
511 {
512 string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
513 ss.Write(" <nant buildfile=\"{0}\"",
514 Helper.NormalizePath(Helper.MakeFilePath(path, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build"),'/'));
515 ss.WriteLine(" target=\"build\" />");
516 }
517 ss.WriteLine(" </target>");
518 ss.WriteLine();
519
520 ss.WriteLine(" <target name=\"build-release\" depends=\"Release, init, build\" description=\"Builds in Release mode\" />");
521 ss.WriteLine();
522 ss.WriteLine(" <target name=\"build-debug\" depends=\"Debug, init, build\" description=\"Builds in Debug mode\" />");
523 ss.WriteLine();
524 //ss.WriteLine(" <target name=\"package\" depends=\"clean, doc, copyfiles, zip\" description=\"Builds in Release mode\" />");
525 ss.WriteLine(" <target name=\"package\" depends=\"clean, doc\" description=\"Builds all\" />");
526 ss.WriteLine();
527
528 ss.WriteLine(" <target name=\"doc\" depends=\"build-release\">");
529 ss.WriteLine(" <echo message=\"Generating all documentation from all builds\" />");
530 foreach (ProjectNode project in solution.Projects)
531 {
532 string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
533 ss.Write(" <nant buildfile=\"{0}\"",
534 Helper.NormalizePath(Helper.MakeFilePath(path, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build"), '/'));
535 ss.WriteLine(" target=\"doc\" />");
536 }
537 ss.WriteLine(" </target>");
538 ss.WriteLine();
539 ss.WriteLine("</project>");
540 }
541
542 m_Kernel.CurrentWorkingDirectory.Pop();
543 }
544
545 private void CleanProject(ProjectNode project)
546 {
547 m_Kernel.Log.Write("...Cleaning project: {0}", project.Name);
548 string projectFile = Helper.MakeFilePath(project.FullPath, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build");
549 Helper.DeleteIfExists(projectFile);
550 }
551
552 private void CleanSolution(SolutionNode solution)
553 {
554 m_Kernel.Log.Write("Cleaning NAnt build files for", solution.Name);
555
556 string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "build");
557 Helper.DeleteIfExists(slnFile);
558
559 foreach(ProjectNode project in solution.Projects)
560 {
561 CleanProject(project);
562 }
563
564 m_Kernel.Log.Write("");
565 }
566
567 #endregion
568
569 #region ITarget Members
570
571 /// <summary>
572 /// Writes the specified kern.
573 /// </summary>
574 /// <param name="kern">The kern.</param>
575 public void Write(Kernel kern)
576 {
577 if( kern == null )
578 {
579 throw new ArgumentNullException("kern");
580 }
581 m_Kernel = kern;
582 foreach(SolutionNode solution in kern.Solutions)
583 {
584 WriteCombine(solution);
585 }
586 m_Kernel = null;
587 }
588
589 /// <summary>
590 /// Cleans the specified kern.
591 /// </summary>
592 /// <param name="kern">The kern.</param>
593 public virtual void Clean(Kernel kern)
594 {
595 if( kern == null )
596 {
597 throw new ArgumentNullException("kern");
598 }
599 m_Kernel = kern;
600 foreach(SolutionNode sol in kern.Solutions)
601 {
602 CleanSolution(sol);
603 }
604 m_Kernel = null;
605 }
606
607 /// <summary>
608 /// Gets the name.
609 /// </summary>
610 /// <value>The name.</value>
611 public string Name
612 {
613 get
614 {
615 return "nant";
616 }
617 }
618
619 #endregion
620 }
621}
diff --git a/Prebuild/src/Core/Targets/SharpDevelop2Target.cs b/Prebuild/src/Core/Targets/SharpDevelop2Target.cs
new file mode 100644
index 0000000..bc84b96
--- /dev/null
+++ b/Prebuild/src/Core/Targets/SharpDevelop2Target.cs
@@ -0,0 +1,90 @@
1#region BSD License
2/*
3Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com)
4
5Redistribution and use in source and binary forms, with or without modification, are permitted
6provided that the following conditions are met:
7
8* Redistributions of source code must retain the above copyright notice, this list of conditions
9 and the following disclaimer.
10* Redistributions in binary form must reproduce the above copyright notice, this list of conditions
11 and the following disclaimer in the documentation and/or other materials provided with the
12 distribution.
13* The name of the author may not be used to endorse or promote products derived from this software
14 without specific prior written permission.
15
16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
17BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
22IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23*/
24#endregion
25
26#region CVS Information
27/*
28 * $Source$
29 * $Author: jendave $
30 * $Date: 2006-01-27 16:49:58 -0800 (Fri, 27 Jan 2006) $
31 * $Revision: 71 $
32 */
33#endregion
34
35using System;
36
37using Prebuild.Core.Attributes;
38
39namespace Prebuild.Core.Targets
40{
41 /// <summary>
42 ///
43 /// </summary>
44 [Target("sharpdev2")]
45 public class SharpDevelop2Target : VS2005Target
46 {
47 #region Private Methods
48 private void SetSharpDevelop2()
49 {
50 this.VersionName = "SharpDevelop2";
51 }
52 #endregion
53
54 #region Public Methods
55
56 /// <summary>
57 /// Writes the specified kern.
58 /// </summary>
59 /// <param name="kern">The kern.</param>
60 public override void Write(Kernel kern)
61 {
62 SetSharpDevelop2();
63 base.Write(kern);
64 }
65
66 /// <summary>
67 /// Cleans the specified kern.
68 /// </summary>
69 /// <param name="kern">The kern.</param>
70 public override void Clean(Kernel kern)
71 {
72 SetSharpDevelop2();
73 base.Clean(kern);
74 }
75
76 /// <summary>
77 /// Gets the name.
78 /// </summary>
79 /// <value>The name.</value>
80 public override string Name
81 {
82 get
83 {
84 return "sharpdev2";
85 }
86 }
87
88 #endregion
89 }
90}
diff --git a/Prebuild/src/Core/Targets/SharpDevelopTarget.cs b/Prebuild/src/Core/Targets/SharpDevelopTarget.cs
new file mode 100644
index 0000000..c725730
--- /dev/null
+++ b/Prebuild/src/Core/Targets/SharpDevelopTarget.cs
@@ -0,0 +1,437 @@
1#region BSD License
2/*
3Copyright (c) 2004 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com)
4
5Redistribution and use in source and binary forms, with or without modification, are permitted
6provided that the following conditions are met:
7
8* Redistributions of source code must retain the above copyright notice, this list of conditions
9 and the following disclaimer.
10* Redistributions in binary form must reproduce the above copyright notice, this list of conditions
11 and the following disclaimer in the documentation and/or other materials provided with the
12 distribution.
13* The name of the author may not be used to endorse or promote products derived from this software
14 without specific prior written permission.
15
16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
17BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
22IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23*/
24#endregion
25
26#region CVS Information
27/*
28 * $Source$
29 * $Author: jendave $
30 * $Date: 2007-02-13 21:58:03 +0100 (ti, 13 feb 2007) $
31 * $Revision: 205 $
32 */
33#endregion
34
35using System;
36using System.Collections;
37using System.Collections.Specialized;
38using System.IO;
39using System.Text.RegularExpressions;
40using System.Reflection;
41
42using Prebuild.Core.Attributes;
43using Prebuild.Core.Interfaces;
44using Prebuild.Core.Nodes;
45using Prebuild.Core.Utilities;
46
47namespace Prebuild.Core.Targets
48{
49 /// <summary>
50 ///
51 /// </summary>
52 [Target("sharpdev")]
53 public class SharpDevelopTarget : ITarget
54 {
55 #region Fields
56
57 private Kernel m_Kernel;
58
59 #endregion
60
61 #region Private Methods
62
63 private static string PrependPath(string path)
64 {
65 string tmpPath = Helper.NormalizePath(path, '/');
66 Regex regex = new Regex(@"(\w):/(\w+)");
67 Match match = regex.Match(tmpPath);
68 if(match.Success || tmpPath[0] == '.' || tmpPath[0] == '/')
69 {
70 tmpPath = Helper.NormalizePath(tmpPath);
71 }
72 else
73 {
74 tmpPath = Helper.NormalizePath("./" + tmpPath);
75 }
76
77 return tmpPath;
78 }
79
80 private static string BuildReference(SolutionNode solution, ReferenceNode refr)
81 {
82 string ret = "<Reference type=\"";
83 if(solution.ProjectsTable.ContainsKey(refr.Name))
84 {
85 ret += "Project\" refto=\"" + refr.Name;
86 ret += "\" localcopy=\"" + refr.LocalCopy.ToString() + "\" />";
87 }
88 else
89 {
90 ProjectNode project = (ProjectNode)refr.Parent;
91 string fileRef = FindFileReference(refr.Name, project);
92
93 if(refr.Path != null || fileRef != null)
94 {
95 ret += "Assembly\" refto=\"";
96
97 string finalPath = (refr.Path != null) ? Helper.MakeFilePath(refr.Path, refr.Name, "dll") : fileRef;
98
99 ret += finalPath;
100 ret += "\" localcopy=\"" + refr.LocalCopy.ToString() + "\" />";
101 return ret;
102 }
103
104 ret += "Gac\" refto=\"";
105 try
106 {
107 //Assembly assem = Assembly.Load(refr.Name);
108 ret += refr.Name;// assem.FullName;
109 }
110 catch (System.NullReferenceException e)
111 {
112 e.ToString();
113 ret += refr.Name;
114 }
115 ret += "\" localcopy=\"" + refr.LocalCopy.ToString() + "\" />";
116 }
117
118 return ret;
119 }
120
121 private static string FindFileReference(string refName, ProjectNode project)
122 {
123 foreach(ReferencePathNode refPath in project.ReferencePaths)
124 {
125 string fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll");
126
127 if(File.Exists(fullPath))
128 {
129 return fullPath;
130 }
131 }
132
133 return null;
134 }
135
136 /// <summary>
137 /// Gets the XML doc file.
138 /// </summary>
139 /// <param name="project">The project.</param>
140 /// <param name="conf">The conf.</param>
141 /// <returns></returns>
142 public static string GenerateXmlDocFile(ProjectNode project, ConfigurationNode conf)
143 {
144 if( conf == null )
145 {
146 throw new ArgumentNullException("conf");
147 }
148 if( project == null )
149 {
150 throw new ArgumentNullException("project");
151 }
152 string docFile = (string)conf.Options["XmlDocFile"];
153 if(docFile != null && docFile.Length == 0)//default to assembly name if not specified
154 {
155 return "False";
156 }
157 return "True";
158 }
159
160 private void WriteProject(SolutionNode solution, ProjectNode project)
161 {
162 string csComp = "Csc";
163 string netRuntime = "MsNet";
164 if(project.Runtime == ClrRuntime.Mono)
165 {
166 csComp = "Mcs";
167 netRuntime = "Mono";
168 }
169
170 string projFile = Helper.MakeFilePath(project.FullPath, project.Name, "prjx");
171 StreamWriter ss = new StreamWriter(projFile);
172
173 m_Kernel.CurrentWorkingDirectory.Push();
174 Helper.SetCurrentDir(Path.GetDirectoryName(projFile));
175
176 using(ss)
177 {
178 ss.WriteLine(
179 "<Project name=\"{0}\" standardNamespace=\"{1}\" description=\"\" newfilesearch=\"None\" enableviewstate=\"True\" version=\"1.1\" projecttype=\"C#\">",
180 project.Name,
181 project.RootNamespace
182 );
183
184 ss.WriteLine(" <Contents>");
185 foreach(string file in project.Files)
186 {
187 string buildAction = "Compile";
188 switch(project.Files.GetBuildAction(file))
189 {
190 case BuildAction.None:
191 buildAction = "Nothing";
192 break;
193
194 case BuildAction.Content:
195 buildAction = "Exclude";
196 break;
197
198 case BuildAction.EmbeddedResource:
199 buildAction = "EmbedAsResource";
200 break;
201
202 default:
203 buildAction = "Compile";
204 break;
205 }
206
207 // Sort of a hack, we try and resolve the path and make it relative, if we can.
208 string filePath = PrependPath(file);
209 ss.WriteLine(" <File name=\"{0}\" subtype=\"Code\" buildaction=\"{1}\" dependson=\"\" data=\"\" />", filePath, buildAction);
210 }
211 ss.WriteLine(" </Contents>");
212
213 ss.WriteLine(" <References>");
214 foreach(ReferenceNode refr in project.References)
215 {
216 ss.WriteLine(" {0}", BuildReference(solution, refr));
217 }
218 ss.WriteLine(" </References>");
219
220 ss.Write(" <DeploymentInformation");
221 ss.Write(" target=\"\"");
222 ss.Write(" script=\"\"");
223 ss.Write(" strategy=\"File\"");
224 ss.WriteLine(" />");
225
226 int count = 0;
227
228 ss.WriteLine(" <Configurations active=\"{0}\">", solution.ActiveConfig);
229
230 foreach(ConfigurationNode conf in project.Configurations)
231 {
232 ss.Write(" <Configuration");
233 ss.Write(" runwithwarnings=\"True\"");
234 ss.Write(" name=\"{0}\"", conf.Name);
235 ss.WriteLine(">");
236 ss.Write(" <CodeGeneration");
237 ss.Write(" runtime=\"{0}\"", netRuntime);
238 ss.Write(" compiler=\"{0}\"", csComp);
239 ss.Write(" compilerversion=\"\"");
240 ss.Write(" warninglevel=\"{0}\"", conf.Options["WarningLevel"]);
241 ss.Write(" nowarn=\"{0}\"", conf.Options["SuppressWarnings"]);
242 ss.Write(" includedebuginformation=\"{0}\"", conf.Options["DebugInformation"]);
243 ss.Write(" optimize=\"{0}\"", conf.Options["OptimizeCode"]);
244 ss.Write(" unsafecodeallowed=\"{0}\"", conf.Options["AllowUnsafe"]);
245 ss.Write(" generateoverflowchecks=\"{0}\"", conf.Options["CheckUnderflowOverflow"]);
246 ss.Write(" mainclass=\"{0}\"", project.StartupObject);
247 ss.Write(" target=\"{0}\"", project.Type);
248 ss.Write(" definesymbols=\"{0}\"", conf.Options["CompilerDefines"]);
249 ss.Write(" generatexmldocumentation=\"{0}\"", GenerateXmlDocFile(project, conf));
250 ss.Write(" win32Icon=\"{0}\"", Helper.NormalizePath(".\\" + project.AppIcon));
251 ss.Write(" noconfig=\"{0}\"", "False");
252 ss.Write(" nostdlib=\"{0}\"", conf.Options["NoStdLib"]);
253 ss.WriteLine(" />");
254
255 ss.Write(" <Execution");
256 ss.Write(" commandlineparameters=\"\"");
257 ss.Write(" consolepause=\"True\"");
258 ss.WriteLine(" />");
259
260 ss.Write(" <Output");
261 ss.Write(" directory=\".\\{0}\"", Helper.NormalizePath(conf.Options["OutputPath"].ToString()));
262 ss.Write(" assembly=\"{0}\"", project.AssemblyName);
263 ss.Write(" executeScript=\"{0}\"", conf.Options["RunScript"]);
264 if (conf.Options["PreBuildEvent"] != null && conf.Options["PreBuildEvent"].ToString().Length != 0)
265 {
266 ss.Write(" executeBeforeBuild=\"{0}\"", Helper.NormalizePath(conf.Options["PreBuildEvent"].ToString()));
267 }
268 else
269 {
270 ss.Write(" executeBeforeBuild=\"{0}\"", conf.Options["PreBuildEvent"]);
271 }
272 if (conf.Options["PostBuildEvent"] != null && conf.Options["PostBuildEvent"].ToString().Length != 0)
273 {
274 ss.Write(" executeAfterBuild=\"{0}\"", Helper.NormalizePath(conf.Options["PostBuildEvent"].ToString()));
275 }
276 else
277 {
278 ss.Write(" executeAfterBuild=\"{0}\"", conf.Options["PostBuildEvent"]);
279 }
280 ss.Write(" executeBeforeBuildArguments=\"{0}\"", conf.Options["PreBuildEventArgs"]);
281 ss.Write(" executeAfterBuildArguments=\"{0}\"", conf.Options["PreBuildEventArgs"]);
282 ss.WriteLine(" />");
283 ss.WriteLine(" </Configuration>");
284
285 count++;
286 }
287 ss.WriteLine(" </Configurations>");
288 ss.WriteLine("</Project>");
289 }
290
291 m_Kernel.CurrentWorkingDirectory.Pop();
292 }
293
294 private void WriteCombine(SolutionNode solution)
295 {
296 m_Kernel.Log.Write("Creating SharpDevelop combine and project files");
297 foreach(ProjectNode project in solution.Projects)
298 {
299 if(m_Kernel.AllowProject(project.FilterGroups))
300 {
301 m_Kernel.Log.Write("...Creating project: {0}", project.Name);
302 WriteProject(solution, project);
303 }
304 }
305
306 m_Kernel.Log.Write("");
307 string combFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "cmbx");
308 StreamWriter ss = new StreamWriter(combFile);
309
310 m_Kernel.CurrentWorkingDirectory.Push();
311 Helper.SetCurrentDir(Path.GetDirectoryName(combFile));
312
313 using(ss)
314 {
315 ss.WriteLine("<Combine fileversion=\"1.0\" name=\"{0}\" description=\"\">", solution.Name);
316
317 int count = 0;
318 foreach(ProjectNode project in solution.Projects)
319 {
320 if(count == 0)
321 ss.WriteLine(" <StartMode startupentry=\"{0}\" single=\"True\">", project.Name);
322
323 ss.WriteLine(" <Execute entry=\"{0}\" type=\"None\" />", project.Name);
324 count++;
325 }
326 ss.WriteLine(" </StartMode>");
327
328 ss.WriteLine(" <Entries>");
329 foreach(ProjectNode project in solution.Projects)
330 {
331 string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
332 ss.WriteLine(" <Entry filename=\"{0}\" />",
333 Helper.MakeFilePath(path, project.Name, "prjx"));
334 }
335 ss.WriteLine(" </Entries>");
336
337 count = 0;
338 foreach(ConfigurationNode conf in solution.Configurations)
339 {
340 if(count == 0)
341 {
342 ss.WriteLine(" <Configurations active=\"{0}\">", conf.Name);
343 }
344
345 ss.WriteLine(" <Configuration name=\"{0}\">", conf.Name);
346 foreach(ProjectNode project in solution.Projects)
347 {
348 ss.WriteLine(" <Entry name=\"{0}\" configurationname=\"{1}\" build=\"True\" />", project.Name, conf.Name);
349 }
350 ss.WriteLine(" </Configuration>");
351
352 count++;
353 }
354 ss.WriteLine(" </Configurations>");
355 ss.WriteLine("</Combine>");
356 }
357
358 m_Kernel.CurrentWorkingDirectory.Pop();
359 }
360
361 private void CleanProject(ProjectNode project)
362 {
363 m_Kernel.Log.Write("...Cleaning project: {0}", project.Name);
364 string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, "prjx");
365 Helper.DeleteIfExists(projectFile);
366 }
367
368 private void CleanSolution(SolutionNode solution)
369 {
370 m_Kernel.Log.Write("Cleaning SharpDevelop combine and project files for", solution.Name);
371
372 string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "cmbx");
373 Helper.DeleteIfExists(slnFile);
374
375 foreach(ProjectNode project in solution.Projects)
376 {
377 CleanProject(project);
378 }
379
380 m_Kernel.Log.Write("");
381 }
382
383 #endregion
384
385 #region ITarget Members
386
387 /// <summary>
388 /// Writes the specified kern.
389 /// </summary>
390 /// <param name="kern">The kern.</param>
391 public void Write(Kernel kern)
392 {
393 if( kern == null )
394 {
395 throw new ArgumentNullException("kern");
396 }
397 m_Kernel = kern;
398 foreach(SolutionNode solution in kern.Solutions)
399 {
400 WriteCombine(solution);
401 }
402 m_Kernel = null;
403 }
404
405 /// <summary>
406 /// Cleans the specified kern.
407 /// </summary>
408 /// <param name="kern">The kern.</param>
409 public virtual void Clean(Kernel kern)
410 {
411 if( kern == null )
412 {
413 throw new ArgumentNullException("kern");
414 }
415 m_Kernel = kern;
416 foreach(SolutionNode sol in kern.Solutions)
417 {
418 CleanSolution(sol);
419 }
420 m_Kernel = null;
421 }
422
423 /// <summary>
424 /// Gets the name.
425 /// </summary>
426 /// <value>The name.</value>
427 public string Name
428 {
429 get
430 {
431 return "sharpdev";
432 }
433 }
434
435 #endregion
436 }
437}
diff --git a/Prebuild/src/Core/Targets/VS2002Target.cs b/Prebuild/src/Core/Targets/VS2002Target.cs
new file mode 100644
index 0000000..66216dc
--- /dev/null
+++ b/Prebuild/src/Core/Targets/VS2002Target.cs
@@ -0,0 +1,96 @@
1#region BSD License
2/*
3Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com)
4
5Redistribution and use in source and binary forms, with or without modification, are permitted
6provided that the following conditions are met:
7
8* Redistributions of source code must retain the above copyright notice, this list of conditions
9 and the following disclaimer.
10* Redistributions in binary form must reproduce the above copyright notice, this list of conditions
11 and the following disclaimer in the documentation and/or other materials provided with the
12 distribution.
13* The name of the author may not be used to endorse or promote products derived from this software
14 without specific prior written permission.
15
16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
17BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
22IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23*/
24#endregion
25
26#region CVS Information
27/*
28 * $Source$
29 * $Author: jendave $
30 * $Date: 2006-01-28 01:49:58 +0100 (lö, 28 jan 2006) $
31 * $Revision: 71 $
32 */
33#endregion
34
35using System;
36
37using Prebuild.Core.Attributes;
38
39namespace Prebuild.Core.Targets
40{
41 /// <summary>
42 ///
43 /// </summary>
44 [Target("vs2002")]
45 public class VS2002Target : VS2003Target
46 {
47 #region Private Methods
48
49 private void SetVS2002()
50 {
51 this.SolutionVersion = "7.00";
52 this.ProductVersion = "7.0.9254";
53 this.SchemaVersion = "1.0";
54 this.VersionName = "2002";
55 this.Version = VSVersion.VS70;
56 }
57
58 #endregion
59
60 #region Public Methods
61
62 /// <summary>
63 /// Writes the specified kern.
64 /// </summary>
65 /// <param name="kern">The kern.</param>
66 public override void Write(Kernel kern)
67 {
68 SetVS2002();
69 base.Write(kern);
70 }
71
72 /// <summary>
73 /// Cleans the specified kern.
74 /// </summary>
75 /// <param name="kern">The kern.</param>
76 public override void Clean(Kernel kern)
77 {
78 SetVS2002();
79 base.Clean(kern);
80 }
81
82 /// <summary>
83 /// Gets the name.
84 /// </summary>
85 /// <value>The name.</value>
86 public override string Name
87 {
88 get
89 {
90 return "vs2002";
91 }
92 }
93
94 #endregion
95 }
96}
diff --git a/Prebuild/src/Core/Targets/VS2003Target.cs b/Prebuild/src/Core/Targets/VS2003Target.cs
new file mode 100644
index 0000000..b3236a8
--- /dev/null
+++ b/Prebuild/src/Core/Targets/VS2003Target.cs
@@ -0,0 +1,633 @@
1#region BSD License
2/*
3Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com)
4
5Redistribution and use in source and binary forms, with or without modification, are permitted
6provided that the following conditions are met:
7
8* Redistributions of source code must retain the above copyright notice, this list of conditions
9 and the following disclaimer.
10* Redistributions in binary form must reproduce the above copyright notice, this list of conditions
11 and the following disclaimer in the documentation and/or other materials provided with the
12 distribution.
13* The name of the author may not be used to endorse or promote products derived from this software
14 without specific prior written permission.
15
16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
17BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
22IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23*/
24#endregion
25
26#region CVS Information
27/*
28 * $Source$
29 * $Author: jendave $
30 * $Date: 2006-09-29 21:11:40 +0200 (fr, 29 sep 2006) $
31 * $Revision: 177 $
32 */
33#endregion
34
35using System;
36using System.Collections;
37using System.Collections.Specialized;
38using System.IO;
39
40using Prebuild.Core.Attributes;
41using Prebuild.Core.Interfaces;
42using Prebuild.Core.Nodes;
43using Prebuild.Core.Utilities;
44
45namespace Prebuild.Core.Targets
46{
47 /// <summary>
48 ///
49 /// </summary>
50 public enum VSVersion
51 {
52 /// <summary>
53 ///
54 /// </summary>
55 VS70,
56 /// <summary>
57 ///
58 /// </summary>
59 VS71,
60 /// <summary>
61 ///
62 /// </summary>
63 VS80
64 }
65
66 /// <summary>
67 ///
68 /// </summary>
69 [Target("vs2003")]
70 public class VS2003Target : ITarget
71 {
72
73 #region Fields
74
75 string solutionVersion = "8.00";
76 string productVersion = "7.10.3077";
77 string schemaVersion = "2.0";
78 string versionName = "2003";
79 VSVersion version = VSVersion.VS71;
80
81 Hashtable m_Tools;
82 Kernel m_Kernel;
83
84 /// <summary>
85 /// Gets or sets the solution version.
86 /// </summary>
87 /// <value>The solution version.</value>
88 protected string SolutionVersion
89 {
90 get
91 {
92 return this.solutionVersion;
93 }
94 set
95 {
96 this.solutionVersion = value;
97 }
98 }
99 /// <summary>
100 /// Gets or sets the product version.
101 /// </summary>
102 /// <value>The product version.</value>
103 protected string ProductVersion
104 {
105 get
106 {
107 return this.productVersion;
108 }
109 set
110 {
111 this.productVersion = value;
112 }
113 }
114 /// <summary>
115 /// Gets or sets the schema version.
116 /// </summary>
117 /// <value>The schema version.</value>
118 protected string SchemaVersion
119 {
120 get
121 {
122 return this.schemaVersion;
123 }
124 set
125 {
126 this.schemaVersion = value;
127 }
128 }
129 /// <summary>
130 /// Gets or sets the name of the version.
131 /// </summary>
132 /// <value>The name of the version.</value>
133 protected string VersionName
134 {
135 get
136 {
137 return this.versionName;
138 }
139 set
140 {
141 this.versionName = value;
142 }
143 }
144 /// <summary>
145 /// Gets or sets the version.
146 /// </summary>
147 /// <value>The version.</value>
148 protected VSVersion Version
149 {
150 get
151 {
152 return this.version;
153 }
154 set
155 {
156 this.version = value;
157 }
158 }
159
160 #endregion
161
162 #region Constructors
163
164 /// <summary>
165 /// Initializes a new instance of the <see cref="VS2003Target"/> class.
166 /// </summary>
167 public VS2003Target()
168 {
169 m_Tools = new Hashtable();
170
171 m_Tools["C#"] = new ToolInfo("C#", "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}", "csproj", "CSHARP");
172 m_Tools["VB.NET"] = new ToolInfo("VB.NET", "{F184B08F-C81C-45F6-A57F-5ABD9991F28F}", "vbproj", "VisualBasic");
173 }
174
175 #endregion
176
177 #region Private Methods
178
179 private string MakeRefPath(ProjectNode project)
180 {
181 string ret = "";
182 foreach(ReferencePathNode node in project.ReferencePaths)
183 {
184 try
185 {
186 string fullPath = Helper.ResolvePath(node.Path);
187 if(ret.Length < 1)
188 {
189 ret = fullPath;
190 }
191 else
192 {
193 ret += ";" + fullPath;
194 }
195 }
196 catch(ArgumentException)
197 {
198 m_Kernel.Log.Write(LogType.Warning, "Could not resolve reference path: {0}", node.Path);
199 }
200 }
201
202 return ret;
203 }
204
205 private void WriteProject(SolutionNode solution, ProjectNode project)
206 {
207 if(!m_Tools.ContainsKey(project.Language))
208 {
209 throw new UnknownLanguageException("Unknown .NET language: " + project.Language);
210 }
211
212 ToolInfo toolInfo = (ToolInfo)m_Tools[project.Language];
213 string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension);
214 StreamWriter ps = new StreamWriter(projectFile);
215
216 m_Kernel.CurrentWorkingDirectory.Push();
217 Helper.SetCurrentDir(Path.GetDirectoryName(projectFile));
218
219 IEnumerator enumerator;
220 //ConfigurationNode scripts;
221
222 using(ps)
223 {
224 ps.WriteLine("<VisualStudioProject>");
225 ps.WriteLine(" <{0}", toolInfo.XmlTag);
226 ps.WriteLine("\t\t\t\tProjectType = \"Local\"");
227 ps.WriteLine("\t\t\t\tProductVersion = \"{0}\"", this.ProductVersion);
228 ps.WriteLine("\t\t\t\tSchemaVersion = \"{0}\"", this.SchemaVersion);
229 ps.WriteLine("\t\t\t\tProjectGuid = \"{{{0}}}\"", project.Guid.ToString().ToUpper());
230 ps.WriteLine("\t\t>");
231
232 ps.WriteLine("\t\t\t\t<Build>");
233 ps.WriteLine(" <Settings");
234 ps.WriteLine("\t\t\t\t ApplicationIcon = \"{0}\"",project.AppIcon);
235 ps.WriteLine("\t\t\t\t AssemblyKeyContainerName = \"\"");
236 ps.WriteLine("\t\t\t\t AssemblyName = \"{0}\"", project.AssemblyName);
237 ps.WriteLine("\t\t\t\t AssemblyOriginatorKeyFile = \"\"");
238 ps.WriteLine("\t\t\t\t DefaultClientScript = \"JScript\"");
239 ps.WriteLine("\t\t\t\t DefaultHTMLPageLayout = \"Grid\"");
240 ps.WriteLine("\t\t\t\t DefaultTargetSchema = \"IE50\"");
241 ps.WriteLine("\t\t\t\t DelaySign = \"false\"");
242
243 if(this.Version == VSVersion.VS70)
244 {
245 ps.WriteLine("\t\t\t\t NoStandardLibraries = \"false\"");
246 }
247
248 ps.WriteLine("\t\t\t\t OutputType = \"{0}\"", project.Type.ToString());
249
250 enumerator = project.Configurations.GetEnumerator();
251 enumerator.Reset();
252 enumerator.MoveNext();
253 foreach(ConfigurationNode conf in project.Configurations)
254 {
255 if (conf.Options["PreBuildEvent"] != null && conf.Options["PreBuildEvent"].ToString().Length != 0)
256 {
257 ps.WriteLine("\t\t\t\t PreBuildEvent = \"{0}\"", Helper.NormalizePath(conf.Options["PreBuildEvent"].ToString()));
258 }
259 else
260 {
261 ps.WriteLine("\t\t\t\t PreBuildEvent = \"{0}\"", conf.Options["PreBuildEvent"]);
262 }
263 if (conf.Options["PostBuildEvent"] != null && conf.Options["PostBuildEvent"].ToString().Length != 0)
264 {
265 ps.WriteLine("\t\t\t\t PostBuildEvent = \"{0}\"", Helper.NormalizePath(conf.Options["PostBuildEvent"].ToString()));
266 }
267 else
268 {
269 ps.WriteLine("\t\t\t\t PostBuildEvent = \"{0}\"", conf.Options["PostBuildEvent"]);
270 }
271 if (conf.Options["RunPostBuildEvent"] == null)
272 {
273 ps.WriteLine("\t\t\t\t RunPostBuildEvent = \"{0}\"", "OnBuildSuccess");
274 }
275 else
276 {
277 ps.WriteLine("\t\t\t\t RunPostBuildEvent = \"{0}\"", conf.Options["RunPostBuildEvent"]);
278 }
279 break;
280 }
281
282 ps.WriteLine("\t\t\t\t RootNamespace = \"{0}\"", project.RootNamespace);
283 ps.WriteLine("\t\t\t\t StartupObject = \"{0}\"", project.StartupObject);
284 ps.WriteLine("\t\t >");
285
286 foreach(ConfigurationNode conf in project.Configurations)
287 {
288 ps.WriteLine("\t\t\t\t <Config");
289 ps.WriteLine("\t\t\t\t Name = \"{0}\"", conf.Name);
290 ps.WriteLine("\t\t\t\t AllowUnsafeBlocks = \"{0}\"", conf.Options["AllowUnsafe"].ToString().ToLower());
291 ps.WriteLine("\t\t\t\t BaseAddress = \"{0}\"", conf.Options["BaseAddress"]);
292 ps.WriteLine("\t\t\t\t CheckForOverflowUnderflow = \"{0}\"", conf.Options["CheckUnderflowOverflow"].ToString().ToLower());
293 ps.WriteLine("\t\t\t\t ConfigurationOverrideFile = \"\"");
294 ps.WriteLine("\t\t\t\t DefineConstants = \"{0}\"", conf.Options["CompilerDefines"]);
295 ps.WriteLine("\t\t\t\t DocumentationFile = \"{0}\"", GetXmlDocFile(project, conf));//default to the assembly name
296 ps.WriteLine("\t\t\t\t DebugSymbols = \"{0}\"", conf.Options["DebugInformation"].ToString().ToLower());
297 ps.WriteLine("\t\t\t\t FileAlignment = \"{0}\"", conf.Options["FileAlignment"]);
298 ps.WriteLine("\t\t\t\t IncrementalBuild = \"{0}\"", conf.Options["IncrementalBuild"].ToString().ToLower());
299
300 if(this.Version == VSVersion.VS71)
301 {
302 ps.WriteLine("\t\t\t\t NoStdLib = \"{0}\"", conf.Options["NoStdLib"].ToString().ToLower());
303 ps.WriteLine("\t\t\t\t NoWarn = \"{0}\"", conf.Options["SuppressWarnings"].ToString().ToLower());
304 }
305
306 ps.WriteLine("\t\t\t\t Optimize = \"{0}\"", conf.Options["OptimizeCode"].ToString().ToLower());
307 ps.WriteLine(" OutputPath = \"{0}\"",
308 Helper.EndPath(Helper.NormalizePath(conf.Options["OutputPath"].ToString())));
309 ps.WriteLine(" RegisterForComInterop = \"{0}\"", conf.Options["RegisterComInterop"].ToString().ToLower());
310 ps.WriteLine(" RemoveIntegerChecks = \"{0}\"", conf.Options["RemoveIntegerChecks"].ToString().ToLower());
311 ps.WriteLine(" TreatWarningsAsErrors = \"{0}\"", conf.Options["WarningsAsErrors"].ToString().ToLower());
312 ps.WriteLine(" WarningLevel = \"{0}\"", conf.Options["WarningLevel"]);
313 ps.WriteLine(" />");
314 }
315
316 ps.WriteLine(" </Settings>");
317
318 ps.WriteLine(" <References>");
319 foreach(ReferenceNode refr in project.References)
320 {
321 ps.WriteLine(" <Reference");
322 ps.WriteLine(" Name = \"{0}\"", refr.Name);
323 ps.WriteLine(" AssemblyName = \"{0}\"", refr.Name);
324
325 if(solution.ProjectsTable.ContainsKey(refr.Name))
326 {
327 ProjectNode refProject = (ProjectNode)solution.ProjectsTable[refr.Name];
328 ps.WriteLine(" Project = \"{{{0}}}\"", refProject.Guid.ToString().ToUpper());
329 ps.WriteLine(" Package = \"{0}\"", toolInfo.Guid.ToString().ToUpper());
330 }
331 else
332 {
333 if(refr.Path != null)
334 {
335 ps.WriteLine(" HintPath = \"{0}\"", Helper.MakeFilePath(refr.Path, refr.Name, "dll"));
336 }
337
338 }
339
340 if(refr.LocalCopySpecified)
341 {
342 ps.WriteLine(" Private = \"{0}\"",refr.LocalCopy);
343 }
344
345 ps.WriteLine(" />");
346 }
347 ps.WriteLine(" </References>");
348
349 ps.WriteLine(" </Build>");
350 ps.WriteLine(" <Files>");
351
352 ps.WriteLine(" <Include>");
353
354 foreach(string file in project.Files)
355 {
356 string fileName = file.Replace(".\\", "");
357 ps.WriteLine(" <File");
358 ps.WriteLine(" RelPath = \"{0}\"", fileName);
359 ps.WriteLine(" SubType = \"{0}\"", project.Files.GetSubType(file));
360 ps.WriteLine(" BuildAction = \"{0}\"", project.Files.GetBuildAction(file));
361 ps.WriteLine(" />");
362
363 if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings)
364 {
365 ps.WriteLine(" <File");
366 ps.WriteLine(" RelPath = \"{0}\"", fileName.Substring(0, fileName.LastIndexOf('.')) + ".resx");
367 int slash = fileName.LastIndexOf('\\');
368 if (slash == -1)
369 {
370 ps.WriteLine(" DependentUpon = \"{0}\"", fileName);
371 }
372 else
373 {
374 ps.WriteLine(" DependentUpon = \"{0}\"", fileName.Substring(slash + 1, fileName.Length - slash - 1));
375 }
376 ps.WriteLine(" BuildAction = \"{0}\"", "EmbeddedResource");
377 ps.WriteLine(" />");
378
379 }
380 }
381 ps.WriteLine(" </Include>");
382
383 ps.WriteLine(" </Files>");
384 ps.WriteLine(" </{0}>", toolInfo.XmlTag);
385 ps.WriteLine("</VisualStudioProject>");
386 }
387
388 ps = new StreamWriter(projectFile + ".user");
389 using(ps)
390 {
391 ps.WriteLine("<VisualStudioProject>");
392 ps.WriteLine(" <{0}>", toolInfo.XmlTag);
393 ps.WriteLine(" <Build>");
394
395 ps.WriteLine(" <Settings ReferencePath=\"{0}\">", MakeRefPath(project));
396 foreach(ConfigurationNode conf in project.Configurations)
397 {
398 ps.WriteLine(" <Config");
399 ps.WriteLine(" Name = \"{0}\"", conf.Name);
400 ps.WriteLine(" />");
401 }
402 ps.WriteLine(" </Settings>");
403
404 ps.WriteLine(" </Build>");
405 ps.WriteLine(" </{0}>", toolInfo.XmlTag);
406 ps.WriteLine("</VisualStudioProject>");
407 }
408
409 m_Kernel.CurrentWorkingDirectory.Pop();
410 }
411
412 /// <summary>
413 /// Gets the XML doc file.
414 /// </summary>
415 /// <param name="project">The project.</param>
416 /// <param name="conf">The conf.</param>
417 /// <returns></returns>
418 public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf)
419 {
420 if( conf == null )
421 {
422 throw new ArgumentNullException("conf");
423 }
424 if( project == null )
425 {
426 throw new ArgumentNullException("project");
427 }
428 // if(!(bool)conf.Options["GenerateXmlDocFile"]) //default to none, if the generate option is false
429 // {
430 // return string.Empty;
431 // }
432
433 //default to "AssemblyName.xml"
434 //string defaultValue = Path.GetFileNameWithoutExtension(project.AssemblyName) + ".xml";
435 //return (string)conf.Options["XmlDocFile", defaultValue];
436
437 //default to no XmlDocFile file
438 return (string)conf.Options["XmlDocFile", ""];
439 }
440
441 private void WriteSolution(SolutionNode solution)
442 {
443 m_Kernel.Log.Write("Creating Visual Studio {0} solution and project files", this.VersionName);
444
445 foreach(ProjectNode project in solution.Projects)
446 {
447 if(m_Kernel.AllowProject(project.FilterGroups))
448 {
449 m_Kernel.Log.Write("...Creating project: {0}", project.Name);
450 WriteProject(solution, project);
451 }
452 }
453
454 m_Kernel.Log.Write("");
455 string solutionFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln");
456 StreamWriter ss = new StreamWriter(solutionFile);
457
458 m_Kernel.CurrentWorkingDirectory.Push();
459 Helper.SetCurrentDir(Path.GetDirectoryName(solutionFile));
460
461 using(ss)
462 {
463 ss.WriteLine("Microsoft Visual Studio Solution File, Format Version {0}", this.SolutionVersion);
464 foreach(ProjectNode project in solution.Projects)
465 {
466 if(!m_Tools.ContainsKey(project.Language))
467 {
468 throw new UnknownLanguageException("Unknown .NET language: " + project.Language);
469 }
470
471 ToolInfo toolInfo = (ToolInfo)m_Tools[project.Language];
472
473 string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
474 ss.WriteLine("Project(\"{0}\") = \"{1}\", \"{2}\", \"{{{3}}}\"",
475 toolInfo.Guid, project.Name, Helper.MakeFilePath(path, project.Name,
476 toolInfo.FileExtension), project.Guid.ToString().ToUpper());
477
478 ss.WriteLine("\tProjectSection(ProjectDependencies) = postProject");
479 ss.WriteLine("\tEndProjectSection");
480
481 ss.WriteLine("EndProject");
482 }
483
484 ss.WriteLine("Global");
485
486 ss.WriteLine("\tGlobalSection(SolutionConfiguration) = preSolution");
487 foreach(ConfigurationNode conf in solution.Configurations)
488 {
489 ss.WriteLine("\t\t{0} = {0}", conf.Name);
490 }
491 ss.WriteLine("\tEndGlobalSection");
492
493 ss.WriteLine("\tGlobalSection(ProjectDependencies) = postSolution");
494 foreach(ProjectNode project in solution.Projects)
495 {
496 for(int i = 0; i < project.References.Count; i++)
497 {
498 ReferenceNode refr = (ReferenceNode)project.References[i];
499 if(solution.ProjectsTable.ContainsKey(refr.Name))
500 {
501 ProjectNode refProject = (ProjectNode)solution.ProjectsTable[refr.Name];
502 ss.WriteLine("\t\t({{{0}}}).{1} = ({{{2}}})",
503 project.Guid.ToString().ToUpper()
504 , i,
505 refProject.Guid.ToString().ToUpper()
506 );
507 }
508 }
509 }
510 ss.WriteLine("\tEndGlobalSection");
511
512 ss.WriteLine("\tGlobalSection(ProjectConfiguration) = postSolution");
513 foreach(ProjectNode project in solution.Projects)
514 {
515 foreach(ConfigurationNode conf in solution.Configurations)
516 {
517 ss.WriteLine("\t\t{{{0}}}.{1}.ActiveCfg = {1}|.NET",
518 project.Guid.ToString().ToUpper(),
519 conf.Name);
520
521 ss.WriteLine("\t\t{{{0}}}.{1}.Build.0 = {1}|.NET",
522 project.Guid.ToString().ToUpper(),
523 conf.Name);
524 }
525 }
526 ss.WriteLine("\tEndGlobalSection");
527
528 if(solution.Files != null)
529 {
530 ss.WriteLine("\tGlobalSection(SolutionItems) = postSolution");
531 foreach(string file in solution.Files)
532 {
533 ss.WriteLine("\t\t{0} = {0}", file);
534 }
535 ss.WriteLine("\tEndGlobalSection");
536 }
537
538 ss.WriteLine("\tGlobalSection(ExtensibilityGlobals) = postSolution");
539 ss.WriteLine("\tEndGlobalSection");
540 ss.WriteLine("\tGlobalSection(ExtensibilityAddIns) = postSolution");
541 ss.WriteLine("\tEndGlobalSection");
542
543 ss.WriteLine("EndGlobal");
544 }
545
546 m_Kernel.CurrentWorkingDirectory.Pop();
547 }
548
549 private void CleanProject(ProjectNode project)
550 {
551 m_Kernel.Log.Write("...Cleaning project: {0}", project.Name);
552
553 ToolInfo toolInfo = (ToolInfo)m_Tools[project.Language];
554 string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension);
555 string userFile = projectFile + ".user";
556
557 Helper.DeleteIfExists(projectFile);
558 Helper.DeleteIfExists(userFile);
559 }
560
561 private void CleanSolution(SolutionNode solution)
562 {
563 m_Kernel.Log.Write("Cleaning Visual Studio {0} solution and project files", this.VersionName, solution.Name);
564
565 string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln");
566 string suoFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "suo");
567
568 Helper.DeleteIfExists(slnFile);
569 Helper.DeleteIfExists(suoFile);
570
571 foreach(ProjectNode project in solution.Projects)
572 {
573 CleanProject(project);
574 }
575
576 m_Kernel.Log.Write("");
577 }
578
579 #endregion
580
581 #region ITarget Members
582
583 /// <summary>
584 /// Writes the specified kern.
585 /// </summary>
586 /// <param name="kern">The kern.</param>
587 public virtual void Write(Kernel kern)
588 {
589 if( kern == null )
590 {
591 throw new ArgumentNullException("kern");
592 }
593 m_Kernel = kern;
594 foreach(SolutionNode sol in m_Kernel.Solutions)
595 {
596 WriteSolution(sol);
597 }
598 m_Kernel = null;
599 }
600
601 /// <summary>
602 /// Cleans the specified kern.
603 /// </summary>
604 /// <param name="kern">The kern.</param>
605 public virtual void Clean(Kernel kern)
606 {
607 if( kern == null )
608 {
609 throw new ArgumentNullException("kern");
610 }
611 m_Kernel = kern;
612 foreach(SolutionNode sol in m_Kernel.Solutions)
613 {
614 CleanSolution(sol);
615 }
616 m_Kernel = null;
617 }
618
619 /// <summary>
620 /// Gets the name.
621 /// </summary>
622 /// <value>The name.</value>
623 public virtual string Name
624 {
625 get
626 {
627 return "vs2003";
628 }
629 }
630
631 #endregion
632 }
633}
diff --git a/Prebuild/src/Core/Targets/VS2005Target.cs b/Prebuild/src/Core/Targets/VS2005Target.cs
new file mode 100644
index 0000000..3cfc8cd
--- /dev/null
+++ b/Prebuild/src/Core/Targets/VS2005Target.cs
@@ -0,0 +1,869 @@
1#region BSD License
2/*
3Copyright (c) 2004 Matthew Holmes (matthew@wildfiregames.com)
4
5Redistribution and use in source and binary forms, with or without modification, are permitted
6provided that the following conditions are met:
7
8* Redistributions of source code must retain the above copyright notice, this list of conditions
9 and the following disclaimer.
10* Redistributions in binary form must reproduce the above copyright notice, this list of conditions
11 and the following disclaimer in the documentation and/or other materials provided with the
12 distribution.
13* The name of the author may not be used to endorse or promote products derived from this software
14 without specific prior written permission.
15
16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
17BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
22IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23*/
24#endregion
25
26#region CVS Information
27/*
28 * $Source$
29 * $Author: robloach $
30 * $Date: 2007-02-27 19:52:34 +0100 (ti, 27 feb 2007) $
31 * $Revision: 207 $
32 */
33#endregion
34
35using System;
36using System.Collections;
37using System.Collections.Specialized;
38using System.IO;
39
40using Prebuild.Core.Attributes;
41using Prebuild.Core.Interfaces;
42using Prebuild.Core.Nodes;
43using Prebuild.Core.Utilities;
44
45namespace Prebuild.Core.Targets
46{
47 /// <summary>
48 ///
49 /// </summary>
50 public struct ToolInfo
51 {
52 string name;
53 string guid;
54 string fileExtension;
55 string xmlTag;
56 string importProject;
57
58 /// <summary>
59 /// Gets or sets the name.
60 /// </summary>
61 /// <value>The name.</value>
62 public string Name
63 {
64 get
65 {
66 return name;
67 }
68 set
69 {
70 name = value;
71 }
72 }
73
74 /// <summary>
75 /// Gets or sets the GUID.
76 /// </summary>
77 /// <value>The GUID.</value>
78 public string Guid
79 {
80 get
81 {
82 return guid;
83 }
84 set
85 {
86 guid = value;
87 }
88 }
89
90 /// <summary>
91 /// Gets or sets the file extension.
92 /// </summary>
93 /// <value>The file extension.</value>
94 public string FileExtension
95 {
96 get
97 {
98 return fileExtension;
99 }
100 set
101 {
102 fileExtension = value;
103 }
104 }
105 /// <summary>
106 /// Gets or sets the XML tag.
107 /// </summary>
108 /// <value>The XML tag.</value>
109 public string XmlTag
110 {
111 get
112 {
113 return xmlTag;
114 }
115 set
116 {
117 xmlTag = value;
118 }
119 }
120
121 /// <summary>
122 /// Gets or sets the import project property.
123 /// </summary>
124 /// <value>The ImportProject tag.</value>
125 public string ImportProject
126 {
127 get
128 {
129 return importProject;
130 }
131 set
132 {
133 importProject = value;
134 }
135 }
136
137 /// <summary>
138 /// Initializes a new instance of the <see cref="ToolInfo"/> class.
139 /// </summary>
140 /// <param name="name">The name.</param>
141 /// <param name="guid">The GUID.</param>
142 /// <param name="fileExtension">The file extension.</param>
143 /// <param name="xml">The XML.</param>
144 /// <param name="importProject">The import project.</param>
145 public ToolInfo(string name, string guid, string fileExtension, string xml, string importProject)
146 {
147 this.name = name;
148 this.guid = guid;
149 this.fileExtension = fileExtension;
150 this.xmlTag = xml;
151 this.importProject = importProject;
152 }
153
154 /// <summary>
155 /// Initializes a new instance of the <see cref="ToolInfo"/> class.
156 /// </summary>
157 /// <param name="name">The name.</param>
158 /// <param name="guid">The GUID.</param>
159 /// <param name="fileExtension">The file extension.</param>
160 /// <param name="xml">The XML.</param>
161 public ToolInfo(string name, string guid, string fileExtension, string xml)
162 {
163 this.name = name;
164 this.guid = guid;
165 this.fileExtension = fileExtension;
166 this.xmlTag = xml;
167 this.importProject = "$(MSBuildBinPath)\\Microsoft." + xml + ".Targets";
168 }
169
170 /// <summary>
171 /// Equals operator
172 /// </summary>
173 /// <param name="obj">ToolInfo to compare</param>
174 /// <returns>true if toolInfos are equal</returns>
175 public override bool Equals(object obj)
176 {
177 if (obj == null)
178 {
179 throw new ArgumentNullException("obj");
180 }
181 if (obj.GetType() != typeof(ToolInfo))
182 return false;
183
184 ToolInfo c = (ToolInfo)obj;
185 return ((this.name == c.name) && (this.guid == c.guid) && (this.fileExtension == c.fileExtension) && (this.importProject == c.importProject));
186 }
187
188 /// <summary>
189 /// Equals operator
190 /// </summary>
191 /// <param name="c1">ToolInfo to compare</param>
192 /// <param name="c2">ToolInfo to compare</param>
193 /// <returns>True if toolInfos are equal</returns>
194 public static bool operator ==(ToolInfo c1, ToolInfo c2)
195 {
196 return ((c1.name == c2.name) && (c1.guid == c2.guid) && (c1.fileExtension == c2.fileExtension) && (c1.importProject == c2.importProject) && (c1.xmlTag == c2.xmlTag));
197 }
198
199 /// <summary>
200 /// Not equals operator
201 /// </summary>
202 /// <param name="c1">ToolInfo to compare</param>
203 /// <param name="c2">ToolInfo to compare</param>
204 /// <returns>True if toolInfos are not equal</returns>
205 public static bool operator !=(ToolInfo c1, ToolInfo c2)
206 {
207 return !(c1 == c2);
208 }
209
210 /// <summary>
211 /// Hash Code
212 /// </summary>
213 /// <returns>Hash code</returns>
214 public override int GetHashCode()
215 {
216 return name.GetHashCode() ^ guid.GetHashCode() ^ this.fileExtension.GetHashCode() ^ this.importProject.GetHashCode() ^ this.xmlTag.GetHashCode();
217
218 }
219 }
220
221 /// <summary>
222 ///
223 /// </summary>
224 [Target("vs2005")]
225 public class VS2005Target : ITarget
226 {
227 #region Inner Classes
228
229 #endregion
230
231 #region Fields
232
233 string solutionVersion = "9.00";
234 string productVersion = "8.0.50727";
235 string schemaVersion = "2.0";
236 string versionName = "Visual C# 2005";
237 VSVersion version = VSVersion.VS80;
238
239 Hashtable tools;
240 Kernel kernel;
241
242 /// <summary>
243 /// Gets or sets the solution version.
244 /// </summary>
245 /// <value>The solution version.</value>
246 protected string SolutionVersion
247 {
248 get
249 {
250 return this.solutionVersion;
251 }
252 set
253 {
254 this.solutionVersion = value;
255 }
256 }
257 /// <summary>
258 /// Gets or sets the product version.
259 /// </summary>
260 /// <value>The product version.</value>
261 protected string ProductVersion
262 {
263 get
264 {
265 return this.productVersion;
266 }
267 set
268 {
269 this.productVersion = value;
270 }
271 }
272 /// <summary>
273 /// Gets or sets the schema version.
274 /// </summary>
275 /// <value>The schema version.</value>
276 protected string SchemaVersion
277 {
278 get
279 {
280 return this.schemaVersion;
281 }
282 set
283 {
284 this.schemaVersion = value;
285 }
286 }
287 /// <summary>
288 /// Gets or sets the name of the version.
289 /// </summary>
290 /// <value>The name of the version.</value>
291 protected string VersionName
292 {
293 get
294 {
295 return this.versionName;
296 }
297 set
298 {
299 this.versionName = value;
300 }
301 }
302 /// <summary>
303 /// Gets or sets the version.
304 /// </summary>
305 /// <value>The version.</value>
306 protected VSVersion Version
307 {
308 get
309 {
310 return this.version;
311 }
312 set
313 {
314 this.version = value;
315 }
316 }
317
318 #endregion
319
320 #region Constructors
321
322 /// <summary>
323 /// Initializes a new instance of the <see cref="VS2005Target"/> class.
324 /// </summary>
325 public VS2005Target()
326 {
327 this.tools = new Hashtable();
328
329 this.tools["C#"] = new ToolInfo("C#", "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}", "csproj", "CSHARP", "$(MSBuildBinPath)\\Microsoft.CSHARP.Targets");
330 this.tools["Boo"] = new ToolInfo("Boo", "{45CEA7DC-C2ED-48A6-ACE0-E16144C02365}", "booproj", "Boo", "$(BooBinPath)\\Boo.Microsoft.Build.targets");
331 this.tools["VisualBasic"] = new ToolInfo("VisualBasic", "{F184B08F-C81C-45F6-A57F-5ABD9991F28F}", "vbproj", "VisualBasic", "$(MSBuildBinPath)\\Microsoft.VisualBasic.Targets");
332 }
333
334 #endregion
335
336 #region Private Methods
337
338 private string MakeRefPath(ProjectNode project)
339 {
340 string ret = "";
341 foreach (ReferencePathNode node in project.ReferencePaths)
342 {
343 try
344 {
345 string fullPath = Helper.ResolvePath(node.Path);
346 if (ret.Length < 1)
347 {
348 ret = fullPath;
349 }
350 else
351 {
352 ret += ";" + fullPath;
353 }
354 }
355 catch (ArgumentException)
356 {
357 this.kernel.Log.Write(LogType.Warning, "Could not resolve reference path: {0}", node.Path);
358 }
359 }
360
361 return ret;
362 }
363
364 private void WriteProject(SolutionNode solution, ProjectNode project)
365 {
366 if (!tools.ContainsKey(project.Language))
367 {
368 throw new UnknownLanguageException("Unknown .NET language: " + project.Language);
369 }
370
371 ToolInfo toolInfo = (ToolInfo)tools[project.Language];
372 string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension);
373 StreamWriter ps = new StreamWriter(projectFile);
374
375 kernel.CurrentWorkingDirectory.Push();
376 Helper.SetCurrentDir(Path.GetDirectoryName(projectFile));
377
378 #region Project File
379 using (ps)
380 {
381 ps.WriteLine("<Project DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">");
382 //ps.WriteLine(" <{0}", toolInfo.XMLTag);
383 ps.WriteLine(" <PropertyGroup>");
384 ps.WriteLine(" <ProjectType>Local</ProjectType>");
385 ps.WriteLine(" <ProductVersion>{0}</ProductVersion>", this.ProductVersion);
386 ps.WriteLine(" <SchemaVersion>{0}</SchemaVersion>", this.SchemaVersion);
387 ps.WriteLine(" <ProjectGuid>{{{0}}}</ProjectGuid>", project.Guid.ToString().ToUpper());
388
389 ps.WriteLine(" <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>");
390 ps.WriteLine(" <Platform Condition=\" '$(Platform)' == '' \">AnyCPU</Platform>");
391 //ps.WriteLine(" <Build>");
392
393 //ps.WriteLine(" <Settings");
394 ps.WriteLine(" <ApplicationIcon>{0}</ApplicationIcon>", project.AppIcon);
395 ps.WriteLine(" <AssemblyKeyContainerName>");
396 ps.WriteLine(" </AssemblyKeyContainerName>");
397 ps.WriteLine(" <AssemblyName>{0}</AssemblyName>", project.AssemblyName);
398 foreach (ConfigurationNode conf in project.Configurations)
399 {
400 if (conf.Options.KeyFile != "")
401 {
402 ps.WriteLine(" <AssemblyOriginatorKeyFile>{0}</AssemblyOriginatorKeyFile>", conf.Options.KeyFile);
403 ps.WriteLine(" <SignAssembly>true</SignAssembly>");
404 break;
405 }
406 }
407 ps.WriteLine(" <DefaultClientScript>JScript</DefaultClientScript>");
408 ps.WriteLine(" <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>");
409 ps.WriteLine(" <DefaultTargetSchema>IE50</DefaultTargetSchema>");
410 ps.WriteLine(" <DelaySign>false</DelaySign>");
411
412 //if(m_Version == VSVersion.VS70)
413 // ps.WriteLine(" NoStandardLibraries = \"false\"");
414
415 ps.WriteLine(" <OutputType>{0}</OutputType>", project.Type.ToString());
416 ps.WriteLine(" <AppDesignerFolder>{0}</AppDesignerFolder>", project.DesignerFolder);
417 ps.WriteLine(" <RootNamespace>{0}</RootNamespace>", project.RootNamespace);
418 ps.WriteLine(" <StartupObject>{0}</StartupObject>", project.StartupObject);
419 //ps.WriteLine(" >");
420 ps.WriteLine(" <FileUpgradeFlags>");
421 ps.WriteLine(" </FileUpgradeFlags>");
422
423 ps.WriteLine(" </PropertyGroup>");
424
425 foreach (ConfigurationNode conf in project.Configurations)
426 {
427 ps.Write(" <PropertyGroup ");
428 ps.WriteLine("Condition=\" '$(Configuration)|$(Platform)' == '{0}|AnyCPU' \">", conf.Name);
429 ps.WriteLine(" <AllowUnsafeBlocks>{0}</AllowUnsafeBlocks>", conf.Options["AllowUnsafe"]);
430 ps.WriteLine(" <BaseAddress>{0}</BaseAddress>", conf.Options["BaseAddress"]);
431 ps.WriteLine(" <CheckForOverflowUnderflow>{0}</CheckForOverflowUnderflow>", conf.Options["CheckUnderflowOverflow"]);
432 ps.WriteLine(" <ConfigurationOverrideFile>");
433 ps.WriteLine(" </ConfigurationOverrideFile>");
434 ps.WriteLine(" <DefineConstants>{0}</DefineConstants>", conf.Options["CompilerDefines"]);
435 ps.WriteLine(" <DocumentationFile>{0}</DocumentationFile>", conf.Options["XmlDocFile"]);
436 ps.WriteLine(" <DebugSymbols>{0}</DebugSymbols>", conf.Options["DebugInformation"]);
437 ps.WriteLine(" <FileAlignment>{0}</FileAlignment>", conf.Options["FileAlignment"]);
438 // ps.WriteLine(" <IncrementalBuild = \"{0}\"", conf.Options["IncrementalBuild"]);
439
440 // if(m_Version == VSVersion.VS71)
441 // {
442 // ps.WriteLine(" NoStdLib = \"{0}\"", conf.Options["NoStdLib"]);
443 // ps.WriteLine(" NoWarn = \"{0}\"", conf.Options["SuppressWarnings"]);
444 // }
445
446 ps.WriteLine(" <Optimize>{0}</Optimize>", conf.Options["OptimizeCode"]);
447 ps.WriteLine(" <OutputPath>{0}</OutputPath>",
448 Helper.EndPath(Helper.NormalizePath(conf.Options["OutputPath"].ToString())));
449 ps.WriteLine(" <RegisterForComInterop>{0}</RegisterForComInterop>", conf.Options["RegisterComInterop"]);
450 ps.WriteLine(" <RemoveIntegerChecks>{0}</RemoveIntegerChecks>", conf.Options["RemoveIntegerChecks"]);
451 ps.WriteLine(" <TreatWarningsAsErrors>{0}</TreatWarningsAsErrors>", conf.Options["WarningsAsErrors"]);
452 ps.WriteLine(" <WarningLevel>{0}</WarningLevel>", conf.Options["WarningLevel"]);
453 ps.WriteLine(" <NoWarn>{0}</NoWarn>", conf.Options["SuppressWarnings"]);
454 ps.WriteLine(" </PropertyGroup>");
455 }
456
457 //ps.WriteLine(" </Settings>");
458
459 // Assembly References
460 ps.WriteLine(" <ItemGroup>");
461 foreach (ReferenceNode refr in project.References)
462 {
463 if (!solution.ProjectsTable.ContainsKey(refr.Name))
464 {
465 ps.Write(" <Reference");
466 ps.Write(" Include=\"");
467 ps.Write(refr.Name);
468
469 if (!string.IsNullOrEmpty(refr.Version))
470 {
471 ps.Write(", Version=");
472 ps.Write(refr.Version);
473 }
474
475 ps.WriteLine("\" >");
476
477 // TODO: Allow reference to *.exe files
478 ps.WriteLine(" <HintPath>{0}</HintPath>", Helper.MakePathRelativeTo(project.FullPath, refr.Path + "\\" + refr.Name + ".dll"));
479 ps.WriteLine(" <Private>{0}</Private>", refr.LocalCopy);
480 ps.WriteLine(" </Reference>");
481 }
482 }
483 ps.WriteLine(" </ItemGroup>");
484
485 //Project References
486 ps.WriteLine(" <ItemGroup>");
487 foreach (ReferenceNode refr in project.References)
488 {
489 if (solution.ProjectsTable.ContainsKey(refr.Name))
490 {
491 ProjectNode refProject = (ProjectNode)solution.ProjectsTable[refr.Name];
492 // TODO: Allow reference to visual basic projects
493 ps.WriteLine(" <ProjectReference Include=\"{0}\">", Helper.MakePathRelativeTo(project.FullPath, Helper.MakeFilePath(refProject.FullPath, refProject.Name, "csproj")));
494 //<ProjectReference Include="..\..\RealmForge\Utility\RealmForge.Utility.csproj">
495 ps.WriteLine(" <Name>{0}</Name>", refProject.Name);
496 // <Name>RealmForge.Utility</Name>
497 ps.WriteLine(" <Project>{{{0}}}</Project>", refProject.Guid.ToString().ToUpper());
498 // <Project>{6880D1D3-69EE-461B-B841-5319845B20D3}</Project>
499 ps.WriteLine(" <Package>{0}</Package>", toolInfo.Guid.ToString().ToUpper());
500 // <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
501 ps.WriteLine("\t\t\t<Private>{0}</Private>", refr.LocalCopy);
502 ps.WriteLine(" </ProjectReference>");
503 //</ProjectReference>
504 }
505 else
506 {
507 }
508 }
509 ps.WriteLine(" </ItemGroup>");
510
511 // ps.WriteLine(" </Build>");
512 ps.WriteLine(" <ItemGroup>");
513
514 // ps.WriteLine(" <Include>");
515 ArrayList list = new ArrayList();
516 foreach (string file in project.Files)
517 {
518 // if (file == "Properties\\Bind.Designer.cs")
519 // {
520 // Console.WriteLine("Wait a minute!");
521 // Console.WriteLine(project.Files.GetSubType(file).ToString());
522 // }
523
524 if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings && project.Files.GetSubType(file) != SubType.Designer)
525 {
526 ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".resx");
527
528 int slash = file.LastIndexOf('\\');
529 if (slash == -1)
530 {
531 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", file);
532 }
533 else
534 {
535 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", file.Substring(slash + 1, file.Length - slash - 1));
536 }
537 ps.WriteLine(" <SubType>Designer</SubType>");
538 ps.WriteLine(" </EmbeddedResource>");
539 //
540 }
541
542 if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) == SubType.Designer)
543 {
544 ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".resx");
545 ps.WriteLine(" <SubType>" + project.Files.GetSubType(file) + "</SubType>");
546 ps.WriteLine(" <Generator>ResXFileCodeGenerator</Generator>");
547 ps.WriteLine(" <LastGenOutput>Resources.Designer.cs</LastGenOutput>");
548 ps.WriteLine(" </EmbeddedResource>");
549 ps.WriteLine(" <Compile Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".Designer.cs");
550 ps.WriteLine(" <AutoGen>True</AutoGen>");
551 ps.WriteLine(" <DesignTime>True</DesignTime>");
552 ps.WriteLine(" <DependentUpon>Resources.resx</DependentUpon>");
553 ps.WriteLine(" </Compile>");
554 list.Add(file.Substring(0, file.LastIndexOf('.')) + ".Designer.cs");
555 }
556 if (project.Files.GetSubType(file).ToString() == "Settings")
557 {
558 //Console.WriteLine("File: " + file);
559 //Console.WriteLine("Last index: " + file.LastIndexOf('.'));
560 //Console.WriteLine("Length: " + file.Length);
561 ps.Write(" <{0} ", project.Files.GetBuildAction(file));
562 ps.WriteLine("Include=\"{0}\">", file);
563 int slash = file.LastIndexOf('\\');
564 string fileName = file.Substring(slash + 1, file.Length - slash - 1);
565 if (project.Files.GetBuildAction(file) == BuildAction.None)
566 {
567 ps.WriteLine(" <Generator>SettingsSingleFileGenerator</Generator>");
568
569 //Console.WriteLine("FileName: " + fileName);
570 //Console.WriteLine("FileNameMain: " + fileName.Substring(0, fileName.LastIndexOf('.')));
571 //Console.WriteLine("FileNameExt: " + fileName.Substring(fileName.LastIndexOf('.'), fileName.Length - fileName.LastIndexOf('.')));
572 if (slash == -1)
573 {
574 ps.WriteLine(" <LastGenOutput>{0}</LastGenOutput>", fileName.Substring(0, fileName.LastIndexOf('.')) + ".Designer.cs");
575 }
576 else
577 {
578 ps.WriteLine(" <LastGenOutput>{0}</LastGenOutput>", fileName.Substring(0, fileName.LastIndexOf('.')) + ".Designer.cs");
579 }
580 }
581 else
582 {
583 ps.WriteLine(" <SubType>Code</SubType>");
584 ps.WriteLine(" <AutoGen>True</AutoGen>");
585 ps.WriteLine(" <DesignTimeSharedInput>True</DesignTimeSharedInput>");
586 string fileNameShort = fileName.Substring(0, fileName.LastIndexOf('.'));
587 string fileNameShorter = fileNameShort.Substring(0, fileNameShort.LastIndexOf('.'));
588 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", fileNameShorter + ".settings");
589 }
590 ps.WriteLine(" </{0}>", project.Files.GetBuildAction(file));
591 }
592 else if (project.Files.GetSubType(file) != SubType.Designer)
593 {
594 if (!list.Contains(file))
595 {
596 ps.Write(" <{0} ", project.Files.GetBuildAction(file));
597 ps.WriteLine("Include=\"{0}\">", file);
598
599
600 if (file.Contains("Designer.cs"))
601 {
602 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", file.Substring(0, file.IndexOf(".Designer.cs")) + ".cs");
603 }
604
605 if (project.Files.GetIsLink(file))
606 {
607 ps.WriteLine(" <Link>{0}</Link>", Path.GetFileName(file));
608 }
609 else if (project.Files.GetBuildAction(file) != BuildAction.None)
610 {
611 if (project.Files.GetBuildAction(file) != BuildAction.EmbeddedResource)
612 {
613 ps.WriteLine(" <SubType>{0}</SubType>", project.Files.GetSubType(file));
614 }
615 }
616 if (project.Files.GetCopyToOutput(file) != CopyToOutput.Never)
617 {
618 ps.WriteLine(" <CopyToOutputDirectory>{0}</CopyToOutputDirectory>", project.Files.GetCopyToOutput(file));
619 }
620
621 ps.WriteLine(" </{0}>", project.Files.GetBuildAction(file));
622 }
623 }
624 }
625 // ps.WriteLine(" </Include>");
626
627 ps.WriteLine(" </ItemGroup>");
628 ps.WriteLine(" <Import Project=\"" + toolInfo.ImportProject + "\" />");
629 ps.WriteLine(" <PropertyGroup>");
630 ps.WriteLine(" <PreBuildEvent>");
631 ps.WriteLine(" </PreBuildEvent>");
632 ps.WriteLine(" <PostBuildEvent>");
633 ps.WriteLine(" </PostBuildEvent>");
634 ps.WriteLine(" </PropertyGroup>");
635 // ps.WriteLine(" </{0}>", toolInfo.XMLTag);
636 ps.WriteLine("</Project>");
637 }
638 #endregion
639
640 #region User File
641
642 ps = new StreamWriter(projectFile + ".user");
643 using (ps)
644 {
645 ps.WriteLine("<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">");
646 //ps.WriteLine( "<VisualStudioProject>" );
647 //ps.WriteLine(" <{0}>", toolInfo.XMLTag);
648 //ps.WriteLine(" <Build>");
649 ps.WriteLine(" <PropertyGroup>");
650 //ps.WriteLine(" <Settings ReferencePath=\"{0}\">", MakeRefPath(project));
651 ps.WriteLine(" <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>");
652 ps.WriteLine(" <Platform Condition=\" '$(Platform)' == '' \">AnyCPU</Platform>");
653 ps.WriteLine(" <ReferencePath>{0}</ReferencePath>", MakeRefPath(project));
654 ps.WriteLine(" <LastOpenVersion>{0}</LastOpenVersion>", this.ProductVersion);
655 ps.WriteLine(" <ProjectView>ProjectFiles</ProjectView>");
656 ps.WriteLine(" <ProjectTrust>0</ProjectTrust>");
657 ps.WriteLine(" </PropertyGroup>");
658 foreach (ConfigurationNode conf in project.Configurations)
659 {
660 ps.Write(" <PropertyGroup");
661 ps.Write(" Condition = \" '$(Configuration)|$(Platform)' == '{0}|AnyCPU' \"", conf.Name);
662 ps.WriteLine(" />");
663 }
664 //ps.WriteLine(" </Settings>");
665
666 //ps.WriteLine(" </Build>");
667 //ps.WriteLine(" </{0}>", toolInfo.XMLTag);
668 //ps.WriteLine("</VisualStudioProject>");
669 ps.WriteLine("</Project>");
670 }
671 #endregion
672
673 kernel.CurrentWorkingDirectory.Pop();
674 }
675
676 private void WriteSolution(SolutionNode solution)
677 {
678 kernel.Log.Write("Creating {0} solution and project files", this.VersionName);
679
680 foreach (ProjectNode project in solution.Projects)
681 {
682 kernel.Log.Write("...Creating project: {0}", project.Name);
683 WriteProject(solution, project);
684 }
685
686 kernel.Log.Write("");
687 string solutionFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln");
688 StreamWriter ss = new StreamWriter(solutionFile);
689
690 kernel.CurrentWorkingDirectory.Push();
691 Helper.SetCurrentDir(Path.GetDirectoryName(solutionFile));
692
693 using (ss)
694 {
695 ss.WriteLine("Microsoft Visual Studio Solution File, Format Version {0}", this.SolutionVersion);
696 ss.WriteLine("# Visual Studio 2005");
697 foreach (ProjectNode project in solution.Projects)
698 {
699 if (!tools.ContainsKey(project.Language))
700 {
701 throw new UnknownLanguageException("Unknown .NET language: " + project.Language);
702 }
703
704 ToolInfo toolInfo = (ToolInfo)tools[project.Language];
705
706 string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
707 ss.WriteLine("Project(\"{0}\") = \"{1}\", \"{2}\", \"{{{3}}}\"",
708 toolInfo.Guid, project.Name, Helper.MakeFilePath(path, project.Name,
709 toolInfo.FileExtension), project.Guid.ToString().ToUpper());
710
711 //ss.WriteLine(" ProjectSection(ProjectDependencies) = postProject");
712 //ss.WriteLine(" EndProjectSection");
713
714 ss.WriteLine("EndProject");
715 }
716
717 if (solution.Files != null)
718 {
719 ss.WriteLine("Project(\"{0}\") = \"Solution Items\", \"Solution Items\", \"{1}\"", "{2150E333-8FDC-42A3-9474-1A3956D46DE8}", "{468F1D07-AD17-4CC3-ABD0-2CA268E4E1A6}");
720 ss.WriteLine("\tProjectSection(SolutionItems) = preProject");
721 foreach (string file in solution.Files)
722 ss.WriteLine("\t\t{0} = {0}", file);
723 ss.WriteLine("\tEndProjectSection");
724 ss.WriteLine("EndProject");
725 }
726
727 ss.WriteLine("Global");
728
729 ss.WriteLine(" GlobalSection(SolutionConfigurationPlatforms) = preSolution");
730 foreach (ConfigurationNode conf in solution.Configurations)
731 {
732 ss.WriteLine(" {0}|Any CPU = {0}|Any CPU", conf.Name);
733 }
734 ss.WriteLine(" EndGlobalSection");
735
736 if (solution.Projects.Count > 1)
737 {
738 ss.WriteLine(" GlobalSection(ProjectDependencies) = postSolution");
739 }
740 foreach (ProjectNode project in solution.Projects)
741 {
742 for (int i = 0; i < project.References.Count; i++)
743 {
744 ReferenceNode refr = (ReferenceNode)project.References[i];
745 if (solution.ProjectsTable.ContainsKey(refr.Name))
746 {
747 ProjectNode refProject = (ProjectNode)solution.ProjectsTable[refr.Name];
748 ss.WriteLine(" ({{{0}}}).{1} = ({{{2}}})",
749 project.Guid.ToString().ToUpper()
750 , i,
751 refProject.Guid.ToString().ToUpper()
752 );
753 }
754 }
755 }
756 if (solution.Projects.Count > 1)
757 {
758 ss.WriteLine(" EndGlobalSection");
759 }
760 ss.WriteLine(" GlobalSection(ProjectConfigurationPlatforms) = postSolution");
761 foreach (ProjectNode project in solution.Projects)
762 {
763 foreach (ConfigurationNode conf in solution.Configurations)
764 {
765 ss.WriteLine(" {{{0}}}.{1}|Any CPU.ActiveCfg = {1}|Any CPU",
766 project.Guid.ToString().ToUpper(),
767 conf.Name);
768
769 ss.WriteLine(" {{{0}}}.{1}|Any CPU.Build.0 = {1}|Any CPU",
770 project.Guid.ToString().ToUpper(),
771 conf.Name);
772 }
773 }
774 ss.WriteLine(" EndGlobalSection");
775 ss.WriteLine(" GlobalSection(SolutionProperties) = preSolution");
776 ss.WriteLine(" HideSolutionNode = FALSE");
777 ss.WriteLine(" EndGlobalSection");
778
779 ss.WriteLine("EndGlobal");
780 }
781
782 kernel.CurrentWorkingDirectory.Pop();
783 }
784
785 private void CleanProject(ProjectNode project)
786 {
787 kernel.Log.Write("...Cleaning project: {0}", project.Name);
788
789 ToolInfo toolInfo = (ToolInfo)tools[project.Language];
790 string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension);
791 string userFile = projectFile + ".user";
792
793 Helper.DeleteIfExists(projectFile);
794 Helper.DeleteIfExists(userFile);
795 }
796
797 private void CleanSolution(SolutionNode solution)
798 {
799 kernel.Log.Write("Cleaning {0} solution and project files", this.VersionName, solution.Name);
800
801 string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln");
802 string suoFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "suo");
803
804 Helper.DeleteIfExists(slnFile);
805 Helper.DeleteIfExists(suoFile);
806
807 foreach (ProjectNode project in solution.Projects)
808 {
809 CleanProject(project);
810 }
811
812 kernel.Log.Write("");
813 }
814
815 #endregion
816
817 #region ITarget Members
818
819 /// <summary>
820 /// Writes the specified kern.
821 /// </summary>
822 /// <param name="kern">The kern.</param>
823 public virtual void Write(Kernel kern)
824 {
825 if (kern == null)
826 {
827 throw new ArgumentNullException("kern");
828 }
829 kernel = kern;
830 foreach (SolutionNode sol in kernel.Solutions)
831 {
832 WriteSolution(sol);
833 }
834 kernel = null;
835 }
836
837 /// <summary>
838 /// Cleans the specified kern.
839 /// </summary>
840 /// <param name="kern">The kern.</param>
841 public virtual void Clean(Kernel kern)
842 {
843 if (kern == null)
844 {
845 throw new ArgumentNullException("kern");
846 }
847 kernel = kern;
848 foreach (SolutionNode sol in kernel.Solutions)
849 {
850 CleanSolution(sol);
851 }
852 kernel = null;
853 }
854
855 /// <summary>
856 /// Gets the name.
857 /// </summary>
858 /// <value>The name.</value>
859 public virtual string Name
860 {
861 get
862 {
863 return "vs2005";
864 }
865 }
866
867 #endregion
868 }
869}