aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Prebuild/src
diff options
context:
space:
mode:
Diffstat (limited to 'Prebuild/src')
-rw-r--r--Prebuild/src/Core/Targets/NAntTarget.cs784
1 files changed, 399 insertions, 385 deletions
diff --git a/Prebuild/src/Core/Targets/NAntTarget.cs b/Prebuild/src/Core/Targets/NAntTarget.cs
index e9870db..5355eef 100644
--- a/Prebuild/src/Core/Targets/NAntTarget.cs
+++ b/Prebuild/src/Core/Targets/NAntTarget.cs
@@ -47,301 +47,311 @@ using Prebuild.Core.Utilities;
47namespace Prebuild.Core.Targets 47namespace Prebuild.Core.Targets
48{ 48{
49 /// <summary> 49 /// <summary>
50/// 50 ///
51/// </summary> 51 /// </summary>
52[Target("nant")] 52 [Target("nant")]
53public class NAntTarget : ITarget 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, ProjectNode currentProject, ReferenceNode refr)
81 { 54 {
82 string ret = ""; 55 #region Fields
83 if(solution.ProjectsTable.ContainsKey(refr.Name)) 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, ProjectNode currentProject, ReferenceNode refr)
81 {
82 string ret = "";
83 if (solution.ProjectsTable.ContainsKey(refr.Name))
84 { 84 {
85 ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name]; 85 ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name];
86 86
87 string finalPath = Helper.NormalizePath(((ReferencePathNode)currentProject.ReferencePaths[0]).Path + refr.Name + ".dll", '/'); 87 string finalPath = Helper.NormalizePath(((ReferencePathNode)currentProject.ReferencePaths[0]).Path + refr.Name + GetProjectExtension(project), '/');
88 88
89 return finalPath; 89 return finalPath;
90 } 90 }
91 else 91 else
92 { 92 {
93 ProjectNode project = (ProjectNode)refr.Parent; 93 ProjectNode project = (ProjectNode)refr.Parent;
94 string fileRef = FindFileReference(refr.Name, project); 94 string fileRef = FindFileReference(refr.Name, project);
95 95
96 if(refr.Path != null || fileRef != null) 96 if (refr.Path != null || fileRef != null)
97 { 97 {
98 string finalPath = (refr.Path != null) ? Helper.NormalizePath(refr.Path + "/" + refr.Name + ".dll", '/') : fileRef; 98 string finalPath = (refr.Path != null) ? Helper.NormalizePath(refr.Path + "/" + refr.Name + GetProjectExtension(project), '/') : fileRef;
99 ret += finalPath; 99 ret += finalPath;
100 return ret; 100 return ret;
101 } 101 }
102 102
103 try 103 try
104 { 104 {
105 //Assembly assem = Assembly.Load(refr.Name); 105 //Assembly assem = Assembly.Load(refr.Name);
106 //if (assem != null) 106 //if (assem != null)
107 //{ 107 //{
108 //ret += (refr.Name + ".dll"); 108 //ret += (refr.Name + ".dll");
109 //} 109 //}
110 //else 110 //else
111 //{ 111 //{
112 ret += (refr.Name + ".dll"); 112 ret += (refr.Name + GetProjectExtension(project));
113 //} 113 //}
114 } 114 }
115 catch (System.NullReferenceException e) 115 catch (System.NullReferenceException e)
116 { 116 {
117 e.ToString(); 117 e.ToString();
118 ret += refr.Name + ".dll"; 118 ret += refr.Name + GetProjectExtension(project);
119 } 119 }
120 } 120 }
121 return ret; 121 return ret;
122 } 122 }
123 123
124 private static string BuildReferencePath(SolutionNode solution, ReferenceNode refr) 124 private static string GetProjectExtension(ProjectNode project)
125 { 125 {
126 string ret = ""; 126 string extension = ".dll";
127 if(solution.ProjectsTable.ContainsKey(refr.Name)) 127 if (project.Type == ProjectType.Exe)
128 {
129 extension = ".exe";
130 }
131 return extension;
132 }
133
134 private static string BuildReferencePath(SolutionNode solution, ReferenceNode refr)
135 {
136 string ret = "";
137 if (solution.ProjectsTable.ContainsKey(refr.Name))
128 { 138 {
129 ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name]; 139 ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name];
130 string finalPath = Helper.NormalizePath(((ReferencePathNode)project.ReferencePaths[0]).Path, '/'); 140 string finalPath = Helper.NormalizePath(((ReferencePathNode)project.ReferencePaths[0]).Path, '/');
131 141
132 return finalPath; 142 return finalPath;
133 } 143 }
134 else 144 else
135 { 145 {
136 ProjectNode project = (ProjectNode)refr.Parent; 146 ProjectNode project = (ProjectNode)refr.Parent;
137 string fileRef = FindFileReference(refr.Name, project); 147 string fileRef = FindFileReference(refr.Name, project);
138 148
139 if(refr.Path != null || fileRef != null) 149 if (refr.Path != null || fileRef != null)
140 { 150 {
141 string finalPath = (refr.Path != null) ? Helper.NormalizePath(refr.Path, '/') : fileRef; 151 string finalPath = (refr.Path != null) ? Helper.NormalizePath(refr.Path, '/') : fileRef;
142 ret += finalPath; 152 ret += finalPath;
143 return ret; 153 return ret;
144 } 154 }
145 155
146 try 156 try
157 {
158 Assembly assem = Assembly.Load(refr.Name);
159 if (assem != null)
147 { 160 {
148 Assembly assem = Assembly.Load(refr.Name); 161 ret += "";
149 if (assem != null)
150 {
151 ret += "";
152 }
153 else
154 {
155 ret += "";
156 }
157 } 162 }
158 catch (System.NullReferenceException e) 163 else
159 { 164 {
160 e.ToString();
161 ret += ""; 165 ret += "";
162 } 166 }
167 }
168 catch (System.NullReferenceException e)
169 {
170 e.ToString();
171 ret += "";
172 }
163 } 173 }
164 return ret; 174 return ret;
165 } 175 }
166 176
167 private static string FindFileReference(string refName, ProjectNode project) 177 private static string FindFileReference(string refName, ProjectNode project)
168 { 178 {
169 foreach(ReferencePathNode refPath in project.ReferencePaths) 179 foreach (ReferencePathNode refPath in project.ReferencePaths)
170 { 180 {
171 string fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll"); 181 string fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll");
172 182
173 if(File.Exists(fullPath)) 183 if (File.Exists(fullPath))
174 { 184 {
175 return fullPath; 185 return fullPath;
176 } 186 }
177 } 187 }
178 188
179 return null; 189 return null;
180 } 190 }
181 191
182 /// <summary> 192 /// <summary>
183 /// Gets the XML doc file. 193 /// Gets the XML doc file.
184 /// </summary> 194 /// </summary>
185 /// <param name="project">The project.</param> 195 /// <param name="project">The project.</param>
186 /// <param name="conf">The conf.</param> 196 /// <param name="conf">The conf.</param>
187 /// <returns></returns> 197 /// <returns></returns>
188 public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf) 198 public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf)
189 { 199 {
190 if( conf == null ) 200 if (conf == null)
191 { 201 {
192 throw new ArgumentNullException("conf"); 202 throw new ArgumentNullException("conf");
193 } 203 }
194 if( project == null ) 204 if (project == null)
195 { 205 {
196 throw new ArgumentNullException("project"); 206 throw new ArgumentNullException("project");
197 } 207 }
198 string docFile = (string)conf.Options["XmlDocFile"]; 208 string docFile = (string)conf.Options["XmlDocFile"];
199 // if(docFile != null && docFile.Length == 0)//default to assembly name if not specified 209 // if(docFile != null && docFile.Length == 0)//default to assembly name if not specified
200 // { 210 // {
201 // return Path.GetFileNameWithoutExtension(project.AssemblyName) + ".xml"; 211 // return Path.GetFileNameWithoutExtension(project.AssemblyName) + ".xml";
202 // } 212 // }
203 return docFile; 213 return docFile;
204 } 214 }
205 215
206 private void WriteProject(SolutionNode solution, ProjectNode project) 216 private void WriteProject(SolutionNode solution, ProjectNode project)
207 { 217 {
208 string projFile = Helper.MakeFilePath(project.FullPath, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build"); 218 string projFile = Helper.MakeFilePath(project.FullPath, project.Name + GetProjectExtension(project), "build");
209 StreamWriter ss = new StreamWriter(projFile); 219 StreamWriter ss = new StreamWriter(projFile);
210 220
211 m_Kernel.CurrentWorkingDirectory.Push(); 221 m_Kernel.CurrentWorkingDirectory.Push();
212 Helper.SetCurrentDir(Path.GetDirectoryName(projFile)); 222 Helper.SetCurrentDir(Path.GetDirectoryName(projFile));
213 bool hasDoc = false; 223 bool hasDoc = false;
214 224
215 using(ss) 225 using (ss)
216 { 226 {
217 ss.WriteLine("<?xml version=\"1.0\" ?>"); 227 ss.WriteLine("<?xml version=\"1.0\" ?>");
218 ss.WriteLine("<project name=\"{0}\" default=\"build\">", project.Name); 228 ss.WriteLine("<project name=\"{0}\" default=\"build\">", project.Name);
219 ss.WriteLine(" <target name=\"{0}\">", "build"); 229 ss.WriteLine(" <target name=\"{0}\">", "build");
220 ss.WriteLine(" <echo message=\"Build Directory is ${project::get-base-directory()}/${build.dir}\" />"); 230 ss.WriteLine(" <echo message=\"Build Directory is ${project::get-base-directory()}/${build.dir}\" />");
221 ss.WriteLine(" <mkdir dir=\"${project::get-base-directory()}/${build.dir}\" />"); 231 ss.WriteLine(" <mkdir dir=\"${project::get-base-directory()}/${build.dir}\" />");
222 ss.WriteLine(" <copy todir=\"${project::get-base-directory()}/${build.dir}\">"); 232 ss.WriteLine(" <copy todir=\"${project::get-base-directory()}/${build.dir}\">");
223 ss.WriteLine(" <fileset basedir=\"${project::get-base-directory()}\">"); 233 ss.WriteLine(" <fileset basedir=\"${project::get-base-directory()}\">");
224 foreach(ReferenceNode refr in project.References) 234 foreach (ReferenceNode refr in project.References)
235 {
236 if (refr.LocalCopy)
225 { 237 {
226 if (refr.LocalCopy) 238 ss.WriteLine(" <include name=\"{0}", Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReference(solution, project, refr)) + "\" />", '/'));
227 {
228 ss.WriteLine(" <include name=\"{0}", Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReference(solution, project, refr))+"\" />", '/'));
229 }
230 } 239 }
240 }
231 ss.WriteLine(" </fileset>"); 241 ss.WriteLine(" </fileset>");
232 ss.WriteLine(" </copy>"); 242 ss.WriteLine(" </copy>");
233 ss.Write(" <csc"); 243 ss.Write(" <csc");
234 ss.Write(" target=\"{0}\"", project.Type.ToString().ToLower()); 244 ss.Write(" target=\"{0}\"", project.Type.ToString().ToLower());
235 ss.Write(" debug=\"{0}\"", "${build.debug}"); 245 ss.Write(" debug=\"{0}\"", "${build.debug}");
236 foreach(ConfigurationNode conf in project.Configurations) 246 foreach (ConfigurationNode conf in project.Configurations)
237 { 247 {
238 if (conf.Options.KeyFile !="") 248 if (conf.Options.KeyFile != "")
239 {
240 ss.Write(" keyfile=\"{0}\"", conf.Options.KeyFile);
241 break;
242 }
243 }
244 foreach(ConfigurationNode conf in project.Configurations)
245 {
246 ss.Write(" unsafe=\"{0}\"", conf.Options.AllowUnsafe);
247 break;
248 }
249 foreach(ConfigurationNode conf in project.Configurations)
250 { 249 {
251 ss.Write(" define=\"{0}\"", conf.Options.CompilerDefines); 250 ss.Write(" keyfile=\"{0}\"", conf.Options.KeyFile);
252 break; 251 break;
253 } 252 }
254 foreach(ConfigurationNode conf in project.Configurations) 253 }
254 foreach (ConfigurationNode conf in project.Configurations)
255 {
256 ss.Write(" unsafe=\"{0}\"", conf.Options.AllowUnsafe);
257 break;
258 }
259 foreach (ConfigurationNode conf in project.Configurations)
260 {
261 ss.Write(" define=\"{0}\"", conf.Options.CompilerDefines);
262 break;
263 }
264 foreach (ConfigurationNode conf in project.Configurations)
265 {
266 if (GetXmlDocFile(project, conf) != "")
255 { 267 {
256 if (GetXmlDocFile(project, conf) !="") 268 ss.Write(" doc=\"{0}\"", "${project::get-base-directory()}/${build.dir}/" + GetXmlDocFile(project, conf));
257 { 269 hasDoc = true;
258 ss.Write(" doc=\"{0}\"", "${project::get-base-directory()}/${build.dir}/" + GetXmlDocFile(project, conf));
259 hasDoc = true;
260 }
261 break;
262 } 270 }
271 break;
272 }
263 ss.Write(" output=\"{0}", "${project::get-base-directory()}/${build.dir}/${project::get-name()}"); 273 ss.Write(" output=\"{0}", "${project::get-base-directory()}/${build.dir}/${project::get-name()}");
264 if (project.Type == ProjectType.Library) 274 if (project.Type == ProjectType.Library)
265 { 275 {
266 ss.Write(".dll\""); 276 ss.Write(".dll\"");
267 } 277 }
268 else 278 else
269 { 279 {
270 ss.Write(".exe\""); 280 ss.Write(".exe\"");
271 } 281 }
272 if(project.AppIcon != null && project.AppIcon.Length != 0) 282 if (project.AppIcon != null && project.AppIcon.Length != 0)
273 { 283 {
274 ss.Write(" win32icon=\"{0}\"", Helper.NormalizePath(project.AppIcon,'/')); 284 ss.Write(" win32icon=\"{0}\"", Helper.NormalizePath(project.AppIcon, '/'));
275 } 285 }
276 ss.WriteLine(">"); 286 ss.WriteLine(">");
277 ss.WriteLine(" <resources prefix=\"{0}\" dynamicprefix=\"true\" >", project.RootNamespace); 287 ss.WriteLine(" <resources prefix=\"{0}\" dynamicprefix=\"true\" >", project.RootNamespace);
278 foreach (string file in project.Files) 288 foreach (string file in project.Files)
289 {
290 switch (project.Files.GetBuildAction(file))
279 { 291 {
280 switch (project.Files.GetBuildAction(file)) 292 case BuildAction.EmbeddedResource:
293 ss.WriteLine(" {0}", "<include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />");
294 break;
295 default:
296 if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings)
281 { 297 {
282 case BuildAction.EmbeddedResource: 298 ss.WriteLine(" <include name=\"{0}\" />", file.Substring(0, file.LastIndexOf('.')) + ".resx");
283 ss.WriteLine(" {0}", "<include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />");
284 break;
285 default:
286 if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings)
287 {
288 ss.WriteLine(" <include name=\"{0}\" />", file.Substring(0, file.LastIndexOf('.')) + ".resx");
289 }
290 break;
291 } 299 }
300 break;
292 } 301 }
302 }
293 //if (project.Files.GetSubType(file).ToString() != "Code") 303 //if (project.Files.GetSubType(file).ToString() != "Code")
294 //{ 304 //{
295 // ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".resx"); 305 // ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".resx");
296 306
297 ss.WriteLine(" </resources>"); 307 ss.WriteLine(" </resources>");
298 ss.WriteLine(" <sources failonempty=\"true\">"); 308 ss.WriteLine(" <sources failonempty=\"true\">");
299 foreach(string file in project.Files) 309 foreach (string file in project.Files)
310 {
311 switch (project.Files.GetBuildAction(file))
300 { 312 {
301 switch(project.Files.GetBuildAction(file)) 313 case BuildAction.Compile:
302 { 314 ss.WriteLine(" <include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />");
303 case BuildAction.Compile: 315 break;
304 ss.WriteLine(" <include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />"); 316 default:
305 break; 317 break;
306 default:
307 break;
308 }
309 } 318 }
319 }
310 ss.WriteLine(" </sources>"); 320 ss.WriteLine(" </sources>");
311 ss.WriteLine(" <references basedir=\"${project::get-base-directory()}\">"); 321 ss.WriteLine(" <references basedir=\"${project::get-base-directory()}\">");
312 ss.WriteLine(" <lib>"); 322 ss.WriteLine(" <lib>");
313 ss.WriteLine(" <include name=\"${project::get-base-directory()}\" />"); 323 ss.WriteLine(" <include name=\"${project::get-base-directory()}\" />");
314 ss.WriteLine(" <include name=\"${project::get-base-directory()}/${build.dir}\" />"); 324 ss.WriteLine(" <include name=\"${project::get-base-directory()}/${build.dir}\" />");
315 ss.WriteLine(" </lib>"); 325 ss.WriteLine(" </lib>");
316 foreach(ReferenceNode refr in project.References) 326 foreach (ReferenceNode refr in project.References)
317 { 327 {
318 string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReference(solution, project, refr)), '/'); 328 string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReference(solution, project, refr)), '/');
319 ss.WriteLine(" <include name=\""+ path + "\" />" ); 329 ss.WriteLine(" <include name=\"" + path + "\" />");
320 } 330 }
321 ss.WriteLine(" </references>"); 331 ss.WriteLine(" </references>");
322 332
323 ss.WriteLine(" </csc>"); 333 ss.WriteLine(" </csc>");
324 334
325 foreach (ConfigurationNode conf in project.Configurations) 335 foreach (ConfigurationNode conf in project.Configurations)
336 {
337 if (!String.IsNullOrEmpty(conf.Options.OutputPath))
326 { 338 {
327 if (!String.IsNullOrEmpty(conf.Options.OutputPath)) 339 string targetDir = Helper.NormalizePath(conf.Options.OutputPath, '/');
328 { 340
329 string targetDir = Helper.NormalizePath(conf.Options.OutputPath, '/'); 341 ss.WriteLine(" <echo message=\"Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/" + targetDir + "\" />");
330 342
331 ss.WriteLine(" <echo message=\"Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/" + targetDir + "\" />"); 343 ss.WriteLine(" <mkdir dir=\"${project::get-base-directory()}/" + targetDir + "\"/>");
332 344
333 ss.WriteLine(" <mkdir dir=\"${project::get-base-directory()}/" + targetDir + "\"/>"); 345 ss.WriteLine(" <copy todir=\"${project::get-base-directory()}/" + targetDir + "\">");
334 346 ss.WriteLine(" <fileset basedir=\"${project::get-base-directory()}/${build.dir}/\" >");
335 ss.WriteLine(" <copy todir=\"${project::get-base-directory()}/" + targetDir + "\">"); 347 ss.WriteLine(" <include name=\"*.dll\"/>");
336 ss.WriteLine(" <fileset basedir=\"${project::get-base-directory()}/${build.dir}/\" >"); 348 ss.WriteLine(" <include name=\"*.exe\"/>");
337 ss.WriteLine(" <include name=\"*.dll\"/>"); 349 ss.WriteLine(" </fileset>");
338 ss.WriteLine(" <include name=\"*.exe\"/>"); 350 ss.WriteLine(" </copy>");
339 ss.WriteLine(" </fileset>"); 351 break;
340 ss.WriteLine(" </copy>");
341 break;
342 }
343 } 352 }
344 353 }
354
345 ss.WriteLine(" </target>"); 355 ss.WriteLine(" </target>");
346 356
347 ss.WriteLine(" <target name=\"clean\">"); 357 ss.WriteLine(" <target name=\"clean\">");
@@ -351,89 +361,89 @@ public class NAntTarget : ITarget
351 361
352 ss.WriteLine(" <target name=\"doc\" description=\"Creates documentation.\">"); 362 ss.WriteLine(" <target name=\"doc\" description=\"Creates documentation.\">");
353 if (hasDoc) 363 if (hasDoc)
364 {
365 ss.WriteLine(" <property name=\"doc.target\" value=\"\" />");
366 ss.WriteLine(" <if test=\"${platform::is-unix()}\">");
367 ss.WriteLine(" <property name=\"doc.target\" value=\"Web\" />");
368 ss.WriteLine(" </if>");
369 ss.WriteLine(" <ndoc failonerror=\"false\" verbose=\"true\">");
370 ss.WriteLine(" <assemblies basedir=\"${project::get-base-directory()}\">");
371 ss.Write(" <include name=\"${build.dir}/${project::get-name()}");
372 if (project.Type == ProjectType.Library)
354 { 373 {
355 ss.WriteLine(" <property name=\"doc.target\" value=\"\" />"); 374 ss.WriteLine(".dll\" />");
356 ss.WriteLine(" <if test=\"${platform::is-unix()}\">"); 375 }
357 ss.WriteLine(" <property name=\"doc.target\" value=\"Web\" />"); 376 else
358 ss.WriteLine(" </if>"); 377 {
359 ss.WriteLine(" <ndoc failonerror=\"false\" verbose=\"true\">"); 378 ss.WriteLine(".exe\" />");
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 } 379 }
380
381 ss.WriteLine(" </assemblies>");
382 ss.WriteLine(" <summaries basedir=\"${project::get-base-directory()}\">");
383 ss.WriteLine(" <include name=\"${build.dir}/${project::get-name()}.xml\"/>");
384 ss.WriteLine(" </summaries>");
385 ss.WriteLine(" <referencepaths basedir=\"${project::get-base-directory()}\">");
386 ss.WriteLine(" <include name=\"${build.dir}\" />");
387 // foreach(ReferenceNode refr in project.References)
388 // {
389 // string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReferencePath(solution, refr)), '/');
390 // if (path != "")
391 // {
392 // ss.WriteLine(" <include name=\"{0}\" />", path);
393 // }
394 // }
395 ss.WriteLine(" </referencepaths>");
396 ss.WriteLine(" <documenters>");
397 ss.WriteLine(" <documenter name=\"MSDN\">");
398 ss.WriteLine(" <property name=\"OutputDirectory\" value=\"${project::get-base-directory()}/${build.dir}/doc/${project::get-name()}\" />");
399 ss.WriteLine(" <property name=\"OutputTarget\" value=\"${doc.target}\" />");
400 ss.WriteLine(" <property name=\"HtmlHelpName\" value=\"${project::get-name()}\" />");
401 ss.WriteLine(" <property name=\"IncludeFavorites\" value=\"False\" />");
402 ss.WriteLine(" <property name=\"Title\" value=\"${project::get-name()} SDK Documentation\" />");
403 ss.WriteLine(" <property name=\"SplitTOCs\" value=\"False\" />");
404 ss.WriteLine(" <property name=\"DefaulTOC\" value=\"\" />");
405 ss.WriteLine(" <property name=\"ShowVisualBasic\" value=\"True\" />");
406 ss.WriteLine(" <property name=\"AutoDocumentConstructors\" value=\"True\" />");
407 ss.WriteLine(" <property name=\"ShowMissingSummaries\" value=\"${build.debug}\" />");
408 ss.WriteLine(" <property name=\"ShowMissingRemarks\" value=\"${build.debug}\" />");
409 ss.WriteLine(" <property name=\"ShowMissingParams\" value=\"${build.debug}\" />");
410 ss.WriteLine(" <property name=\"ShowMissingReturns\" value=\"${build.debug}\" />");
411 ss.WriteLine(" <property name=\"ShowMissingValues\" value=\"${build.debug}\" />");
412 ss.WriteLine(" <property name=\"DocumentInternals\" value=\"False\" />");
413 ss.WriteLine(" <property name=\"DocumentPrivates\" value=\"False\" />");
414 ss.WriteLine(" <property name=\"DocumentProtected\" value=\"True\" />");
415 ss.WriteLine(" <property name=\"DocumentEmptyNamespaces\" value=\"${build.debug}\" />");
416 ss.WriteLine(" <property name=\"IncludeAssemblyVersion\" value=\"True\" />");
417 ss.WriteLine(" </documenter>");
418 ss.WriteLine(" </documenters>");
419 ss.WriteLine(" </ndoc>");
420 }
411 ss.WriteLine(" </target>"); 421 ss.WriteLine(" </target>");
412 ss.WriteLine("</project>"); 422 ss.WriteLine("</project>");
413 } 423 }
414 m_Kernel.CurrentWorkingDirectory.Pop(); 424 m_Kernel.CurrentWorkingDirectory.Pop();
415 } 425 }
416 426
417 private void WriteCombine(SolutionNode solution) 427 private void WriteCombine(SolutionNode solution)
418 { 428 {
419 m_Kernel.Log.Write("Creating NAnt build files"); 429 m_Kernel.Log.Write("Creating NAnt build files");
420 foreach(ProjectNode project in solution.Projects) 430 foreach (ProjectNode project in solution.Projects)
421 { 431 {
422 if(m_Kernel.AllowProject(project.FilterGroups)) 432 if (m_Kernel.AllowProject(project.FilterGroups))
423 { 433 {
424 m_Kernel.Log.Write("...Creating project: {0}", project.Name); 434 m_Kernel.Log.Write("...Creating project: {0}", project.Name);
425 WriteProject(solution, project); 435 WriteProject(solution, project);
426 } 436 }
427 } 437 }
428 438
429 m_Kernel.Log.Write(""); 439 m_Kernel.Log.Write("");
430 string combFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "build"); 440 string combFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "build");
431 StreamWriter ss = new StreamWriter(combFile); 441 StreamWriter ss = new StreamWriter(combFile);
432 442
433 m_Kernel.CurrentWorkingDirectory.Push(); 443 m_Kernel.CurrentWorkingDirectory.Push();
434 Helper.SetCurrentDir(Path.GetDirectoryName(combFile)); 444 Helper.SetCurrentDir(Path.GetDirectoryName(combFile));
435 445
436 using(ss) 446 using (ss)
437 { 447 {
438 ss.WriteLine("<?xml version=\"1.0\" ?>"); 448 ss.WriteLine("<?xml version=\"1.0\" ?>");
439 ss.WriteLine("<project name=\"{0}\" default=\"build\">", solution.Name); 449 ss.WriteLine("<project name=\"{0}\" default=\"build\">", solution.Name);
@@ -447,26 +457,26 @@ public class NAntTarget : ITarget
447 ss.WriteLine(" <property name=\"doc.dir\" value=\"doc\" />"); 457 ss.WriteLine(" <property name=\"doc.dir\" value=\"doc\" />");
448 ss.WriteLine(" <property name=\"project.main.dir\" value=\"${project::get-base-directory()}\" />"); 458 ss.WriteLine(" <property name=\"project.main.dir\" value=\"${project::get-base-directory()}\" />");
449 459
450 foreach(ConfigurationNode conf in solution.Configurations) 460 foreach (ConfigurationNode conf in solution.Configurations)
461 {
462 // Set the project.config to a non-debug configuration
463 if (conf.Options["DebugInformation"].ToString().ToLower() != "true")
451 { 464 {
452 // Set the project.config to a non-debug configuration 465 ss.WriteLine(" <property name=\"project.config\" value=\"{0}\" />", conf.Name);
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 } 466 }
467 ss.WriteLine();
468 ss.WriteLine(" <target name=\"{0}\" description=\"\">", conf.Name);
469 ss.WriteLine(" <property name=\"project.config\" value=\"{0}\" />", conf.Name);
470 ss.WriteLine(" <property name=\"build.debug\" value=\"{0}\" />", conf.Options["DebugInformation"].ToString().ToLower());
471 ss.WriteLine(" </target>");
472 ss.WriteLine();
473 }
464 474
465 ss.WriteLine(" <target name=\"net-1.1\" description=\"Sets framework to .NET 1.1\">"); 475 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\" />"); 476 ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"net-1.1\" />");
467 ss.WriteLine(" </target>"); 477 ss.WriteLine(" </target>");
468 ss.WriteLine(); 478 ss.WriteLine();
469 479
470 ss.WriteLine(" <target name=\"net-2.0\" description=\"Sets framework to .NET 2.0\">"); 480 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\" />"); 481 ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"net-2.0\" />");
472 ss.WriteLine(" </target>"); 482 ss.WriteLine(" </target>");
@@ -497,28 +507,31 @@ public class NAntTarget : ITarget
497 // created files from all .nant/*include files. This 507 // created files from all .nant/*include files. This
498 // lets us keep using prebuild, but allows for 508 // lets us keep using prebuild, but allows for
499 // extended nant targets to do build and the like. 509 // extended nant targets to do build and the like.
500 510
501 try { 511 try
512 {
502 Regex re = new Regex(".include$"); 513 Regex re = new Regex(".include$");
503 DirectoryInfo nantdir = new DirectoryInfo(".nant"); 514 DirectoryInfo nantdir = new DirectoryInfo(".nant");
504 foreach (FileSystemInfo item in nantdir.GetFileSystemInfos()) 515 foreach (FileSystemInfo item in nantdir.GetFileSystemInfos())
505 { 516 {
506 if (item is DirectoryInfo) {} 517 if (item is DirectoryInfo) { }
507 else if (item is FileInfo) 518 else if (item is FileInfo)
508 { 519 {
509 if (re.Match(((FileInfo)item).FullName) != 520 if (re.Match(((FileInfo)item).FullName) !=
510 System.Text.RegularExpressions.Match.Empty) { 521 System.Text.RegularExpressions.Match.Empty)
522 {
511 Console.WriteLine("Including file: " + ((FileInfo)item).FullName); 523 Console.WriteLine("Including file: " + ((FileInfo)item).FullName);
512 524
513 using (FileStream fs = new FileStream(((FileInfo)item).FullName, 525 using (FileStream fs = new FileStream(((FileInfo)item).FullName,
514 FileMode.Open, 526 FileMode.Open,
515 FileAccess.Read, 527 FileAccess.Read,
516 FileShare.None)) 528 FileShare.None))
517 { 529 {
518 using (StreamReader sr = new StreamReader(fs)) 530 using (StreamReader sr = new StreamReader(fs))
519 { 531 {
520 ss.WriteLine("<!-- included from {0} -->", ((FileInfo)item).FullName); 532 ss.WriteLine("<!-- included from {0} -->", ((FileInfo)item).FullName);
521 while (sr.Peek() != -1) { 533 while (sr.Peek() != -1)
534 {
522 ss.WriteLine(sr.ReadLine()); 535 ss.WriteLine(sr.ReadLine());
523 } 536 }
524 ss.WriteLine(); 537 ss.WriteLine();
@@ -527,45 +540,46 @@ public class NAntTarget : ITarget
527 } 540 }
528 } 541 }
529 } 542 }
530 } catch {} 543 }
544 catch { }
531 // ss.WriteLine(" <include buildfile=\".nant/local.include\" />"); 545 // ss.WriteLine(" <include buildfile=\".nant/local.include\" />");
532// ss.WriteLine(" <target name=\"zip\" description=\"\">"); 546 // ss.WriteLine(" <target name=\"zip\" description=\"\">");
533// ss.WriteLine(" <zip zipfile=\"{0}-{1}.zip\">", solution.Name, solution.Version); 547 // ss.WriteLine(" <zip zipfile=\"{0}-{1}.zip\">", solution.Name, solution.Version);
534// ss.WriteLine(" <fileset basedir=\"${project::get-base-directory()}\">"); 548 // ss.WriteLine(" <fileset basedir=\"${project::get-base-directory()}\">");
535 549
536// ss.WriteLine(" <include name=\"${project::get-base-directory()}/**/*.cs\" />"); 550 // ss.WriteLine(" <include name=\"${project::get-base-directory()}/**/*.cs\" />");
537// // ss.WriteLine(" <include name=\"${project.main.dir}/**/*\" />"); 551 // // ss.WriteLine(" <include name=\"${project.main.dir}/**/*\" />");
538// ss.WriteLine(" </fileset>"); 552 // ss.WriteLine(" </fileset>");
539// ss.WriteLine(" </zip>"); 553 // ss.WriteLine(" </zip>");
540// ss.WriteLine(" <echo message=\"Building zip target\" />"); 554 // ss.WriteLine(" <echo message=\"Building zip target\" />");
541// ss.WriteLine(" </target>"); 555 // ss.WriteLine(" </target>");
542 ss.WriteLine(); 556 ss.WriteLine();
543 557
544 558
545 ss.WriteLine(" <target name=\"clean\" description=\"\">"); 559 ss.WriteLine(" <target name=\"clean\" description=\"\">");
546 ss.WriteLine(" <echo message=\"Deleting all builds from all configurations\" />"); 560 ss.WriteLine(" <echo message=\"Deleting all builds from all configurations\" />");
547 //ss.WriteLine(" <delete dir=\"${dist.dir}\" failonerror=\"false\" />"); 561 //ss.WriteLine(" <delete dir=\"${dist.dir}\" failonerror=\"false\" />");
548 ss.WriteLine(" <delete dir=\"${bin.dir}\" failonerror=\"false\" />"); 562 ss.WriteLine(" <delete dir=\"${bin.dir}\" failonerror=\"false\" />");
549 ss.WriteLine(" <delete dir=\"${obj.dir}\" failonerror=\"false\" />"); 563 ss.WriteLine(" <delete dir=\"${obj.dir}\" failonerror=\"false\" />");
550 foreach(ProjectNode project in solution.Projects) 564 foreach (ProjectNode project in solution.Projects)
551 { 565 {
552 string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); 566 string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
553 ss.Write(" <nant buildfile=\"{0}\"", 567 ss.Write(" <nant buildfile=\"{0}\"",
554 Helper.NormalizePath(Helper.MakeFilePath(path, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build"),'/')); 568 Helper.NormalizePath(Helper.MakeFilePath(path, project.Name + GetProjectExtension(project), "build"), '/'));
555 ss.WriteLine(" target=\"clean\" />"); 569 ss.WriteLine(" target=\"clean\" />");
556 } 570 }
557 ss.WriteLine(" </target>"); 571 ss.WriteLine(" </target>");
558 ss.WriteLine(); 572 ss.WriteLine();
559 573
560 ss.WriteLine(" <target name=\"build\" depends=\"init\" description=\"\">"); 574 ss.WriteLine(" <target name=\"build\" depends=\"init\" description=\"\">");
561 575
562 foreach(ProjectNode project in solution.ProjectsTableOrder) 576 foreach (ProjectNode project in solution.ProjectsTableOrder)
563 { 577 {
564 string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); 578 string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
565 ss.Write(" <nant buildfile=\"{0}\"", 579 ss.Write(" <nant buildfile=\"{0}\"",
566 Helper.NormalizePath(Helper.MakeFilePath(path, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build"),'/')); 580 Helper.NormalizePath(Helper.MakeFilePath(path, project.Name + GetProjectExtension(project), "build"), '/'));
567 ss.WriteLine(" target=\"build\" />"); 581 ss.WriteLine(" target=\"build\" />");
568 } 582 }
569 ss.WriteLine(" </target>"); 583 ss.WriteLine(" </target>");
570 ss.WriteLine(); 584 ss.WriteLine();
571 585
@@ -580,94 +594,94 @@ public class NAntTarget : ITarget
580 ss.WriteLine(" <target name=\"doc\" depends=\"build-release\">"); 594 ss.WriteLine(" <target name=\"doc\" depends=\"build-release\">");
581 ss.WriteLine(" <echo message=\"Generating all documentation from all builds\" />"); 595 ss.WriteLine(" <echo message=\"Generating all documentation from all builds\" />");
582 foreach (ProjectNode project in solution.Projects) 596 foreach (ProjectNode project in solution.Projects)
583 { 597 {
584 string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); 598 string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
585 ss.Write(" <nant buildfile=\"{0}\"", 599 ss.Write(" <nant buildfile=\"{0}\"",
586 Helper.NormalizePath(Helper.MakeFilePath(path, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build"), '/')); 600 Helper.NormalizePath(Helper.MakeFilePath(path, project.Name + GetProjectExtension(project), "build"), '/'));
587 ss.WriteLine(" target=\"doc\" />"); 601 ss.WriteLine(" target=\"doc\" />");
588 } 602 }
589 ss.WriteLine(" </target>"); 603 ss.WriteLine(" </target>");
590 ss.WriteLine(); 604 ss.WriteLine();
591 ss.WriteLine("</project>"); 605 ss.WriteLine("</project>");
592 } 606 }
593 607
594 m_Kernel.CurrentWorkingDirectory.Pop(); 608 m_Kernel.CurrentWorkingDirectory.Pop();
595 } 609 }
596 610
597 private void CleanProject(ProjectNode project) 611 private void CleanProject(ProjectNode project)
598 { 612 {
599 m_Kernel.Log.Write("...Cleaning project: {0}", project.Name); 613 m_Kernel.Log.Write("...Cleaning project: {0}", project.Name);
600 string projectFile = Helper.MakeFilePath(project.FullPath, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build"); 614 string projectFile = Helper.MakeFilePath(project.FullPath, project.Name + GetProjectExtension(project), "build");
601 Helper.DeleteIfExists(projectFile); 615 Helper.DeleteIfExists(projectFile);
602 } 616 }
603 617
604 private void CleanSolution(SolutionNode solution) 618 private void CleanSolution(SolutionNode solution)
605 { 619 {
606 m_Kernel.Log.Write("Cleaning NAnt build files for", solution.Name); 620 m_Kernel.Log.Write("Cleaning NAnt build files for", solution.Name);
607 621
608 string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "build"); 622 string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "build");
609 Helper.DeleteIfExists(slnFile); 623 Helper.DeleteIfExists(slnFile);
610 624
611 foreach(ProjectNode project in solution.Projects) 625 foreach (ProjectNode project in solution.Projects)
612 { 626 {
613 CleanProject(project); 627 CleanProject(project);
614 } 628 }
615
616 m_Kernel.Log.Write("");
617 }
618 629
619#endregion 630 m_Kernel.Log.Write("");
631 }
620 632
621#region ITarget Members 633 #endregion
622 634
623 /// <summary> 635 #region ITarget Members
624 /// Writes the specified kern. 636
625 /// </summary> 637 /// <summary>
626 /// <param name="kern">The kern.</param> 638 /// Writes the specified kern.
627 public void Write(Kernel kern) 639 /// </summary>
628 { 640 /// <param name="kern">The kern.</param>
629 if( kern == null ) 641 public void Write(Kernel kern)
642 {
643 if (kern == null)
630 { 644 {
631 throw new ArgumentNullException("kern"); 645 throw new ArgumentNullException("kern");
632 } 646 }
633 m_Kernel = kern; 647 m_Kernel = kern;
634 foreach(SolutionNode solution in kern.Solutions) 648 foreach (SolutionNode solution in kern.Solutions)
635 { 649 {
636 WriteCombine(solution); 650 WriteCombine(solution);
637 } 651 }
638 m_Kernel = null; 652 m_Kernel = null;
639 } 653 }
640 654
641 /// <summary> 655 /// <summary>
642 /// Cleans the specified kern. 656 /// Cleans the specified kern.
643 /// </summary> 657 /// </summary>
644 /// <param name="kern">The kern.</param> 658 /// <param name="kern">The kern.</param>
645 public virtual void Clean(Kernel kern) 659 public virtual void Clean(Kernel kern)
646 { 660 {
647 if( kern == null ) 661 if (kern == null)
648 { 662 {
649 throw new ArgumentNullException("kern"); 663 throw new ArgumentNullException("kern");
650 } 664 }
651 m_Kernel = kern; 665 m_Kernel = kern;
652 foreach(SolutionNode sol in kern.Solutions) 666 foreach (SolutionNode sol in kern.Solutions)
653 { 667 {
654 CleanSolution(sol); 668 CleanSolution(sol);
655 } 669 }
656 m_Kernel = null; 670 m_Kernel = null;
657 } 671 }
658 672
659 /// <summary> 673 /// <summary>
660 /// Gets the name. 674 /// Gets the name.
661 /// </summary> 675 /// </summary>
662 /// <value>The name.</value> 676 /// <value>The name.</value>
663 public string Name 677 public string Name
664 { 678 {
665 get 679 get
666 { 680 {
667 return "nant"; 681 return "nant";
668 } 682 }
669 } 683 }
670 684
671#endregion 685 #endregion
672} 686 }
673} 687}