aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Prebuild/src/Core/Targets/NAntTarget.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Prebuild/src/Core/Targets/NAntTarget.cs')
-rw-r--r--Prebuild/src/Core/Targets/NAntTarget.cs859
1 files changed, 451 insertions, 408 deletions
diff --git a/Prebuild/src/Core/Targets/NAntTarget.cs b/Prebuild/src/Core/Targets/NAntTarget.cs
index 9a6ee17..eb5325d 100644
--- a/Prebuild/src/Core/Targets/NAntTarget.cs
+++ b/Prebuild/src/Core/Targets/NAntTarget.cs
@@ -1,9 +1,9 @@
1#region BSD License 1#region BSD License
2/* 2/*
3Copyright (c) 2004 - 2008 3Copyright (c) 2004 - 2008
4Matthew Holmes (matthew@wildfiregames.com), 4Matthew Holmes (matthew@wildfiregames.com),
5Dan Moorehead (dan05a@gmail.com), 5Dan Moorehead (dan05a@gmail.com),
6C.J. Adams-Collier (cjac@colliertech.org), 6C.J. Adams-Collier (cjac@colliertech.org),
7 7
8Redistribution and use in source and binary forms, with or without 8Redistribution and use in source and binary forms, with or without
9modification, are permitted provided that the following conditions are 9modification, are permitted provided that the following conditions are
@@ -35,6 +35,15 @@ POSSIBILITY OF SUCH DAMAGE.
35 35
36#endregion 36#endregion
37 37
38#region CVS Information
39/*
40 * $Source$
41 * $Author: cjcollier $
42 * $Date: 2008-02-07 10:22:36 +0900 (Thu, 07 Feb 2008) $
43 * $Revision: 255 $
44 */
45#endregion
46
38using System; 47using System;
39using System.Collections; 48using System.Collections;
40using System.Collections.Specialized; 49using System.Collections.Specialized;
@@ -49,73 +58,85 @@ using Prebuild.Core.Utilities;
49 58
50namespace Prebuild.Core.Targets 59namespace Prebuild.Core.Targets
51{ 60{
52 /// <summary> 61 /// <summary>
53 /// 62 ///
54 /// </summary> 63 /// </summary>
55 [Target("nant")] 64 [Target("nant")]
56 public class NAntTarget : ITarget 65 public class NAntTarget : ITarget
57 { 66 {
58 #region Fields 67 #region Fields
59 68
60 private Kernel m_Kernel; 69 private Kernel m_Kernel;
61 70
62 #endregion 71 #endregion
63 72
64 #region Private Methods 73 #region Private Methods
65 74
66 private static string PrependPath(string path) 75 private static string PrependPath(string path)
67 { 76 {
68 string tmpPath = Helper.NormalizePath(path, '/'); 77 string tmpPath = Helper.NormalizePath(path, '/');
69 Regex regex = new Regex(@"(\w):/(\w+)"); 78 Regex regex = new Regex(@"(\w):/(\w+)");
70 Match match = regex.Match(tmpPath); 79 Match match = regex.Match(tmpPath);
71 //if(match.Success || tmpPath[0] == '.' || tmpPath[0] == '/') 80 //if(match.Success || tmpPath[0] == '.' || tmpPath[0] == '/')
72 //{ 81 //{
73 tmpPath = Helper.NormalizePath(tmpPath); 82 tmpPath = Helper.NormalizePath(tmpPath);
74 //} 83 //}
75 // else 84 // else
76 // { 85 // {
77 // tmpPath = Helper.NormalizePath("./" + tmpPath); 86 // tmpPath = Helper.NormalizePath("./" + tmpPath);
78 // } 87 // }
79 88
80 return tmpPath; 89 return tmpPath;
81 } 90 }
82 91
83 private static string BuildReference(SolutionNode solution, ProjectNode currentProject, ReferenceNode refr) 92 private static string BuildReference(SolutionNode solution, ProjectNode currentProject, ReferenceNode refr)
84 { 93 {
94 string ret = "";
95 string referencePath = ((ReferencePathNode)currentProject.ReferencePaths[0]).Path;
85 96
86 if (!String.IsNullOrEmpty(refr.Path)) 97 if (String.IsNullOrEmpty(refr.Path))
87 { 98 {
88 return refr.Path; 99 if (solution.ProjectsTable.ContainsKey(refr.Name))
89 } 100 {
90 101 ProjectNode project = (ProjectNode) solution.ProjectsTable[refr.Name];
91 if (solution.ProjectsTable.ContainsKey(refr.Name)) 102 string finalPath =
92 { 103 Helper.NormalizePath(referencePath + refr.Name + GetProjectExtension(project), '/');
93 ProjectNode projectRef = (ProjectNode) solution.ProjectsTable[refr.Name]; 104 return finalPath;
94 string finalPath = 105 }
95 Helper.NormalizePath(refr.Name + GetProjectExtension(projectRef), '/'); 106 else
96 return finalPath; 107 {
97 } 108 ProjectNode project = (ProjectNode) refr.Parent;
98 109
99 ProjectNode project = (ProjectNode) refr.Parent; 110 // Do we have an explicit file reference?
111 string fileRef = FindFileReference(refr.Name, project);
112 if (fileRef != null)
113 {
114 return fileRef;
115 }
100 116
101 // Do we have an explicit file reference? 117 // Is there an explicit path in the project ref?
102 string fileRef = FindFileReference(refr.Name, project); 118 if (refr.Path != null)
103 if (fileRef != null) 119 {
104 { 120 return Helper.NormalizePath(refr.Path + "/" + refr.Name + GetProjectExtension(project), '/');
105 return fileRef; 121 }
106 }
107 122
108 // Is there an explicit path in the project ref? 123 // Is it a specified extension (dll or exe?)
109 if (refr.Path != null) 124 if (ExtensionSpecified(refr.Name))
125 {
126 return Helper.NormalizePath(referencePath + GetRefFileName(refr.Name), '/');
127 }
128
129 // No, it's an extensionless GAC ref, but nant needs the .dll extension anyway
130 return refr.Name + ".dll";
131 }
132 }
133 else
110 { 134 {
111 return Helper.NormalizePath(refr.Path + "/" + refr.Name + GetProjectExtension(project), '/'); 135 return refr.Path;
112 } 136 }
113
114 // No, it's an extensionless GAC ref, but nant needs the .dll extension anyway
115 return refr.Name + ".dll";
116 } 137 }
117 138
118 public static string GetRefFileName(string refName) 139 public static string GetRefFileName(string refName)
119 { 140 {
120 if (ExtensionSpecified(refName)) 141 if (ExtensionSpecified(refName))
121 { 142 {
@@ -123,7 +144,7 @@ namespace Prebuild.Core.Targets
123 } 144 }
124 else 145 else
125 { 146 {
126 return refName + ".dll"; 147 return refName + ".dll";
127 } 148 }
128 } 149 }
129 150
@@ -135,235 +156,268 @@ namespace Prebuild.Core.Targets
135 private static string GetProjectExtension(ProjectNode project) 156 private static string GetProjectExtension(ProjectNode project)
136 { 157 {
137 string extension = ".dll"; 158 string extension = ".dll";
138 if (project.Type == ProjectType.Exe || project.Type == ProjectType.WinExe) 159 if (project.Type == ProjectType.Exe)
139 { 160 {
140 extension = ".exe"; 161 extension = ".exe";
141 } 162 }
142 return extension; 163 return extension;
143 } 164 }
144 165
145 private static string FindFileReference(string refName, ProjectNode project) 166 //private static string BuildReferencePath(SolutionNode solution, ReferenceNode refr)
146 { 167 //{
147 foreach (ReferencePathNode refPath in project.ReferencePaths) 168 // string ret = "";
148 { 169 // if (solution.ProjectsTable.ContainsKey(refr.Name))
149 string fullPath = Helper.MakeFilePath(refPath.Path, refName); 170 // {
171 // ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name];
172 // string finalPath = Helper.NormalizePath(((ReferencePathNode)project.ReferencePaths[0]).Path, '/');
173 // return finalPath;
174 // }
175 // else
176 // {
177 // if (refr.Path == null)
178 // {
179 // ProjectNode project = (ProjectNode) refr.Parent;
180 // string fileRef = FindFileReference(refr.Name, project);
181
182 // if (refr.Path != null || fileRef != null)
183 // {
184 // string finalPath = (refr.Path != null) ? Helper.NormalizePath(refr.Path, '/') : fileRef;
185 // ret += finalPath;
186 // return ret;
187 // }
188
189 // try
190 // {
191 // Assembly assem = Assembly.Load(refr.Name);
192 // if (assem != null)
193 // {
194 // ret += "";
195 // }
196 // else
197 // {
198 // ret += "";
199 // }
200 // }
201 // catch (System.NullReferenceException e)
202 // {
203 // e.ToString();
204 // ret += "";
205 // }
206 // }
207 // else
208 // {
209 // ret = refr.Path;
210 // }
211 // }
212 // return ret;
213 //}
214
215 private static string FindFileReference(string refName, ProjectNode project)
216 {
217 foreach (ReferencePathNode refPath in project.ReferencePaths)
218 {
219 string fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll");
150 220
151 if (File.Exists(fullPath)) 221 if (File.Exists(fullPath))
152 { 222 {
153 return fullPath; 223 return fullPath;
154 } 224 }
155 225
156 fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll");
157
158 if (File.Exists(fullPath))
159 {
160 return fullPath;
161 }
162
163 fullPath = Helper.MakeFilePath(refPath.Path, refName, "exe"); 226 fullPath = Helper.MakeFilePath(refPath.Path, refName, "exe");
164 227
165 if (File.Exists(fullPath)) 228 if (File.Exists(fullPath))
166 { 229 {
167 return fullPath; 230 return fullPath;
168 } 231 }
169 } 232 }
170 233
171 return null; 234 return null;
172 } 235 }
173 236
174 /// <summary> 237 /// <summary>
175 /// Gets the XML doc file. 238 /// Gets the XML doc file.
176 /// </summary> 239 /// </summary>
177 /// <param name="project">The project.</param> 240 /// <param name="project">The project.</param>
178 /// <param name="conf">The conf.</param> 241 /// <param name="conf">The conf.</param>
179 /// <returns></returns> 242 /// <returns></returns>
180 public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf) 243 public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf)
181 { 244 {
182 if (conf == null) 245 if (conf == null)
183 { 246 {
184 throw new ArgumentNullException("conf"); 247 throw new ArgumentNullException("conf");
185 } 248 }
186 if (project == null) 249 if (project == null)
187 { 250 {
188 throw new ArgumentNullException("project"); 251 throw new ArgumentNullException("project");
189 } 252 }
190 string docFile = (string)conf.Options["XmlDocFile"]; 253 string docFile = (string)conf.Options["XmlDocFile"];
191 // if(docFile != null && docFile.Length == 0)//default to assembly name if not specified 254 // if(docFile != null && docFile.Length == 0)//default to assembly name if not specified
192 // { 255 // {
193 // return Path.GetFileNameWithoutExtension(project.AssemblyName) + ".xml"; 256 // return Path.GetFileNameWithoutExtension(project.AssemblyName) + ".xml";
194 // } 257 // }
195 return docFile; 258 return docFile;
196 } 259 }
197 260
198 private void WriteProject(SolutionNode solution, ProjectNode project) 261 private void WriteProject(SolutionNode solution, ProjectNode project)
199 { 262 {
200 string projFile = Helper.MakeFilePath(project.FullPath, project.Name + GetProjectExtension(project), "build"); 263 string projFile = Helper.MakeFilePath(project.FullPath, project.Name + GetProjectExtension(project), "build");
201 StreamWriter ss = new StreamWriter(projFile); 264 StreamWriter ss = new StreamWriter(projFile);
202 265
203 m_Kernel.CurrentWorkingDirectory.Push(); 266 m_Kernel.CurrentWorkingDirectory.Push();
204 Helper.SetCurrentDir(Path.GetDirectoryName(projFile)); 267 Helper.SetCurrentDir(Path.GetDirectoryName(projFile));
205 bool hasDoc = false; 268 bool hasDoc = false;
206 269
207 using (ss) 270 using (ss)
208 { 271 {
209 ss.WriteLine("<?xml version=\"1.0\" ?>"); 272 ss.WriteLine("<?xml version=\"1.0\" ?>");
210 ss.WriteLine("<project name=\"{0}\" default=\"build\">", project.Name); 273 ss.WriteLine("<project name=\"{0}\" default=\"build\">", project.Name);
211 ss.WriteLine(" <target name=\"{0}\">", "build"); 274 ss.WriteLine(" <target name=\"{0}\">", "build");
212 ss.WriteLine(" <echo message=\"Build Directory is ${project::get-base-directory()}/${build.dir}\" />"); 275 ss.WriteLine(" <echo message=\"Build Directory is ${project::get-base-directory()}/${build.dir}\" />");
213 ss.WriteLine(" <mkdir dir=\"${project::get-base-directory()}/${build.dir}\" />"); 276 ss.WriteLine(" <mkdir dir=\"${project::get-base-directory()}/${build.dir}\" />");
214 ss.WriteLine(" <copy todir=\"${project::get-base-directory()}/${build.dir}\" flatten=\"true\">"); 277 ss.WriteLine(" <copy todir=\"${project::get-base-directory()}/${build.dir}\" flatten=\"true\">");
215 ss.WriteLine(" <fileset basedir=\"${project::get-base-directory()}\">"); 278 ss.WriteLine(" <fileset basedir=\"${project::get-base-directory()}\">");
216 foreach (ReferenceNode refr in project.References) 279 foreach (ReferenceNode refr in project.References)
217 { 280 {
218 if (refr.LocalCopy) 281 if (refr.LocalCopy)
219 { 282 {
220 ss.WriteLine(" <include name=\"{0}", Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReference(solution, project, refr)) + "\" />", '/')); 283 ss.WriteLine(" <include name=\"{0}", Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReference(solution, project, refr)) + "\" />", '/'));
221 } 284 }
222 } 285 }
223 286
224 ss.WriteLine(" </fileset>"); 287 ss.WriteLine(" </fileset>");
225 ss.WriteLine(" </copy>"); 288 ss.WriteLine(" </copy>");
226 if (project.ConfigFile != null && project.ConfigFile.Length!=0) 289 if (project.ConfigFile != null && project.ConfigFile.Length!=0)
227 { 290 {
228 ss.Write(" <copy file=\"" + project.ConfigFile + "\" tofile=\"${project::get-base-directory()}/${build.dir}/${project::get-name()}"); 291 ss.Write(" <copy file=\"" + project.ConfigFile + "\" tofile=\"${project::get-base-directory()}/${build.dir}/${project::get-name()}");
229 292
230 if (project.Type == ProjectType.Library) 293 if (project.Type == ProjectType.Library)
231 { 294 {
232 ss.Write(".dll.config\""); 295 ss.Write(".dll.config\"");
233 } 296 }
234 else 297 else
235 { 298 {
236 ss.Write(".exe.config\""); 299 ss.Write(".exe.config\"");
237 } 300 }
238 ss.WriteLine(" />"); 301 ss.WriteLine(" />");
239 } 302 }
240 303
241 // Add the content files to just be copied 304 // Add the content files to just be copied
242 ss.WriteLine(" {0}", "<copy todir=\"${project::get-base-directory()}/${build.dir}\">"); 305 ss.WriteLine(" {0}", "<copy todir=\"${project::get-base-directory()}/${build.dir}\">");
243 ss.WriteLine(" {0}", "<fileset basedir=\".\">"); 306 ss.WriteLine(" {0}", "<fileset basedir=\".\">");
244 307
245 foreach (string file in project.Files) 308 foreach (string file in project.Files)
246 { 309 {
247 // Ignore if we aren't content 310 // Ignore if we aren't content
248 if (project.Files.GetBuildAction(file) != BuildAction.Content) 311 if (project.Files.GetBuildAction(file) != BuildAction.Content)
249 continue; 312 continue;
250 313
251 // Create a include tag 314 // Create a include tag
252 ss.WriteLine(" {0}", "<include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />"); 315 ss.WriteLine(" {0}", "<include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />");
253 } 316 }
254 317
255 ss.WriteLine(" {0}", "</fileset>"); 318 ss.WriteLine(" {0}", "</fileset>");
256 ss.WriteLine(" {0}", "</copy>"); 319 ss.WriteLine(" {0}", "</copy>");
257 320
258 ss.Write(" <csc"); 321 ss.Write(" <csc");
259 ss.Write(" target=\"{0}\"", project.Type.ToString().ToLower()); 322 ss.Write(" target=\"{0}\"", project.Type.ToString().ToLower());
260 ss.Write(" debug=\"{0}\"", "${build.debug}"); 323 ss.Write(" debug=\"{0}\"", "${build.debug}");
261 foreach (ConfigurationNode conf in project.Configurations) 324 foreach (ConfigurationNode conf in project.Configurations)
262 { 325 {
263 if (conf.Options.KeyFile != "") 326 if (conf.Options.KeyFile != "")
264 { 327 {
265 ss.Write(" keyfile=\"{0}\"", conf.Options.KeyFile); 328 ss.Write(" keyfile=\"{0}\"", conf.Options.KeyFile);
266 break; 329 break;
267 } 330 }
268 } 331 }
269 foreach (ConfigurationNode conf in project.Configurations) 332 foreach (ConfigurationNode conf in project.Configurations)
270 {
271 ss.Write(" unsafe=\"{0}\"", conf.Options.AllowUnsafe);
272 break;
273 }
274 foreach (ConfigurationNode conf in project.Configurations)
275 {
276 ss.Write(" warnaserror=\"{0}\"", conf.Options.WarningsAsErrors);
277 break;
278 }
279 foreach (ConfigurationNode conf in project.Configurations)
280 {
281 ss.Write(" define=\"{0}\"", conf.Options.CompilerDefines);
282 break;
283 }
284 foreach (ConfigurationNode conf in project.Configurations)
285 {
286 ss.Write(" nostdlib=\"{0}\"", conf.Options["NoStdLib"]);
287 break;
288 }
289
290 ss.Write(" main=\"{0}\"", project.StartupObject);
291
292 foreach (ConfigurationNode conf in project.Configurations)
293 {
294 if (GetXmlDocFile(project, conf) != "")
295 {
296 ss.Write(" doc=\"{0}\"", "${project::get-base-directory()}/${build.dir}/" + GetXmlDocFile(project, conf));
297 hasDoc = true;
298 }
299 break;
300 }
301 ss.Write(" output=\"{0}", "${project::get-base-directory()}/${build.dir}/${project::get-name()}");
302 if (project.Type == ProjectType.Library)
303 {
304 ss.Write(".dll\"");
305 }
306 else
307 {
308 ss.Write(".exe\"");
309 }
310 if (project.AppIcon != null && project.AppIcon.Length != 0)
311 {
312 ss.Write(" win32icon=\"{0}\"", Helper.NormalizePath(project.AppIcon, '/'));
313 }
314 ss.WriteLine(">");
315 ss.WriteLine(" <resources prefix=\"{0}\" dynamicprefix=\"true\" >", project.RootNamespace);
316 foreach (string file in project.Files)
317 {
318 switch (project.Files.GetBuildAction(file))
319 {
320 case BuildAction.EmbeddedResource:
321 ss.WriteLine(" {0}", "<include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />");
322 break;
323 default:
324 if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings)
325 {
326 ss.WriteLine(" <include name=\"{0}\" />", file.Substring(0, file.LastIndexOf('.')) + ".resx");
327 }
328 break;
329 }
330 }
331 //if (project.Files.GetSubType(file).ToString() != "Code")
332 //{
333 // ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".resx");
334
335 ss.WriteLine(" </resources>");
336 ss.WriteLine(" <sources failonempty=\"true\">");
337 foreach (string file in project.Files)
338 {
339 switch (project.Files.GetBuildAction(file))
340 {
341 case BuildAction.Compile:
342 ss.WriteLine(" <include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />");
343 break;
344 default:
345 break;
346 }
347 }
348 ss.WriteLine(" </sources>");
349 ss.WriteLine(" <references basedir=\"${project::get-base-directory()}\">");
350 ss.WriteLine(" <lib>");
351 ss.WriteLine(" <include name=\"${project::get-base-directory()}\" />");
352 foreach(ReferencePathNode refPath in project.ReferencePaths)
353 { 333 {
354 ss.WriteLine(" <include name=\"${project::get-base-directory()}/" + refPath.Path.TrimEnd('/', '\\') + "\" />"); 334 ss.Write(" unsafe=\"{0}\"", conf.Options.AllowUnsafe);
335 break;
355 } 336 }
356 ss.WriteLine(" </lib>"); 337 foreach (ConfigurationNode conf in project.Configurations)
357 foreach (ReferenceNode refr in project.References) 338 {
358 { 339 ss.Write(" warnaserror=\"{0}\"", conf.Options.WarningsAsErrors);
359 string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReference(solution, project, refr)), '/'); 340 break;
341 }
342 foreach (ConfigurationNode conf in project.Configurations)
343 {
344 ss.Write(" define=\"{0}\"", conf.Options.CompilerDefines);
345 break;
346 }
347 ss.Write(" main=\"{0}\"", project.StartupObject);
348
349 foreach (ConfigurationNode conf in project.Configurations)
350 {
351 if (GetXmlDocFile(project, conf) != "")
352 {
353 ss.Write(" doc=\"{0}\"", "${project::get-base-directory()}/${build.dir}/" + GetXmlDocFile(project, conf));
354 hasDoc = true;
355 }
356 break;
357 }
358 ss.Write(" output=\"{0}", "${project::get-base-directory()}/${build.dir}/${project::get-name()}");
359 if (project.Type == ProjectType.Library)
360 {
361 ss.Write(".dll\"");
362 }
363 else
364 {
365 ss.Write(".exe\"");
366 }
367 if (project.AppIcon != null && project.AppIcon.Length != 0)
368 {
369 ss.Write(" win32icon=\"{0}\"", Helper.NormalizePath(project.AppIcon, '/'));
370 }
371 ss.WriteLine(">");
372 ss.WriteLine(" <resources prefix=\"{0}\" dynamicprefix=\"true\" >", project.RootNamespace);
373 foreach (string file in project.Files)
374 {
375 switch (project.Files.GetBuildAction(file))
376 {
377 case BuildAction.EmbeddedResource:
378 ss.WriteLine(" {0}", "<include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />");
379 break;
380 default:
381 if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings)
382 {
383 ss.WriteLine(" <include name=\"{0}\" />", file.Substring(0, file.LastIndexOf('.')) + ".resx");
384 }
385 break;
386 }
387 }
388 //if (project.Files.GetSubType(file).ToString() != "Code")
389 //{
390 // ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".resx");
391
392 ss.WriteLine(" </resources>");
393 ss.WriteLine(" <sources failonempty=\"true\">");
394 foreach (string file in project.Files)
395 {
396 switch (project.Files.GetBuildAction(file))
397 {
398 case BuildAction.Compile:
399 ss.WriteLine(" <include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />");
400 break;
401 default:
402 break;
403 }
404 }
405 ss.WriteLine(" </sources>");
406 ss.WriteLine(" <references basedir=\"${project::get-base-directory()}\">");
407 ss.WriteLine(" <lib>");
408 ss.WriteLine(" <include name=\"${project::get-base-directory()}\" />");
409 ss.WriteLine(" <include name=\"${project::get-base-directory()}/${build.dir}\" />");
410 ss.WriteLine(" </lib>");
411 foreach (ReferenceNode refr in project.References)
412 {
413 string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReference(solution, project, refr)), '/');
360 ss.WriteLine(" <include name=\"" + path + "\" />"); 414 ss.WriteLine(" <include name=\"" + path + "\" />");
361 } 415 }
362 ss.WriteLine(" </references>"); 416 ss.WriteLine(" </references>");
363 417
364 ss.WriteLine(" </csc>"); 418 ss.WriteLine(" </csc>");
365 419
366 foreach (ConfigurationNode conf in project.Configurations) 420 foreach (ConfigurationNode conf in project.Configurations)
367 { 421 {
368 if (!String.IsNullOrEmpty(conf.Options.OutputPath)) 422 if (!String.IsNullOrEmpty(conf.Options.OutputPath))
369 { 423 {
@@ -378,160 +432,149 @@ namespace Prebuild.Core.Targets
378 ss.WriteLine(" <include name=\"*.dll\"/>"); 432 ss.WriteLine(" <include name=\"*.dll\"/>");
379 ss.WriteLine(" <include name=\"*.exe\"/>"); 433 ss.WriteLine(" <include name=\"*.exe\"/>");
380 ss.WriteLine(" <include name=\"*.mdb\" if='${build.debug}'/>"); 434 ss.WriteLine(" <include name=\"*.mdb\" if='${build.debug}'/>");
381 ss.WriteLine(" <include name=\"*.pdb\" if='${build.debug}'/>");
382 ss.WriteLine(" </fileset>"); 435 ss.WriteLine(" </fileset>");
383 ss.WriteLine(" </copy>"); 436 ss.WriteLine(" </copy>");
384 break; 437 break;
385 } 438 }
386 } 439 }
387 440
388 ss.WriteLine(" </target>"); 441 ss.WriteLine(" </target>");
389 442
390 ss.WriteLine(" <target name=\"clean\">"); 443 ss.WriteLine(" <target name=\"clean\">");
391 ss.WriteLine(" <delete dir=\"${bin.dir}\" failonerror=\"false\" />"); 444 ss.WriteLine(" <delete dir=\"${obj.dir}\" failonerror=\"false\" />");
392 ss.WriteLine(" <delete dir=\"${obj.dir}\" failonerror=\"false\" />"); 445 ss.WriteLine(" <delete dir=\"${bin.dir}\" failonerror=\"false\" />");
393 ss.WriteLine(" </target>"); 446 ss.WriteLine(" </target>");
394 447
395 ss.WriteLine(" <target name=\"doc\" description=\"Creates documentation.\">"); 448 ss.WriteLine(" <target name=\"doc\" description=\"Creates documentation.\">");
396 if (hasDoc) 449 if (hasDoc)
397 { 450 {
398 ss.WriteLine(" <property name=\"doc.target\" value=\"\" />"); 451 ss.WriteLine(" <property name=\"doc.target\" value=\"\" />");
399 ss.WriteLine(" <if test=\"${platform::is-unix()}\">"); 452 ss.WriteLine(" <if test=\"${platform::is-unix()}\">");
400 ss.WriteLine(" <property name=\"doc.target\" value=\"Web\" />"); 453 ss.WriteLine(" <property name=\"doc.target\" value=\"Web\" />");
401 ss.WriteLine(" </if>"); 454 ss.WriteLine(" </if>");
402 ss.WriteLine(" <ndoc failonerror=\"false\" verbose=\"true\">"); 455 ss.WriteLine(" <ndoc failonerror=\"false\" verbose=\"true\">");
403 ss.WriteLine(" <assemblies basedir=\"${project::get-base-directory()}\">"); 456 ss.WriteLine(" <assemblies basedir=\"${project::get-base-directory()}\">");
404 ss.Write(" <include name=\"${build.dir}/${project::get-name()}"); 457 ss.Write(" <include name=\"${build.dir}/${project::get-name()}");
405 if (project.Type == ProjectType.Library) 458 if (project.Type == ProjectType.Library)
406 { 459 {
407 ss.WriteLine(".dll\" />"); 460 ss.WriteLine(".dll\" />");
408 } 461 }
409 else 462 else
410 { 463 {
411 ss.WriteLine(".exe\" />"); 464 ss.WriteLine(".exe\" />");
412 } 465 }
413 466
414 ss.WriteLine(" </assemblies>"); 467 ss.WriteLine(" </assemblies>");
415 ss.WriteLine(" <summaries basedir=\"${project::get-base-directory()}\">"); 468 ss.WriteLine(" <summaries basedir=\"${project::get-base-directory()}\">");
416 ss.WriteLine(" <include name=\"${build.dir}/${project::get-name()}.xml\"/>"); 469 ss.WriteLine(" <include name=\"${build.dir}/${project::get-name()}.xml\"/>");
417 ss.WriteLine(" </summaries>"); 470 ss.WriteLine(" </summaries>");
418 ss.WriteLine(" <referencepaths basedir=\"${project::get-base-directory()}\">"); 471 ss.WriteLine(" <referencepaths basedir=\"${project::get-base-directory()}\">");
419 ss.WriteLine(" <include name=\"${build.dir}\" />"); 472 ss.WriteLine(" <include name=\"${build.dir}\" />");
420 // foreach(ReferenceNode refr in project.References) 473 // foreach(ReferenceNode refr in project.References)
421 // { 474 // {
422 // string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReferencePath(solution, refr)), '/'); 475 // string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReferencePath(solution, refr)), '/');
423 // if (path != "") 476 // if (path != "")
424 // { 477 // {
425 // ss.WriteLine(" <include name=\"{0}\" />", path); 478 // ss.WriteLine(" <include name=\"{0}\" />", path);
426 // } 479 // }
427 // } 480 // }
428 ss.WriteLine(" </referencepaths>"); 481 ss.WriteLine(" </referencepaths>");
429 ss.WriteLine(" <documenters>"); 482 ss.WriteLine(" <documenters>");
430 ss.WriteLine(" <documenter name=\"MSDN\">"); 483 ss.WriteLine(" <documenter name=\"MSDN\">");
431 ss.WriteLine(" <property name=\"OutputDirectory\" value=\"${project::get-base-directory()}/${build.dir}/doc/${project::get-name()}\" />"); 484 ss.WriteLine(" <property name=\"OutputDirectory\" value=\"${project::get-base-directory()}/${build.dir}/doc/${project::get-name()}\" />");
432 ss.WriteLine(" <property name=\"OutputTarget\" value=\"${doc.target}\" />"); 485 ss.WriteLine(" <property name=\"OutputTarget\" value=\"${doc.target}\" />");
433 ss.WriteLine(" <property name=\"HtmlHelpName\" value=\"${project::get-name()}\" />"); 486 ss.WriteLine(" <property name=\"HtmlHelpName\" value=\"${project::get-name()}\" />");
434 ss.WriteLine(" <property name=\"IncludeFavorites\" value=\"False\" />"); 487 ss.WriteLine(" <property name=\"IncludeFavorites\" value=\"False\" />");
435 ss.WriteLine(" <property name=\"Title\" value=\"${project::get-name()} SDK Documentation\" />"); 488 ss.WriteLine(" <property name=\"Title\" value=\"${project::get-name()} SDK Documentation\" />");
436 ss.WriteLine(" <property name=\"SplitTOCs\" value=\"False\" />"); 489 ss.WriteLine(" <property name=\"SplitTOCs\" value=\"False\" />");
437 ss.WriteLine(" <property name=\"DefaulTOC\" value=\"\" />"); 490 ss.WriteLine(" <property name=\"DefaulTOC\" value=\"\" />");
438 ss.WriteLine(" <property name=\"ShowVisualBasic\" value=\"True\" />"); 491 ss.WriteLine(" <property name=\"ShowVisualBasic\" value=\"True\" />");
439 ss.WriteLine(" <property name=\"AutoDocumentConstructors\" value=\"True\" />"); 492 ss.WriteLine(" <property name=\"AutoDocumentConstructors\" value=\"True\" />");
440 ss.WriteLine(" <property name=\"ShowMissingSummaries\" value=\"${build.debug}\" />"); 493 ss.WriteLine(" <property name=\"ShowMissingSummaries\" value=\"${build.debug}\" />");
441 ss.WriteLine(" <property name=\"ShowMissingRemarks\" value=\"${build.debug}\" />"); 494 ss.WriteLine(" <property name=\"ShowMissingRemarks\" value=\"${build.debug}\" />");
442 ss.WriteLine(" <property name=\"ShowMissingParams\" value=\"${build.debug}\" />"); 495 ss.WriteLine(" <property name=\"ShowMissingParams\" value=\"${build.debug}\" />");
443 ss.WriteLine(" <property name=\"ShowMissingReturns\" value=\"${build.debug}\" />"); 496 ss.WriteLine(" <property name=\"ShowMissingReturns\" value=\"${build.debug}\" />");
444 ss.WriteLine(" <property name=\"ShowMissingValues\" value=\"${build.debug}\" />"); 497 ss.WriteLine(" <property name=\"ShowMissingValues\" value=\"${build.debug}\" />");
445 ss.WriteLine(" <property name=\"DocumentInternals\" value=\"False\" />"); 498 ss.WriteLine(" <property name=\"DocumentInternals\" value=\"False\" />");
446 ss.WriteLine(" <property name=\"DocumentPrivates\" value=\"False\" />"); 499 ss.WriteLine(" <property name=\"DocumentPrivates\" value=\"False\" />");
447 ss.WriteLine(" <property name=\"DocumentProtected\" value=\"True\" />"); 500 ss.WriteLine(" <property name=\"DocumentProtected\" value=\"True\" />");
448 ss.WriteLine(" <property name=\"DocumentEmptyNamespaces\" value=\"${build.debug}\" />"); 501 ss.WriteLine(" <property name=\"DocumentEmptyNamespaces\" value=\"${build.debug}\" />");
449 ss.WriteLine(" <property name=\"IncludeAssemblyVersion\" value=\"True\" />"); 502 ss.WriteLine(" <property name=\"IncludeAssemblyVersion\" value=\"True\" />");
450 ss.WriteLine(" </documenter>"); 503 ss.WriteLine(" </documenter>");
451 ss.WriteLine(" </documenters>"); 504 ss.WriteLine(" </documenters>");
452 ss.WriteLine(" </ndoc>"); 505 ss.WriteLine(" </ndoc>");
453 } 506 }
454 ss.WriteLine(" </target>"); 507 ss.WriteLine(" </target>");
455 ss.WriteLine("</project>"); 508 ss.WriteLine("</project>");
456 } 509 }
457 m_Kernel.CurrentWorkingDirectory.Pop(); 510 m_Kernel.CurrentWorkingDirectory.Pop();
458 } 511 }
459 512
460 private void WriteCombine(SolutionNode solution) 513 private void WriteCombine(SolutionNode solution)
461 { 514 {
462 m_Kernel.Log.Write("Creating NAnt build files"); 515 m_Kernel.Log.Write("Creating NAnt build files");
463 foreach (ProjectNode project in solution.Projects) 516 foreach (ProjectNode project in solution.Projects)
464 { 517 {
465 if (m_Kernel.AllowProject(project.FilterGroups)) 518 if (m_Kernel.AllowProject(project.FilterGroups))
466 { 519 {
467 m_Kernel.Log.Write("...Creating project: {0}", project.Name); 520 m_Kernel.Log.Write("...Creating project: {0}", project.Name);
468 WriteProject(solution, project); 521 WriteProject(solution, project);
469 } 522 }
470 } 523 }
471 524
472 m_Kernel.Log.Write(""); 525 m_Kernel.Log.Write("");
473 string combFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "build"); 526 string combFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "build");
474 StreamWriter ss = new StreamWriter(combFile); 527 StreamWriter ss = new StreamWriter(combFile);
475 528
476 m_Kernel.CurrentWorkingDirectory.Push(); 529 m_Kernel.CurrentWorkingDirectory.Push();
477 Helper.SetCurrentDir(Path.GetDirectoryName(combFile)); 530 Helper.SetCurrentDir(Path.GetDirectoryName(combFile));
478 531
479 using (ss) 532 using (ss)
480 { 533 {
481 ss.WriteLine("<?xml version=\"1.0\" ?>"); 534 ss.WriteLine("<?xml version=\"1.0\" ?>");
482 ss.WriteLine("<project name=\"{0}\" default=\"build\">", solution.Name); 535 ss.WriteLine("<project name=\"{0}\" default=\"build\">", solution.Name);
483 ss.WriteLine(" <echo message=\"Using '${nant.settings.currentframework}' Framework\"/>"); 536 ss.WriteLine(" <echo message=\"Using '${nant.settings.currentframework}' Framework\"/>");
484 ss.WriteLine(); 537 ss.WriteLine();
485 538
486 //ss.WriteLine(" <property name=\"dist.dir\" value=\"dist\" />"); 539 //ss.WriteLine(" <property name=\"dist.dir\" value=\"dist\" />");
487 //ss.WriteLine(" <property name=\"source.dir\" value=\"source\" />"); 540 //ss.WriteLine(" <property name=\"source.dir\" value=\"source\" />");
488 ss.WriteLine(" <property name=\"bin.dir\" value=\"bin\" />"); 541 ss.WriteLine(" <property name=\"bin.dir\" value=\"bin\" />");
489 ss.WriteLine(" <property name=\"obj.dir\" value=\"obj\" />"); 542 ss.WriteLine(" <property name=\"obj.dir\" value=\"obj\" />");
490 ss.WriteLine(" <property name=\"doc.dir\" value=\"doc\" />"); 543 ss.WriteLine(" <property name=\"doc.dir\" value=\"doc\" />");
491 ss.WriteLine(" <property name=\"project.main.dir\" value=\"${project::get-base-directory()}\" />"); 544 ss.WriteLine(" <property name=\"project.main.dir\" value=\"${project::get-base-directory()}\" />");
492 545
493 // actually use active config out of prebuild.xml 546 // actually use active config out of prebuild.xml
494 ss.WriteLine(" <property name=\"project.config\" value=\"{0}\" />", solution.ActiveConfig); 547 ss.WriteLine(" <property name=\"project.config\" value=\"{0}\" />", solution.ActiveConfig);
495 548
496 foreach (ConfigurationNode conf in solution.Configurations) 549 foreach (ConfigurationNode conf in solution.Configurations)
497 { 550 {
498 ss.WriteLine(); 551 ss.WriteLine();
499 ss.WriteLine(" <target name=\"{0}\" description=\"\">", conf.Name); 552 ss.WriteLine(" <target name=\"{0}\" description=\"\">", conf.Name);
500 ss.WriteLine(" <property name=\"project.config\" value=\"{0}\" />", conf.Name); 553 ss.WriteLine(" <property name=\"project.config\" value=\"{0}\" />", conf.Name);
501 ss.WriteLine(" <property name=\"build.debug\" value=\"{0}\" />", conf.Options["DebugInformation"].ToString().ToLower()); 554 ss.WriteLine(" <property name=\"build.debug\" value=\"{0}\" />", conf.Options["DebugInformation"].ToString().ToLower());
502 ss.WriteLine(" </target>"); 555 ss.WriteLine(" </target>");
503 ss.WriteLine(); 556 ss.WriteLine();
504 } 557 }
505 558
506 ss.WriteLine(" <target name=\"net-1.1\" description=\"Sets framework to .NET 1.1\">"); 559 ss.WriteLine(" <target name=\"net-1.1\" description=\"Sets framework to .NET 1.1\">");
507 ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"net-1.1\" />"); 560 ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"net-1.1\" />");
508 ss.WriteLine(" </target>"); 561 ss.WriteLine(" </target>");
509 ss.WriteLine(); 562 ss.WriteLine();
510 563
511 ss.WriteLine(" <target name=\"net-2.0\" description=\"Sets framework to .NET 2.0\">"); 564 ss.WriteLine(" <target name=\"net-2.0\" description=\"Sets framework to .NET 2.0\">");
512 ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"net-2.0\" />"); 565 ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"net-2.0\" />");
513 ss.WriteLine(" </target>"); 566 ss.WriteLine(" </target>");
514 ss.WriteLine(); 567 ss.WriteLine();
515 568
516 ss.WriteLine(" <target name=\"net-3.5\" description=\"Sets framework to .NET 3.5\">"); 569 ss.WriteLine(" <target name=\"mono-2.0\" description=\"Sets framework to mono 2.0\">");
517 ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"net-3.5\" />"); 570 ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"mono-2.0\" />");
518 ss.WriteLine(" </target>"); 571 ss.WriteLine(" </target>");
519 ss.WriteLine(); 572 ss.WriteLine();
520 573
521 ss.WriteLine(" <target name=\"mono-1.0\" description=\"Sets framework to mono 1.0\">"); 574 ss.WriteLine(" <target name=\"mono-1.0\" description=\"Sets framework to mono 1.0\">");
522 ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"mono-1.0\" />"); 575 ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"mono-1.0\" />");
523 ss.WriteLine(" </target>"); 576 ss.WriteLine(" </target>");
524 ss.WriteLine(); 577 ss.WriteLine();
525
526 ss.WriteLine(" <target name=\"mono-2.0\" description=\"Sets framework to mono 2.0\">");
527 ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"mono-2.0\" />");
528 ss.WriteLine(" </target>");
529 ss.WriteLine();
530
531 ss.WriteLine(" <target name=\"mono-3.5\" description=\"Sets framework to mono 3.5\">");
532 ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"mono-3.5\" />");
533 ss.WriteLine(" </target>");
534 ss.WriteLine();
535 578
536 ss.WriteLine(" <target name=\"init\" description=\"\">"); 579 ss.WriteLine(" <target name=\"init\" description=\"\">");
537 ss.WriteLine(" <call target=\"${project.config}\" />"); 580 ss.WriteLine(" <call target=\"${project.config}\" />");