1 namespace Castle
.NewGenerator
.Core
3 using System
.Collections
.Generic
;
7 public class VSSolution
9 private readonly string name
;
10 private readonly string solutionFolder
;
11 private readonly string targetFileName
;
12 private readonly List
<VSProject
> projects
= new List
<VSProject
>();
14 public VSSolution(string name
, string solutionFolder
, string targetFileName
)
17 this.solutionFolder
= solutionFolder
;
18 this.targetFileName
= targetFileName
;
21 public void Add(VSProject project
)
23 projects
.Add(project
);
28 File
.Delete(targetFileName
);
30 using(TextWriter writer
= new StreamWriter(new FileStream(targetFileName
, FileMode
.CreateNew
, FileAccess
.Write
), Encoding
.UTF8
))
33 writer
.WriteLine("Microsoft Visual Studio Solution File, Format Version 9.00");
34 writer
.WriteLine("# Visual Studio 2005");
36 foreach(VSProject project
in projects
)
38 writer
.WriteLine("Project(\"{0}\") = \"{2}\", \"{3}\", \"{1}\"",
39 "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}", project
.Id
.ToString("P"), project
.Name
, MakeRelative(project
.FileName
));
40 writer
.WriteLine(" ProjectSection(WebsiteProperties) = preProject");
41 writer
.WriteLine(" Debug.AspNetCompiler.Debug = \"True\"");
42 writer
.WriteLine(" Release.AspNetCompiler.Debug = \"False\"");
43 writer
.WriteLine(" EndProjectSection");
44 writer
.WriteLine("EndProject");
47 writer
.WriteLine("Global");
48 writer
.WriteLine(" GlobalSection(SolutionConfigurationPlatforms) = preSolution");
49 writer
.WriteLine(" Debug|Any CPU = Debug|Any CPU");
50 writer
.WriteLine(" Release|Any CPU = Release|Any CPU");
51 writer
.WriteLine(" EndGlobalSection");
52 writer
.WriteLine(" GlobalSection(ProjectConfigurationPlatforms) = postSolution");
54 foreach(VSProject project
in projects
)
56 writer
.WriteLine(" {0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU", project
.Id
.ToString("P"));
57 writer
.WriteLine(" {0}.Debug|Any CPU.Build.0 = Debug|Any CPU", project
.Id
.ToString("P"));
58 writer
.WriteLine(" {0}.Release|Any CPU.ActiveCfg = Release|Any CPU", project
.Id
.ToString("P"));
59 writer
.WriteLine(" {0}.Release|Any CPU.Build.0 = Release|Any CPU", project
.Id
.ToString("P"));
62 writer
.WriteLine(" EndGlobalSection");
63 writer
.WriteLine(" GlobalSection(SolutionProperties) = preSolution");
64 writer
.WriteLine(" HideSolutionNode = FALSE");
65 writer
.WriteLine(" EndGlobalSection");
66 writer
.WriteLine("EndGlobal");
70 private string MakeRelative(string fileName
)
72 return fileName
.Substring(solutionFolder
.Length
+ 1);