opensim – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | eva | 1 | #region BSD License |
2 | /* |
||
3 | Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) |
||
4 | |||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted |
||
6 | provided that the following conditions are met: |
||
7 | |||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions |
||
9 | and the following disclaimer. |
||
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions |
||
11 | and the following disclaimer in the documentation and/or other materials provided with the |
||
12 | distribution. |
||
13 | * The name of the author may not be used to endorse or promote products derived from this software |
||
14 | without specific prior written permission. |
||
15 | |||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, |
||
17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
||
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
||
20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
||
21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
||
22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||
23 | */ |
||
24 | #endregion |
||
25 | |||
26 | using System; |
||
27 | using System.Collections.Generic; |
||
28 | using System.IO; |
||
29 | |||
30 | using Prebuild.Core.Attributes; |
||
31 | using Prebuild.Core.Interfaces; |
||
32 | using Prebuild.Core.Nodes; |
||
33 | using Prebuild.Core.Utilities; |
||
34 | |||
35 | namespace Prebuild.Core.Targets |
||
36 | { |
||
37 | [Target("vs2003")] |
||
38 | public class VS2003Target : ITarget |
||
39 | { |
||
40 | |||
41 | #region Fields |
||
42 | |||
43 | string solutionVersion = "8.00"; |
||
44 | string productVersion = "7.10.3077"; |
||
45 | string schemaVersion = "2.0"; |
||
46 | string versionName = "2003"; |
||
47 | VSVersion version = VSVersion.VS71; |
||
48 | |||
49 | readonly Dictionary<string, ToolInfo> m_Tools = new Dictionary<string, ToolInfo>(); |
||
50 | Kernel m_Kernel; |
||
51 | |||
52 | /// <summary> |
||
53 | /// Gets or sets the solution version. |
||
54 | /// </summary> |
||
55 | /// <value>The solution version.</value> |
||
56 | protected string SolutionVersion |
||
57 | { |
||
58 | get |
||
59 | { |
||
60 | return solutionVersion; |
||
61 | } |
||
62 | set |
||
63 | { |
||
64 | solutionVersion = value; |
||
65 | } |
||
66 | } |
||
67 | /// <summary> |
||
68 | /// Gets or sets the product version. |
||
69 | /// </summary> |
||
70 | /// <value>The product version.</value> |
||
71 | protected string ProductVersion |
||
72 | { |
||
73 | get |
||
74 | { |
||
75 | return productVersion; |
||
76 | } |
||
77 | set |
||
78 | { |
||
79 | productVersion = value; |
||
80 | } |
||
81 | } |
||
82 | /// <summary> |
||
83 | /// Gets or sets the schema version. |
||
84 | /// </summary> |
||
85 | /// <value>The schema version.</value> |
||
86 | protected string SchemaVersion |
||
87 | { |
||
88 | get |
||
89 | { |
||
90 | return schemaVersion; |
||
91 | } |
||
92 | set |
||
93 | { |
||
94 | schemaVersion = value; |
||
95 | } |
||
96 | } |
||
97 | /// <summary> |
||
98 | /// Gets or sets the name of the version. |
||
99 | /// </summary> |
||
100 | /// <value>The name of the version.</value> |
||
101 | protected string VersionName |
||
102 | { |
||
103 | get |
||
104 | { |
||
105 | return versionName; |
||
106 | } |
||
107 | set |
||
108 | { |
||
109 | versionName = value; |
||
110 | } |
||
111 | } |
||
112 | /// <summary> |
||
113 | /// Gets or sets the version. |
||
114 | /// </summary> |
||
115 | /// <value>The version.</value> |
||
116 | protected VSVersion Version |
||
117 | { |
||
118 | get |
||
119 | { |
||
120 | return version; |
||
121 | } |
||
122 | set |
||
123 | { |
||
124 | version = value; |
||
125 | } |
||
126 | } |
||
127 | |||
128 | #endregion |
||
129 | |||
130 | #region Constructors |
||
131 | |||
132 | /// <summary> |
||
133 | /// Initializes a new instance of the <see cref="VS2003Target"/> class. |
||
134 | /// </summary> |
||
135 | public VS2003Target() |
||
136 | { |
||
137 | m_Tools["C#"] = new ToolInfo("C#", "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}", "csproj", "CSHARP"); |
||
138 | m_Tools["VB.NET"] = new ToolInfo("VB.NET", "{F184B08F-C81C-45F6-A57F-5ABD9991F28F}", "vbproj", "VisualBasic"); |
||
139 | } |
||
140 | |||
141 | #endregion |
||
142 | |||
143 | #region Private Methods |
||
144 | |||
145 | private string MakeRefPath(ProjectNode project) |
||
146 | { |
||
147 | string ret = ""; |
||
148 | foreach(ReferencePathNode node in project.ReferencePaths) |
||
149 | { |
||
150 | try |
||
151 | { |
||
152 | string fullPath = Helper.ResolvePath(node.Path); |
||
153 | if(ret.Length < 1) |
||
154 | { |
||
155 | ret = fullPath; |
||
156 | } |
||
157 | else |
||
158 | { |
||
159 | ret += ";" + fullPath; |
||
160 | } |
||
161 | } |
||
162 | catch(ArgumentException) |
||
163 | { |
||
164 | m_Kernel.Log.Write(LogType.Warning, "Could not resolve reference path: {0}", node.Path); |
||
165 | } |
||
166 | } |
||
167 | |||
168 | return ret; |
||
169 | } |
||
170 | |||
171 | private void WriteProject(SolutionNode solution, ProjectNode project) |
||
172 | { |
||
173 | if(!m_Tools.ContainsKey(project.Language)) |
||
174 | { |
||
175 | throw new UnknownLanguageException("Unknown .NET language: " + project.Language); |
||
176 | } |
||
177 | |||
178 | ToolInfo toolInfo = m_Tools[project.Language]; |
||
179 | string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); |
||
180 | StreamWriter ps = new StreamWriter(projectFile); |
||
181 | |||
182 | m_Kernel.CurrentWorkingDirectory.Push(); |
||
183 | Helper.SetCurrentDir(Path.GetDirectoryName(projectFile)); |
||
184 | |||
185 | using(ps) |
||
186 | { |
||
187 | ps.WriteLine("<VisualStudioProject>"); |
||
188 | ps.WriteLine(" <{0}", toolInfo.XmlTag); |
||
189 | ps.WriteLine("\t\t\t\tProjectType = \"Local\""); |
||
190 | ps.WriteLine("\t\t\t\tProductVersion = \"{0}\"", ProductVersion); |
||
191 | ps.WriteLine("\t\t\t\tSchemaVersion = \"{0}\"", SchemaVersion); |
||
192 | ps.WriteLine("\t\t\t\tProjectGuid = \"{{{0}}}\"", project.Guid.ToString().ToUpper()); |
||
193 | ps.WriteLine("\t\t>"); |
||
194 | |||
195 | ps.WriteLine("\t\t\t\t<Build>"); |
||
196 | ps.WriteLine(" <Settings"); |
||
197 | ps.WriteLine("\t\t\t\t ApplicationIcon = \"{0}\"",project.AppIcon); |
||
198 | ps.WriteLine("\t\t\t\t AssemblyKeyContainerName = \"\""); |
||
199 | ps.WriteLine("\t\t\t\t AssemblyName = \"{0}\"", project.AssemblyName); |
||
200 | ps.WriteLine("\t\t\t\t AssemblyOriginatorKeyFile = \"\""); |
||
201 | ps.WriteLine("\t\t\t\t DefaultClientScript = \"JScript\""); |
||
202 | ps.WriteLine("\t\t\t\t DefaultHTMLPageLayout = \"Grid\""); |
||
203 | ps.WriteLine("\t\t\t\t DefaultTargetSchema = \"IE50\""); |
||
204 | ps.WriteLine("\t\t\t\t DelaySign = \"false\""); |
||
205 | |||
206 | if(Version == VSVersion.VS70) |
||
207 | { |
||
208 | ps.WriteLine("\t\t\t\t NoStandardLibraries = \"false\""); |
||
209 | } |
||
210 | |||
211 | ps.WriteLine("\t\t\t\t OutputType = \"{0}\"", project.Type); |
||
212 | |||
213 | foreach(ConfigurationNode conf in project.Configurations) |
||
214 | { |
||
215 | if (conf.Options["PreBuildEvent"] != null && conf.Options["PreBuildEvent"].ToString().Length != 0) |
||
216 | { |
||
217 | ps.WriteLine("\t\t\t\t PreBuildEvent = \"{0}\"", Helper.NormalizePath(conf.Options["PreBuildEvent"].ToString())); |
||
218 | } |
||
219 | else |
||
220 | { |
||
221 | ps.WriteLine("\t\t\t\t PreBuildEvent = \"{0}\"", conf.Options["PreBuildEvent"]); |
||
222 | } |
||
223 | if (conf.Options["PostBuildEvent"] != null && conf.Options["PostBuildEvent"].ToString().Length != 0) |
||
224 | { |
||
225 | ps.WriteLine("\t\t\t\t PostBuildEvent = \"{0}\"", Helper.NormalizePath(conf.Options["PostBuildEvent"].ToString())); |
||
226 | } |
||
227 | else |
||
228 | { |
||
229 | ps.WriteLine("\t\t\t\t PostBuildEvent = \"{0}\"", conf.Options["PostBuildEvent"]); |
||
230 | } |
||
231 | if (conf.Options["RunPostBuildEvent"] == null) |
||
232 | { |
||
233 | ps.WriteLine("\t\t\t\t RunPostBuildEvent = \"{0}\"", "OnBuildSuccess"); |
||
234 | } |
||
235 | else |
||
236 | { |
||
237 | ps.WriteLine("\t\t\t\t RunPostBuildEvent = \"{0}\"", conf.Options["RunPostBuildEvent"]); |
||
238 | } |
||
239 | break; |
||
240 | } |
||
241 | |||
242 | ps.WriteLine("\t\t\t\t RootNamespace = \"{0}\"", project.RootNamespace); |
||
243 | ps.WriteLine("\t\t\t\t StartupObject = \"{0}\"", project.StartupObject); |
||
244 | ps.WriteLine("\t\t >"); |
||
245 | |||
246 | foreach(ConfigurationNode conf in project.Configurations) |
||
247 | { |
||
248 | ps.WriteLine("\t\t\t\t <Config"); |
||
249 | ps.WriteLine("\t\t\t\t Name = \"{0}\"", conf.Name); |
||
250 | ps.WriteLine("\t\t\t\t AllowUnsafeBlocks = \"{0}\"", conf.Options["AllowUnsafe"].ToString().ToLower()); |
||
251 | ps.WriteLine("\t\t\t\t BaseAddress = \"{0}\"", conf.Options["BaseAddress"]); |
||
252 | ps.WriteLine("\t\t\t\t CheckForOverflowUnderflow = \"{0}\"", conf.Options["CheckUnderflowOverflow"].ToString().ToLower()); |
||
253 | ps.WriteLine("\t\t\t\t ConfigurationOverrideFile = \"\""); |
||
254 | ps.WriteLine("\t\t\t\t DefineConstants = \"{0}\"", conf.Options["CompilerDefines"]); |
||
255 | ps.WriteLine("\t\t\t\t DocumentationFile = \"{0}\"", GetXmlDocFile(project, conf));//default to the assembly name |
||
256 | ps.WriteLine("\t\t\t\t DebugSymbols = \"{0}\"", conf.Options["DebugInformation"].ToString().ToLower()); |
||
257 | ps.WriteLine("\t\t\t\t FileAlignment = \"{0}\"", conf.Options["FileAlignment"]); |
||
258 | ps.WriteLine("\t\t\t\t IncrementalBuild = \"{0}\"", conf.Options["IncrementalBuild"].ToString().ToLower()); |
||
259 | |||
260 | if(Version == VSVersion.VS71) |
||
261 | { |
||
262 | ps.WriteLine("\t\t\t\t NoStdLib = \"{0}\"", conf.Options["NoStdLib"].ToString().ToLower()); |
||
263 | ps.WriteLine("\t\t\t\t NoWarn = \"{0}\"", conf.Options["SuppressWarnings"].ToString().ToLower()); |
||
264 | } |
||
265 | |||
266 | ps.WriteLine("\t\t\t\t Optimize = \"{0}\"", conf.Options["OptimizeCode"].ToString().ToLower()); |
||
267 | ps.WriteLine(" OutputPath = \"{0}\"", |
||
268 | Helper.EndPath(Helper.NormalizePath(conf.Options["OutputPath"].ToString()))); |
||
269 | ps.WriteLine(" RegisterForComInterop = \"{0}\"", conf.Options["RegisterComInterop"].ToString().ToLower()); |
||
270 | ps.WriteLine(" RemoveIntegerChecks = \"{0}\"", conf.Options["RemoveIntegerChecks"].ToString().ToLower()); |
||
271 | ps.WriteLine(" TreatWarningsAsErrors = \"{0}\"", conf.Options["WarningsAsErrors"].ToString().ToLower()); |
||
272 | ps.WriteLine(" WarningLevel = \"{0}\"", conf.Options["WarningLevel"]); |
||
273 | ps.WriteLine(" />"); |
||
274 | } |
||
275 | |||
276 | ps.WriteLine(" </Settings>"); |
||
277 | |||
278 | ps.WriteLine(" <References>"); |
||
279 | foreach(ReferenceNode refr in project.References) |
||
280 | { |
||
281 | ps.WriteLine(" <Reference"); |
||
282 | ps.WriteLine(" Name = \"{0}\"", refr.Name); |
||
283 | ps.WriteLine(" AssemblyName = \"{0}\"", refr.Name); |
||
284 | |||
285 | if(solution.ProjectsTable.ContainsKey(refr.Name)) |
||
286 | { |
||
287 | ProjectNode refProject = solution.ProjectsTable[refr.Name]; |
||
288 | ps.WriteLine(" Project = \"{{{0}}}\"", refProject.Guid.ToString().ToUpper()); |
||
289 | ps.WriteLine(" Package = \"{0}\"", toolInfo.Guid.ToUpper()); |
||
290 | } |
||
291 | else |
||
292 | { |
||
293 | if(refr.Path != null) |
||
294 | { |
||
295 | ps.WriteLine(" HintPath = \"{0}\"", Helper.MakeFilePath(refr.Path, refr.Name, "dll")); |
||
296 | } |
||
297 | |||
298 | } |
||
299 | |||
300 | if(refr.LocalCopySpecified) |
||
301 | { |
||
302 | ps.WriteLine(" Private = \"{0}\"",refr.LocalCopy); |
||
303 | } |
||
304 | |||
305 | ps.WriteLine(" />"); |
||
306 | } |
||
307 | ps.WriteLine(" </References>"); |
||
308 | |||
309 | ps.WriteLine(" </Build>"); |
||
310 | ps.WriteLine(" <Files>"); |
||
311 | |||
312 | ps.WriteLine(" <Include>"); |
||
313 | |||
314 | foreach(string file in project.Files) |
||
315 | { |
||
316 | string fileName = file.Replace(".\\", ""); |
||
317 | ps.WriteLine(" <File"); |
||
318 | ps.WriteLine(" RelPath = \"{0}\"", fileName); |
||
319 | ps.WriteLine(" SubType = \"{0}\"", project.Files.GetSubType(file)); |
||
320 | ps.WriteLine(" BuildAction = \"{0}\"", project.Files.GetBuildAction(file)); |
||
321 | ps.WriteLine(" />"); |
||
322 | |||
323 | if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings) |
||
324 | { |
||
325 | ps.WriteLine(" <File"); |
||
326 | ps.WriteLine(" RelPath = \"{0}\"", fileName.Substring(0, fileName.LastIndexOf('.')) + ".resx"); |
||
327 | int slash = fileName.LastIndexOf('\\'); |
||
328 | if (slash == -1) |
||
329 | { |
||
330 | ps.WriteLine(" DependentUpon = \"{0}\"", fileName); |
||
331 | } |
||
332 | else |
||
333 | { |
||
334 | ps.WriteLine(" DependentUpon = \"{0}\"", fileName.Substring(slash + 1, fileName.Length - slash - 1)); |
||
335 | } |
||
336 | ps.WriteLine(" BuildAction = \"{0}\"", "EmbeddedResource"); |
||
337 | ps.WriteLine(" />"); |
||
338 | |||
339 | } |
||
340 | } |
||
341 | ps.WriteLine(" </Include>"); |
||
342 | |||
343 | ps.WriteLine(" </Files>"); |
||
344 | ps.WriteLine(" </{0}>", toolInfo.XmlTag); |
||
345 | ps.WriteLine("</VisualStudioProject>"); |
||
346 | } |
||
347 | |||
348 | ps = new StreamWriter(projectFile + ".user"); |
||
349 | using(ps) |
||
350 | { |
||
351 | ps.WriteLine("<VisualStudioProject>"); |
||
352 | ps.WriteLine(" <{0}>", toolInfo.XmlTag); |
||
353 | ps.WriteLine(" <Build>"); |
||
354 | |||
355 | ps.WriteLine(" <Settings ReferencePath=\"{0}\">", MakeRefPath(project)); |
||
356 | foreach(ConfigurationNode conf in project.Configurations) |
||
357 | { |
||
358 | ps.WriteLine(" <Config"); |
||
359 | ps.WriteLine(" Name = \"{0}\"", conf.Name); |
||
360 | ps.WriteLine(" />"); |
||
361 | } |
||
362 | ps.WriteLine(" </Settings>"); |
||
363 | |||
364 | ps.WriteLine(" </Build>"); |
||
365 | ps.WriteLine(" </{0}>", toolInfo.XmlTag); |
||
366 | ps.WriteLine("</VisualStudioProject>"); |
||
367 | } |
||
368 | |||
369 | m_Kernel.CurrentWorkingDirectory.Pop(); |
||
370 | } |
||
371 | |||
372 | /// <summary> |
||
373 | /// Gets the XML doc file. |
||
374 | /// </summary> |
||
375 | /// <param name="project">The project.</param> |
||
376 | /// <param name="conf">The conf.</param> |
||
377 | /// <returns></returns> |
||
378 | public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf) |
||
379 | { |
||
380 | if( conf == null ) |
||
381 | { |
||
382 | throw new ArgumentNullException("conf"); |
||
383 | } |
||
384 | if( project == null ) |
||
385 | { |
||
386 | throw new ArgumentNullException("project"); |
||
387 | } |
||
388 | // if(!(bool)conf.Options["GenerateXmlDocFile"]) //default to none, if the generate option is false |
||
389 | // { |
||
390 | // return string.Empty; |
||
391 | // } |
||
392 | |||
393 | //default to "AssemblyName.xml" |
||
394 | //string defaultValue = Path.GetFileNameWithoutExtension(project.AssemblyName) + ".xml"; |
||
395 | //return (string)conf.Options["XmlDocFile", defaultValue]; |
||
396 | |||
397 | //default to no XmlDocFile file |
||
398 | return (string)conf.Options["XmlDocFile", ""]; |
||
399 | } |
||
400 | |||
401 | private void WriteSolution(SolutionNode solution) |
||
402 | { |
||
403 | m_Kernel.Log.Write("Creating Visual Studio {0} solution and project files", VersionName); |
||
404 | |||
405 | foreach(ProjectNode project in solution.Projects) |
||
406 | { |
||
407 | if(m_Kernel.AllowProject(project.FilterGroups)) |
||
408 | { |
||
409 | m_Kernel.Log.Write("...Creating project: {0}", project.Name); |
||
410 | WriteProject(solution, project); |
||
411 | } |
||
412 | } |
||
413 | |||
414 | m_Kernel.Log.Write(""); |
||
415 | string solutionFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln"); |
||
416 | StreamWriter ss = new StreamWriter(solutionFile); |
||
417 | |||
418 | m_Kernel.CurrentWorkingDirectory.Push(); |
||
419 | Helper.SetCurrentDir(Path.GetDirectoryName(solutionFile)); |
||
420 | |||
421 | using(ss) |
||
422 | { |
||
423 | ss.WriteLine("Microsoft Visual Studio Solution File, Format Version {0}", SolutionVersion); |
||
424 | foreach(ProjectNode project in solution.Projects) |
||
425 | { |
||
426 | if(!m_Tools.ContainsKey(project.Language)) |
||
427 | { |
||
428 | throw new UnknownLanguageException("Unknown .NET language: " + project.Language); |
||
429 | } |
||
430 | |||
431 | ToolInfo toolInfo = m_Tools[project.Language]; |
||
432 | |||
433 | string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); |
||
434 | ss.WriteLine("Project(\"{0}\") = \"{1}\", \"{2}\", \"{{{3}}}\"", |
||
435 | toolInfo.Guid, project.Name, Helper.MakeFilePath(path, project.Name, |
||
436 | toolInfo.FileExtension), project.Guid.ToString().ToUpper()); |
||
437 | |||
438 | ss.WriteLine("\tProjectSection(ProjectDependencies) = postProject"); |
||
439 | ss.WriteLine("\tEndProjectSection"); |
||
440 | |||
441 | ss.WriteLine("EndProject"); |
||
442 | } |
||
443 | |||
444 | ss.WriteLine("Global"); |
||
445 | |||
446 | ss.WriteLine("\tGlobalSection(SolutionConfiguration) = preSolution"); |
||
447 | foreach(ConfigurationNode conf in solution.Configurations) |
||
448 | { |
||
449 | ss.WriteLine("\t\t{0} = {0}", conf.Name); |
||
450 | } |
||
451 | ss.WriteLine("\tEndGlobalSection"); |
||
452 | |||
453 | ss.WriteLine("\tGlobalSection(ProjectDependencies) = postSolution"); |
||
454 | foreach(ProjectNode project in solution.Projects) |
||
455 | { |
||
456 | for(int i = 0; i < project.References.Count; i++) |
||
457 | { |
||
458 | ReferenceNode refr = project.References[i]; |
||
459 | if(solution.ProjectsTable.ContainsKey(refr.Name)) |
||
460 | { |
||
461 | ProjectNode refProject = solution.ProjectsTable[refr.Name]; |
||
462 | ss.WriteLine("\t\t({{{0}}}).{1} = ({{{2}}})", |
||
463 | project.Guid.ToString().ToUpper() |
||
464 | , i, |
||
465 | refProject.Guid.ToString().ToUpper() |
||
466 | ); |
||
467 | } |
||
468 | } |
||
469 | } |
||
470 | ss.WriteLine("\tEndGlobalSection"); |
||
471 | |||
472 | ss.WriteLine("\tGlobalSection(ProjectConfiguration) = postSolution"); |
||
473 | foreach(ProjectNode project in solution.Projects) |
||
474 | { |
||
475 | foreach(ConfigurationNode conf in solution.Configurations) |
||
476 | { |
||
477 | ss.WriteLine("\t\t{{{0}}}.{1}.ActiveCfg = {1}|.NET", |
||
478 | project.Guid.ToString().ToUpper(), |
||
479 | conf.Name); |
||
480 | |||
481 | ss.WriteLine("\t\t{{{0}}}.{1}.Build.0 = {1}|.NET", |
||
482 | project.Guid.ToString().ToUpper(), |
||
483 | conf.Name); |
||
484 | } |
||
485 | } |
||
486 | ss.WriteLine("\tEndGlobalSection"); |
||
487 | |||
488 | if(solution.Files != null) |
||
489 | { |
||
490 | ss.WriteLine("\tGlobalSection(SolutionItems) = postSolution"); |
||
491 | foreach(string file in solution.Files) |
||
492 | { |
||
493 | ss.WriteLine("\t\t{0} = {0}", file); |
||
494 | } |
||
495 | ss.WriteLine("\tEndGlobalSection"); |
||
496 | } |
||
497 | |||
498 | ss.WriteLine("\tGlobalSection(ExtensibilityGlobals) = postSolution"); |
||
499 | ss.WriteLine("\tEndGlobalSection"); |
||
500 | ss.WriteLine("\tGlobalSection(ExtensibilityAddIns) = postSolution"); |
||
501 | ss.WriteLine("\tEndGlobalSection"); |
||
502 | |||
503 | ss.WriteLine("EndGlobal"); |
||
504 | } |
||
505 | |||
506 | m_Kernel.CurrentWorkingDirectory.Pop(); |
||
507 | } |
||
508 | |||
509 | private void CleanProject(ProjectNode project) |
||
510 | { |
||
511 | m_Kernel.Log.Write("...Cleaning project: {0}", project.Name); |
||
512 | |||
513 | ToolInfo toolInfo = m_Tools[project.Language]; |
||
514 | string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); |
||
515 | string userFile = projectFile + ".user"; |
||
516 | |||
517 | Helper.DeleteIfExists(projectFile); |
||
518 | Helper.DeleteIfExists(userFile); |
||
519 | } |
||
520 | |||
521 | private void CleanSolution(SolutionNode solution) |
||
522 | { |
||
523 | m_Kernel.Log.Write("Cleaning Visual Studio {0} solution and project files", VersionName, solution.Name); |
||
524 | |||
525 | string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln"); |
||
526 | string suoFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "suo"); |
||
527 | |||
528 | Helper.DeleteIfExists(slnFile); |
||
529 | Helper.DeleteIfExists(suoFile); |
||
530 | |||
531 | foreach(ProjectNode project in solution.Projects) |
||
532 | { |
||
533 | CleanProject(project); |
||
534 | } |
||
535 | |||
536 | m_Kernel.Log.Write(""); |
||
537 | } |
||
538 | |||
539 | #endregion |
||
540 | |||
541 | #region ITarget Members |
||
542 | |||
543 | /// <summary> |
||
544 | /// Writes the specified kern. |
||
545 | /// </summary> |
||
546 | /// <param name="kern">The kern.</param> |
||
547 | public virtual void Write(Kernel kern) |
||
548 | { |
||
549 | if( kern == null ) |
||
550 | { |
||
551 | throw new ArgumentNullException("kern"); |
||
552 | } |
||
553 | m_Kernel = kern; |
||
554 | foreach(SolutionNode sol in m_Kernel.Solutions) |
||
555 | { |
||
556 | WriteSolution(sol); |
||
557 | } |
||
558 | m_Kernel = null; |
||
559 | } |
||
560 | |||
561 | /// <summary> |
||
562 | /// Cleans the specified kern. |
||
563 | /// </summary> |
||
564 | /// <param name="kern">The kern.</param> |
||
565 | public virtual void Clean(Kernel kern) |
||
566 | { |
||
567 | if( kern == null ) |
||
568 | { |
||
569 | throw new ArgumentNullException("kern"); |
||
570 | } |
||
571 | m_Kernel = kern; |
||
572 | foreach(SolutionNode sol in m_Kernel.Solutions) |
||
573 | { |
||
574 | CleanSolution(sol); |
||
575 | } |
||
576 | m_Kernel = null; |
||
577 | } |
||
578 | |||
579 | /// <summary> |
||
580 | /// Gets the name. |
||
581 | /// </summary> |
||
582 | /// <value>The name.</value> |
||
583 | public virtual string Name |
||
584 | { |
||
585 | get |
||
586 | { |
||
587 | return "vs2003"; |
||
588 | } |
||
589 | } |
||
590 | |||
591 | #endregion |
||
592 | } |
||
593 | } |