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