aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Prebuild/src/Core/Targets/SharpDevelopTarget.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Prebuild/src/Core/Targets/SharpDevelopTarget.cs')
-rw-r--r--Prebuild/src/Core/Targets/SharpDevelopTarget.cs874
1 files changed, 437 insertions, 437 deletions
diff --git a/Prebuild/src/Core/Targets/SharpDevelopTarget.cs b/Prebuild/src/Core/Targets/SharpDevelopTarget.cs
index c725730..ededadb 100644
--- a/Prebuild/src/Core/Targets/SharpDevelopTarget.cs
+++ b/Prebuild/src/Core/Targets/SharpDevelopTarget.cs
@@ -1,437 +1,437 @@
1#region BSD License 1#region BSD License
2/* 2/*
3Copyright (c) 2004 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) 3Copyright (c) 2004 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com)
4 4
5Redistribution and use in source and binary forms, with or without modification, are permitted 5Redistribution and use in source and binary forms, with or without modification, are permitted
6provided that the following conditions are met: 6provided that the following conditions are met:
7 7
8* Redistributions of source code must retain the above copyright notice, this list of conditions 8* Redistributions of source code must retain the above copyright notice, this list of conditions
9 and the following disclaimer. 9 and the following disclaimer.
10* Redistributions in binary form must reproduce the above copyright notice, this list of conditions 10* Redistributions in binary form must reproduce the above copyright notice, this list of conditions
11 and the following disclaimer in the documentation and/or other materials provided with the 11 and the following disclaimer in the documentation and/or other materials provided with the
12 distribution. 12 distribution.
13* The name of the author may not be used to endorse or promote products derived from this software 13* The name of the author may not be used to endorse or promote products derived from this software
14 without specific prior written permission. 14 without specific prior written permission.
15 15
16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
17BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 21OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
22IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23*/ 23*/
24#endregion 24#endregion
25 25
26#region CVS Information 26#region CVS Information
27/* 27/*
28 * $Source$ 28 * $Source$
29 * $Author: jendave $ 29 * $Author: jendave $
30 * $Date: 2007-02-13 21:58:03 +0100 (ti, 13 feb 2007) $ 30 * $Date: 2007-02-13 21:58:03 +0100 (ti, 13 feb 2007) $
31 * $Revision: 205 $ 31 * $Revision: 205 $
32 */ 32 */
33#endregion 33#endregion
34 34
35using System; 35using System;
36using System.Collections; 36using System.Collections;
37using System.Collections.Specialized; 37using System.Collections.Specialized;
38using System.IO; 38using System.IO;
39using System.Text.RegularExpressions; 39using System.Text.RegularExpressions;
40using System.Reflection; 40using System.Reflection;
41 41
42using Prebuild.Core.Attributes; 42using Prebuild.Core.Attributes;
43using Prebuild.Core.Interfaces; 43using Prebuild.Core.Interfaces;
44using Prebuild.Core.Nodes; 44using Prebuild.Core.Nodes;
45using Prebuild.Core.Utilities; 45using Prebuild.Core.Utilities;
46 46
47namespace Prebuild.Core.Targets 47namespace Prebuild.Core.Targets
48{ 48{
49 /// <summary> 49 /// <summary>
50 /// 50 ///
51 /// </summary> 51 /// </summary>
52 [Target("sharpdev")] 52 [Target("sharpdev")]
53 public class SharpDevelopTarget : ITarget 53 public class SharpDevelopTarget : ITarget
54 { 54 {
55 #region Fields 55 #region Fields
56 56
57 private Kernel m_Kernel; 57 private Kernel m_Kernel;
58 58
59 #endregion 59 #endregion
60 60
61 #region Private Methods 61 #region Private Methods
62 62
63 private static string PrependPath(string path) 63 private static string PrependPath(string path)
64 { 64 {
65 string tmpPath = Helper.NormalizePath(path, '/'); 65 string tmpPath = Helper.NormalizePath(path, '/');
66 Regex regex = new Regex(@"(\w):/(\w+)"); 66 Regex regex = new Regex(@"(\w):/(\w+)");
67 Match match = regex.Match(tmpPath); 67 Match match = regex.Match(tmpPath);
68 if(match.Success || tmpPath[0] == '.' || tmpPath[0] == '/') 68 if(match.Success || tmpPath[0] == '.' || tmpPath[0] == '/')
69 { 69 {
70 tmpPath = Helper.NormalizePath(tmpPath); 70 tmpPath = Helper.NormalizePath(tmpPath);
71 } 71 }
72 else 72 else
73 { 73 {
74 tmpPath = Helper.NormalizePath("./" + tmpPath); 74 tmpPath = Helper.NormalizePath("./" + tmpPath);
75 } 75 }
76 76
77 return tmpPath; 77 return tmpPath;
78 } 78 }
79 79
80 private static string BuildReference(SolutionNode solution, ReferenceNode refr) 80 private static string BuildReference(SolutionNode solution, ReferenceNode refr)
81 { 81 {
82 string ret = "<Reference type=\""; 82 string ret = "<Reference type=\"";
83 if(solution.ProjectsTable.ContainsKey(refr.Name)) 83 if(solution.ProjectsTable.ContainsKey(refr.Name))
84 { 84 {
85 ret += "Project\" refto=\"" + refr.Name; 85 ret += "Project\" refto=\"" + refr.Name;
86 ret += "\" localcopy=\"" + refr.LocalCopy.ToString() + "\" />"; 86 ret += "\" localcopy=\"" + refr.LocalCopy.ToString() + "\" />";
87 } 87 }
88 else 88 else
89 { 89 {
90 ProjectNode project = (ProjectNode)refr.Parent; 90 ProjectNode project = (ProjectNode)refr.Parent;
91 string fileRef = FindFileReference(refr.Name, project); 91 string fileRef = FindFileReference(refr.Name, project);
92 92
93 if(refr.Path != null || fileRef != null) 93 if(refr.Path != null || fileRef != null)
94 { 94 {
95 ret += "Assembly\" refto=\""; 95 ret += "Assembly\" refto=\"";
96 96
97 string finalPath = (refr.Path != null) ? Helper.MakeFilePath(refr.Path, refr.Name, "dll") : fileRef; 97 string finalPath = (refr.Path != null) ? Helper.MakeFilePath(refr.Path, refr.Name, "dll") : fileRef;
98 98
99 ret += finalPath; 99 ret += finalPath;
100 ret += "\" localcopy=\"" + refr.LocalCopy.ToString() + "\" />"; 100 ret += "\" localcopy=\"" + refr.LocalCopy.ToString() + "\" />";
101 return ret; 101 return ret;
102 } 102 }
103 103
104 ret += "Gac\" refto=\""; 104 ret += "Gac\" refto=\"";
105 try 105 try
106 { 106 {
107 //Assembly assem = Assembly.Load(refr.Name); 107 //Assembly assem = Assembly.Load(refr.Name);
108 ret += refr.Name;// assem.FullName; 108 ret += refr.Name;// assem.FullName;
109 } 109 }
110 catch (System.NullReferenceException e) 110 catch (System.NullReferenceException e)
111 { 111 {
112 e.ToString(); 112 e.ToString();
113 ret += refr.Name; 113 ret += refr.Name;
114 } 114 }
115 ret += "\" localcopy=\"" + refr.LocalCopy.ToString() + "\" />"; 115 ret += "\" localcopy=\"" + refr.LocalCopy.ToString() + "\" />";
116 } 116 }
117 117
118 return ret; 118 return ret;
119 } 119 }
120 120
121 private static string FindFileReference(string refName, ProjectNode project) 121 private static string FindFileReference(string refName, ProjectNode project)
122 { 122 {
123 foreach(ReferencePathNode refPath in project.ReferencePaths) 123 foreach(ReferencePathNode refPath in project.ReferencePaths)
124 { 124 {
125 string fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll"); 125 string fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll");
126 126
127 if(File.Exists(fullPath)) 127 if(File.Exists(fullPath))
128 { 128 {
129 return fullPath; 129 return fullPath;
130 } 130 }
131 } 131 }
132 132
133 return null; 133 return null;
134 } 134 }
135 135
136 /// <summary> 136 /// <summary>
137 /// Gets the XML doc file. 137 /// Gets the XML doc file.
138 /// </summary> 138 /// </summary>
139 /// <param name="project">The project.</param> 139 /// <param name="project">The project.</param>
140 /// <param name="conf">The conf.</param> 140 /// <param name="conf">The conf.</param>
141 /// <returns></returns> 141 /// <returns></returns>
142 public static string GenerateXmlDocFile(ProjectNode project, ConfigurationNode conf) 142 public static string GenerateXmlDocFile(ProjectNode project, ConfigurationNode conf)
143 { 143 {
144 if( conf == null ) 144 if( conf == null )
145 { 145 {
146 throw new ArgumentNullException("conf"); 146 throw new ArgumentNullException("conf");
147 } 147 }
148 if( project == null ) 148 if( project == null )
149 { 149 {
150 throw new ArgumentNullException("project"); 150 throw new ArgumentNullException("project");
151 } 151 }
152 string docFile = (string)conf.Options["XmlDocFile"]; 152 string docFile = (string)conf.Options["XmlDocFile"];
153 if(docFile != null && docFile.Length == 0)//default to assembly name if not specified 153 if(docFile != null && docFile.Length == 0)//default to assembly name if not specified
154 { 154 {
155 return "False"; 155 return "False";
156 } 156 }
157 return "True"; 157 return "True";
158 } 158 }
159 159
160 private void WriteProject(SolutionNode solution, ProjectNode project) 160 private void WriteProject(SolutionNode solution, ProjectNode project)
161 { 161 {
162 string csComp = "Csc"; 162 string csComp = "Csc";
163 string netRuntime = "MsNet"; 163 string netRuntime = "MsNet";
164 if(project.Runtime == ClrRuntime.Mono) 164 if(project.Runtime == ClrRuntime.Mono)
165 { 165 {
166 csComp = "Mcs"; 166 csComp = "Mcs";
167 netRuntime = "Mono"; 167 netRuntime = "Mono";
168 } 168 }
169 169
170 string projFile = Helper.MakeFilePath(project.FullPath, project.Name, "prjx"); 170 string projFile = Helper.MakeFilePath(project.FullPath, project.Name, "prjx");
171 StreamWriter ss = new StreamWriter(projFile); 171 StreamWriter ss = new StreamWriter(projFile);
172 172
173 m_Kernel.CurrentWorkingDirectory.Push(); 173 m_Kernel.CurrentWorkingDirectory.Push();
174 Helper.SetCurrentDir(Path.GetDirectoryName(projFile)); 174 Helper.SetCurrentDir(Path.GetDirectoryName(projFile));
175 175
176 using(ss) 176 using(ss)
177 { 177 {
178 ss.WriteLine( 178 ss.WriteLine(
179 "<Project name=\"{0}\" standardNamespace=\"{1}\" description=\"\" newfilesearch=\"None\" enableviewstate=\"True\" version=\"1.1\" projecttype=\"C#\">", 179 "<Project name=\"{0}\" standardNamespace=\"{1}\" description=\"\" newfilesearch=\"None\" enableviewstate=\"True\" version=\"1.1\" projecttype=\"C#\">",
180 project.Name, 180 project.Name,
181 project.RootNamespace 181 project.RootNamespace
182 ); 182 );
183 183
184 ss.WriteLine(" <Contents>"); 184 ss.WriteLine(" <Contents>");
185 foreach(string file in project.Files) 185 foreach(string file in project.Files)
186 { 186 {
187 string buildAction = "Compile"; 187 string buildAction = "Compile";
188 switch(project.Files.GetBuildAction(file)) 188 switch(project.Files.GetBuildAction(file))
189 { 189 {
190 case BuildAction.None: 190 case BuildAction.None:
191 buildAction = "Nothing"; 191 buildAction = "Nothing";
192 break; 192 break;
193 193
194 case BuildAction.Content: 194 case BuildAction.Content:
195 buildAction = "Exclude"; 195 buildAction = "Exclude";
196 break; 196 break;
197 197
198 case BuildAction.EmbeddedResource: 198 case BuildAction.EmbeddedResource:
199 buildAction = "EmbedAsResource"; 199 buildAction = "EmbedAsResource";
200 break; 200 break;
201 201
202 default: 202 default:
203 buildAction = "Compile"; 203 buildAction = "Compile";
204 break; 204 break;
205 } 205 }
206 206
207 // Sort of a hack, we try and resolve the path and make it relative, if we can. 207 // Sort of a hack, we try and resolve the path and make it relative, if we can.
208 string filePath = PrependPath(file); 208 string filePath = PrependPath(file);
209 ss.WriteLine(" <File name=\"{0}\" subtype=\"Code\" buildaction=\"{1}\" dependson=\"\" data=\"\" />", filePath, buildAction); 209 ss.WriteLine(" <File name=\"{0}\" subtype=\"Code\" buildaction=\"{1}\" dependson=\"\" data=\"\" />", filePath, buildAction);
210 } 210 }
211 ss.WriteLine(" </Contents>"); 211 ss.WriteLine(" </Contents>");
212 212
213 ss.WriteLine(" <References>"); 213 ss.WriteLine(" <References>");
214 foreach(ReferenceNode refr in project.References) 214 foreach(ReferenceNode refr in project.References)
215 { 215 {
216 ss.WriteLine(" {0}", BuildReference(solution, refr)); 216 ss.WriteLine(" {0}", BuildReference(solution, refr));
217 } 217 }
218 ss.WriteLine(" </References>"); 218 ss.WriteLine(" </References>");
219 219
220 ss.Write(" <DeploymentInformation"); 220 ss.Write(" <DeploymentInformation");
221 ss.Write(" target=\"\""); 221 ss.Write(" target=\"\"");
222 ss.Write(" script=\"\""); 222 ss.Write(" script=\"\"");
223 ss.Write(" strategy=\"File\""); 223 ss.Write(" strategy=\"File\"");
224 ss.WriteLine(" />"); 224 ss.WriteLine(" />");
225 225
226 int count = 0; 226 int count = 0;
227 227
228 ss.WriteLine(" <Configurations active=\"{0}\">", solution.ActiveConfig); 228 ss.WriteLine(" <Configurations active=\"{0}\">", solution.ActiveConfig);
229 229
230 foreach(ConfigurationNode conf in project.Configurations) 230 foreach(ConfigurationNode conf in project.Configurations)
231 { 231 {
232 ss.Write(" <Configuration"); 232 ss.Write(" <Configuration");
233 ss.Write(" runwithwarnings=\"True\""); 233 ss.Write(" runwithwarnings=\"True\"");
234 ss.Write(" name=\"{0}\"", conf.Name); 234 ss.Write(" name=\"{0}\"", conf.Name);
235 ss.WriteLine(">"); 235 ss.WriteLine(">");
236 ss.Write(" <CodeGeneration"); 236 ss.Write(" <CodeGeneration");
237 ss.Write(" runtime=\"{0}\"", netRuntime); 237 ss.Write(" runtime=\"{0}\"", netRuntime);
238 ss.Write(" compiler=\"{0}\"", csComp); 238 ss.Write(" compiler=\"{0}\"", csComp);
239 ss.Write(" compilerversion=\"\""); 239 ss.Write(" compilerversion=\"\"");
240 ss.Write(" warninglevel=\"{0}\"", conf.Options["WarningLevel"]); 240 ss.Write(" warninglevel=\"{0}\"", conf.Options["WarningLevel"]);
241 ss.Write(" nowarn=\"{0}\"", conf.Options["SuppressWarnings"]); 241 ss.Write(" nowarn=\"{0}\"", conf.Options["SuppressWarnings"]);
242 ss.Write(" includedebuginformation=\"{0}\"", conf.Options["DebugInformation"]); 242 ss.Write(" includedebuginformation=\"{0}\"", conf.Options["DebugInformation"]);
243 ss.Write(" optimize=\"{0}\"", conf.Options["OptimizeCode"]); 243 ss.Write(" optimize=\"{0}\"", conf.Options["OptimizeCode"]);
244 ss.Write(" unsafecodeallowed=\"{0}\"", conf.Options["AllowUnsafe"]); 244 ss.Write(" unsafecodeallowed=\"{0}\"", conf.Options["AllowUnsafe"]);
245 ss.Write(" generateoverflowchecks=\"{0}\"", conf.Options["CheckUnderflowOverflow"]); 245 ss.Write(" generateoverflowchecks=\"{0}\"", conf.Options["CheckUnderflowOverflow"]);
246 ss.Write(" mainclass=\"{0}\"", project.StartupObject); 246 ss.Write(" mainclass=\"{0}\"", project.StartupObject);
247 ss.Write(" target=\"{0}\"", project.Type); 247 ss.Write(" target=\"{0}\"", project.Type);
248 ss.Write(" definesymbols=\"{0}\"", conf.Options["CompilerDefines"]); 248 ss.Write(" definesymbols=\"{0}\"", conf.Options["CompilerDefines"]);
249 ss.Write(" generatexmldocumentation=\"{0}\"", GenerateXmlDocFile(project, conf)); 249 ss.Write(" generatexmldocumentation=\"{0}\"", GenerateXmlDocFile(project, conf));
250 ss.Write(" win32Icon=\"{0}\"", Helper.NormalizePath(".\\" + project.AppIcon)); 250 ss.Write(" win32Icon=\"{0}\"", Helper.NormalizePath(".\\" + project.AppIcon));
251 ss.Write(" noconfig=\"{0}\"", "False"); 251 ss.Write(" noconfig=\"{0}\"", "False");
252 ss.Write(" nostdlib=\"{0}\"", conf.Options["NoStdLib"]); 252 ss.Write(" nostdlib=\"{0}\"", conf.Options["NoStdLib"]);
253 ss.WriteLine(" />"); 253 ss.WriteLine(" />");
254 254
255 ss.Write(" <Execution"); 255 ss.Write(" <Execution");
256 ss.Write(" commandlineparameters=\"\""); 256 ss.Write(" commandlineparameters=\"\"");
257 ss.Write(" consolepause=\"True\""); 257 ss.Write(" consolepause=\"True\"");
258 ss.WriteLine(" />"); 258 ss.WriteLine(" />");
259 259
260 ss.Write(" <Output"); 260 ss.Write(" <Output");
261 ss.Write(" directory=\".\\{0}\"", Helper.NormalizePath(conf.Options["OutputPath"].ToString())); 261 ss.Write(" directory=\".\\{0}\"", Helper.NormalizePath(conf.Options["OutputPath"].ToString()));
262 ss.Write(" assembly=\"{0}\"", project.AssemblyName); 262 ss.Write(" assembly=\"{0}\"", project.AssemblyName);
263 ss.Write(" executeScript=\"{0}\"", conf.Options["RunScript"]); 263 ss.Write(" executeScript=\"{0}\"", conf.Options["RunScript"]);
264 if (conf.Options["PreBuildEvent"] != null && conf.Options["PreBuildEvent"].ToString().Length != 0) 264 if (conf.Options["PreBuildEvent"] != null && conf.Options["PreBuildEvent"].ToString().Length != 0)
265 { 265 {
266 ss.Write(" executeBeforeBuild=\"{0}\"", Helper.NormalizePath(conf.Options["PreBuildEvent"].ToString())); 266 ss.Write(" executeBeforeBuild=\"{0}\"", Helper.NormalizePath(conf.Options["PreBuildEvent"].ToString()));
267 } 267 }
268 else 268 else
269 { 269 {
270 ss.Write(" executeBeforeBuild=\"{0}\"", conf.Options["PreBuildEvent"]); 270 ss.Write(" executeBeforeBuild=\"{0}\"", conf.Options["PreBuildEvent"]);
271 } 271 }
272 if (conf.Options["PostBuildEvent"] != null && conf.Options["PostBuildEvent"].ToString().Length != 0) 272 if (conf.Options["PostBuildEvent"] != null && conf.Options["PostBuildEvent"].ToString().Length != 0)
273 { 273 {
274 ss.Write(" executeAfterBuild=\"{0}\"", Helper.NormalizePath(conf.Options["PostBuildEvent"].ToString())); 274 ss.Write(" executeAfterBuild=\"{0}\"", Helper.NormalizePath(conf.Options["PostBuildEvent"].ToString()));
275 } 275 }
276 else 276 else
277 { 277 {
278 ss.Write(" executeAfterBuild=\"{0}\"", conf.Options["PostBuildEvent"]); 278 ss.Write(" executeAfterBuild=\"{0}\"", conf.Options["PostBuildEvent"]);
279 } 279 }
280 ss.Write(" executeBeforeBuildArguments=\"{0}\"", conf.Options["PreBuildEventArgs"]); 280 ss.Write(" executeBeforeBuildArguments=\"{0}\"", conf.Options["PreBuildEventArgs"]);
281 ss.Write(" executeAfterBuildArguments=\"{0}\"", conf.Options["PreBuildEventArgs"]); 281 ss.Write(" executeAfterBuildArguments=\"{0}\"", conf.Options["PreBuildEventArgs"]);
282 ss.WriteLine(" />"); 282 ss.WriteLine(" />");
283 ss.WriteLine(" </Configuration>"); 283 ss.WriteLine(" </Configuration>");
284 284
285 count++; 285 count++;
286 } 286 }
287 ss.WriteLine(" </Configurations>"); 287 ss.WriteLine(" </Configurations>");
288 ss.WriteLine("</Project>"); 288 ss.WriteLine("</Project>");
289 } 289 }
290 290
291 m_Kernel.CurrentWorkingDirectory.Pop(); 291 m_Kernel.CurrentWorkingDirectory.Pop();
292 } 292 }
293 293
294 private void WriteCombine(SolutionNode solution) 294 private void WriteCombine(SolutionNode solution)
295 { 295 {
296 m_Kernel.Log.Write("Creating SharpDevelop combine and project files"); 296 m_Kernel.Log.Write("Creating SharpDevelop combine and project files");
297 foreach(ProjectNode project in solution.Projects) 297 foreach(ProjectNode project in solution.Projects)
298 { 298 {
299 if(m_Kernel.AllowProject(project.FilterGroups)) 299 if(m_Kernel.AllowProject(project.FilterGroups))
300 { 300 {
301 m_Kernel.Log.Write("...Creating project: {0}", project.Name); 301 m_Kernel.Log.Write("...Creating project: {0}", project.Name);
302 WriteProject(solution, project); 302 WriteProject(solution, project);
303 } 303 }
304 } 304 }
305 305
306 m_Kernel.Log.Write(""); 306 m_Kernel.Log.Write("");
307 string combFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "cmbx"); 307 string combFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "cmbx");
308 StreamWriter ss = new StreamWriter(combFile); 308 StreamWriter ss = new StreamWriter(combFile);
309 309
310 m_Kernel.CurrentWorkingDirectory.Push(); 310 m_Kernel.CurrentWorkingDirectory.Push();
311 Helper.SetCurrentDir(Path.GetDirectoryName(combFile)); 311 Helper.SetCurrentDir(Path.GetDirectoryName(combFile));
312 312
313 using(ss) 313 using(ss)
314 { 314 {
315 ss.WriteLine("<Combine fileversion=\"1.0\" name=\"{0}\" description=\"\">", solution.Name); 315 ss.WriteLine("<Combine fileversion=\"1.0\" name=\"{0}\" description=\"\">", solution.Name);
316 316
317 int count = 0; 317 int count = 0;
318 foreach(ProjectNode project in solution.Projects) 318 foreach(ProjectNode project in solution.Projects)
319 { 319 {
320 if(count == 0) 320 if(count == 0)
321 ss.WriteLine(" <StartMode startupentry=\"{0}\" single=\"True\">", project.Name); 321 ss.WriteLine(" <StartMode startupentry=\"{0}\" single=\"True\">", project.Name);
322 322
323 ss.WriteLine(" <Execute entry=\"{0}\" type=\"None\" />", project.Name); 323 ss.WriteLine(" <Execute entry=\"{0}\" type=\"None\" />", project.Name);
324 count++; 324 count++;
325 } 325 }
326 ss.WriteLine(" </StartMode>"); 326 ss.WriteLine(" </StartMode>");
327 327
328 ss.WriteLine(" <Entries>"); 328 ss.WriteLine(" <Entries>");
329 foreach(ProjectNode project in solution.Projects) 329 foreach(ProjectNode project in solution.Projects)
330 { 330 {
331 string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); 331 string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
332 ss.WriteLine(" <Entry filename=\"{0}\" />", 332 ss.WriteLine(" <Entry filename=\"{0}\" />",
333 Helper.MakeFilePath(path, project.Name, "prjx")); 333 Helper.MakeFilePath(path, project.Name, "prjx"));
334 } 334 }
335 ss.WriteLine(" </Entries>"); 335 ss.WriteLine(" </Entries>");
336 336
337 count = 0; 337 count = 0;
338 foreach(ConfigurationNode conf in solution.Configurations) 338 foreach(ConfigurationNode conf in solution.Configurations)
339 { 339 {
340 if(count == 0) 340 if(count == 0)
341 { 341 {
342 ss.WriteLine(" <Configurations active=\"{0}\">", conf.Name); 342 ss.WriteLine(" <Configurations active=\"{0}\">", conf.Name);
343 } 343 }
344 344
345 ss.WriteLine(" <Configuration name=\"{0}\">", conf.Name); 345 ss.WriteLine(" <Configuration name=\"{0}\">", conf.Name);
346 foreach(ProjectNode project in solution.Projects) 346 foreach(ProjectNode project in solution.Projects)
347 { 347 {
348 ss.WriteLine(" <Entry name=\"{0}\" configurationname=\"{1}\" build=\"True\" />", project.Name, conf.Name); 348 ss.WriteLine(" <Entry name=\"{0}\" configurationname=\"{1}\" build=\"True\" />", project.Name, conf.Name);
349 } 349 }
350 ss.WriteLine(" </Configuration>"); 350 ss.WriteLine(" </Configuration>");
351 351
352 count++; 352 count++;
353 } 353 }
354 ss.WriteLine(" </Configurations>"); 354 ss.WriteLine(" </Configurations>");
355 ss.WriteLine("</Combine>"); 355 ss.WriteLine("</Combine>");
356 } 356 }
357 357
358 m_Kernel.CurrentWorkingDirectory.Pop(); 358 m_Kernel.CurrentWorkingDirectory.Pop();
359 } 359 }
360 360
361 private void CleanProject(ProjectNode project) 361 private void CleanProject(ProjectNode project)
362 { 362 {
363 m_Kernel.Log.Write("...Cleaning project: {0}", project.Name); 363 m_Kernel.Log.Write("...Cleaning project: {0}", project.Name);
364 string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, "prjx"); 364 string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, "prjx");
365 Helper.DeleteIfExists(projectFile); 365 Helper.DeleteIfExists(projectFile);
366 } 366 }
367 367
368 private void CleanSolution(SolutionNode solution) 368 private void CleanSolution(SolutionNode solution)
369 { 369 {
370 m_Kernel.Log.Write("Cleaning SharpDevelop combine and project files for", solution.Name); 370 m_Kernel.Log.Write("Cleaning SharpDevelop combine and project files for", solution.Name);
371 371
372 string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "cmbx"); 372 string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "cmbx");
373 Helper.DeleteIfExists(slnFile); 373 Helper.DeleteIfExists(slnFile);
374 374
375 foreach(ProjectNode project in solution.Projects) 375 foreach(ProjectNode project in solution.Projects)
376 { 376 {
377 CleanProject(project); 377 CleanProject(project);
378 } 378 }
379 379
380 m_Kernel.Log.Write(""); 380 m_Kernel.Log.Write("");
381 } 381 }
382 382
383 #endregion 383 #endregion
384 384
385 #region ITarget Members 385 #region ITarget Members
386 386
387 /// <summary> 387 /// <summary>
388 /// Writes the specified kern. 388 /// Writes the specified kern.
389 /// </summary> 389 /// </summary>
390 /// <param name="kern">The kern.</param> 390 /// <param name="kern">The kern.</param>
391 public void Write(Kernel kern) 391 public void Write(Kernel kern)
392 { 392 {
393 if( kern == null ) 393 if( kern == null )
394 { 394 {
395 throw new ArgumentNullException("kern"); 395 throw new ArgumentNullException("kern");
396 } 396 }
397 m_Kernel = kern; 397 m_Kernel = kern;
398 foreach(SolutionNode solution in kern.Solutions) 398 foreach(SolutionNode solution in kern.Solutions)
399 { 399 {
400 WriteCombine(solution); 400 WriteCombine(solution);
401 } 401 }
402 m_Kernel = null; 402 m_Kernel = null;
403 } 403 }
404 404
405 /// <summary> 405 /// <summary>
406 /// Cleans the specified kern. 406 /// Cleans the specified kern.
407 /// </summary> 407 /// </summary>
408 /// <param name="kern">The kern.</param> 408 /// <param name="kern">The kern.</param>
409 public virtual void Clean(Kernel kern) 409 public virtual void Clean(Kernel kern)
410 { 410 {
411 if( kern == null ) 411 if( kern == null )
412 { 412 {
413 throw new ArgumentNullException("kern"); 413 throw new ArgumentNullException("kern");
414 } 414 }
415 m_Kernel = kern; 415 m_Kernel = kern;
416 foreach(SolutionNode sol in kern.Solutions) 416 foreach(SolutionNode sol in kern.Solutions)
417 { 417 {
418 CleanSolution(sol); 418 CleanSolution(sol);
419 } 419 }
420 m_Kernel = null; 420 m_Kernel = null;
421 } 421 }
422 422
423 /// <summary> 423 /// <summary>
424 /// Gets the name. 424 /// Gets the name.
425 /// </summary> 425 /// </summary>
426 /// <value>The name.</value> 426 /// <value>The name.</value>
427 public string Name 427 public string Name
428 { 428 {
429 get 429 get
430 { 430 {
431 return "sharpdev"; 431 return "sharpdev";
432 } 432 }
433 } 433 }
434 434
435 #endregion 435 #endregion
436 } 436 }
437} 437}