aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Prebuild/src/Core/Targets/VSGenericTarget.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Prebuild/src/Core/Targets/VSGenericTarget.cs')
-rw-r--r--Prebuild/src/Core/Targets/VSGenericTarget.cs1766
1 files changed, 886 insertions, 880 deletions
diff --git a/Prebuild/src/Core/Targets/VSGenericTarget.cs b/Prebuild/src/Core/Targets/VSGenericTarget.cs
index 400788b..b8904ad 100644
--- a/Prebuild/src/Core/Targets/VSGenericTarget.cs
+++ b/Prebuild/src/Core/Targets/VSGenericTarget.cs
@@ -35,141 +35,141 @@ using System.CodeDom.Compiler;
35namespace Prebuild.Core.Targets 35namespace Prebuild.Core.Targets
36{ 36{
37 37
38 /// <summary> 38 /// <summary>
39 /// 39 ///
40 /// </summary> 40 /// </summary>
41 public abstract class VSGenericTarget : ITarget 41 public abstract class VSGenericTarget : ITarget
42 { 42 {
43 #region Fields 43 #region Fields
44 44
45 readonly Dictionary<string, ToolInfo> tools = new Dictionary<string, ToolInfo>(); 45 readonly Dictionary<string, ToolInfo> tools = new Dictionary<string, ToolInfo>();
46// NameValueCollection CopyFiles = new NameValueCollection(); 46// NameValueCollection CopyFiles = new NameValueCollection();
47 Kernel kernel; 47 Kernel kernel;
48 #endregion 48 #endregion
49 49
50 #region Properties 50 #region Properties
51 /// <summary> 51 /// <summary>
52 /// Gets or sets the solution version. 52 /// Gets or sets the solution version.
53 /// </summary> 53 /// </summary>
54 /// <value>The solution version.</value> 54 /// <value>The solution version.</value>
55 public abstract string SolutionVersion { get; } 55 public abstract string SolutionVersion { get; }
56 /// <summary> 56 /// <summary>
57 /// Gets or sets the product version. 57 /// Gets or sets the product version.
58 /// </summary> 58 /// </summary>
59 /// <value>The product version.</value> 59 /// <value>The product version.</value>
60 public abstract string ProductVersion { get; } 60 public abstract string ProductVersion { get; }
61 /// <summary> 61 /// <summary>
62 /// Gets or sets the schema version. 62 /// Gets or sets the schema version.
63 /// </summary> 63 /// </summary>
64 /// <value>The schema version.</value> 64 /// <value>The schema version.</value>
65 public abstract string SchemaVersion { get; } 65 public abstract string SchemaVersion { get; }
66 /// <summary> 66 /// <summary>
67 /// Gets or sets the name of the version. 67 /// Gets or sets the name of the version.
68 /// </summary> 68 /// </summary>
69 /// <value>The name of the version.</value> 69 /// <value>The name of the version.</value>
70 public abstract string VersionName { get; } 70 public abstract string VersionName { get; }
71 /// <summary> 71 /// <summary>
72 /// Gets or sets the version. 72 /// Gets or sets the version.
73 /// </summary> 73 /// </summary>
74 /// <value>The version.</value> 74 /// <value>The version.</value>
75 public abstract VSVersion Version { get; } 75 public abstract VSVersion Version { get; }
76 /// <summary> 76 /// <summary>
77 /// Gets the name. 77 /// Gets the name.
78 /// </summary> 78 /// </summary>
79 /// <value>The name.</value> 79 /// <value>The name.</value>
80 public abstract string Name { get; } 80 public abstract string Name { get; }
81 81
82 protected abstract string GetToolsVersionXml(FrameworkVersion version); 82 protected abstract string GetToolsVersionXml(FrameworkVersion version);
83 public abstract string SolutionTag { get; } 83 public abstract string SolutionTag { get; }
84 84
85 #endregion 85 #endregion
86 86
87 #region Constructors 87 #region Constructors
88 88
89 /// <summary> 89 /// <summary>
90 /// Initializes a new instance of the <see cref="VSGenericTarget"/> class. 90 /// Initializes a new instance of the <see cref="VSGenericTarget"/> class.
91 /// </summary> 91 /// </summary>
92 protected VSGenericTarget() 92 protected VSGenericTarget()
93 { 93 {
94 tools["C#"] = new ToolInfo("C#", "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}", "csproj", "CSHARP", "$(MSBuildBinPath)\\Microsoft.CSHARP.Targets"); 94 tools["C#"] = new ToolInfo("C#", "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}", "csproj", "CSHARP", "$(MSBuildBinPath)\\Microsoft.CSHARP.Targets");
95 tools["Database"] = new ToolInfo("Database", "{4F174C21-8C12-11D0-8340-0000F80270F8}", "dbp", "UNKNOWN"); 95 tools["Database"] = new ToolInfo("Database", "{4F174C21-8C12-11D0-8340-0000F80270F8}", "dbp", "UNKNOWN");
96 tools["Boo"] = new ToolInfo("Boo", "{45CEA7DC-C2ED-48A6-ACE0-E16144C02365}", "booproj", "Boo", "$(BooBinPath)\\Boo.Microsoft.Build.targets"); 96 tools["Boo"] = new ToolInfo("Boo", "{45CEA7DC-C2ED-48A6-ACE0-E16144C02365}", "booproj", "Boo", "$(BooBinPath)\\Boo.Microsoft.Build.targets");
97 tools["VisualBasic"] = new ToolInfo("VisualBasic", "{F184B08F-C81C-45F6-A57F-5ABD9991F28F}", "vbproj", "VisualBasic", "$(MSBuildBinPath)\\Microsoft.VisualBasic.Targets"); 97 tools["VisualBasic"] = new ToolInfo("VisualBasic", "{F184B08F-C81C-45F6-A57F-5ABD9991F28F}", "vbproj", "VisualBasic", "$(MSBuildBinPath)\\Microsoft.VisualBasic.Targets");
98 tools["Folder"] = new ToolInfo("Folder", "{2150E333-8FDC-42A3-9474-1A3956D46DE8}", null, null); 98 tools["Folder"] = new ToolInfo("Folder", "{2150E333-8FDC-42A3-9474-1A3956D46DE8}", null, null);
99 } 99 }
100 100
101 #endregion 101 #endregion
102 102
103 #region Private Methods 103 #region Private Methods
104 104
105 private string MakeRefPath(ProjectNode project) 105 private string MakeRefPath(ProjectNode project)
106 { 106 {
107 string ret = ""; 107 string ret = "";
108 foreach (ReferencePathNode node in project.ReferencePaths) 108 foreach (ReferencePathNode node in project.ReferencePaths)
109 { 109 {
110 try 110 try
111 { 111 {
112 string fullPath = Helper.ResolvePath(node.Path); 112 string fullPath = Helper.ResolvePath(node.Path);
113 if (ret.Length < 1) 113 if (ret.Length < 1)
114 { 114 {
115 ret = fullPath; 115 ret = fullPath;
116 } 116 }
117 else 117 else
118 { 118 {
119 ret += ";" + fullPath; 119 ret += ";" + fullPath;
120 } 120 }
121 } 121 }
122 catch (ArgumentException) 122 catch (ArgumentException)
123 { 123 {
124 kernel.Log.Write(LogType.Warning, "Could not resolve reference path: {0}", node.Path); 124 kernel.Log.Write(LogType.Warning, "Could not resolve reference path: {0}", node.Path);
125 } 125 }
126 } 126 }
127 127
128 return ret; 128 return ret;
129 } 129 }
130 130
131 private static ProjectNode FindProjectInSolution(string name, SolutionNode solution) 131 private static ProjectNode FindProjectInSolution(string name, SolutionNode solution)
132 { 132 {
133 SolutionNode node = solution; 133 SolutionNode node = solution;
134 134
135 while (node.Parent is SolutionNode) 135 while (node.Parent is SolutionNode)
136 node = node.Parent as SolutionNode; 136 node = node.Parent as SolutionNode;
137 137
138 return FindProjectInSolutionRecursively(name, node); 138 return FindProjectInSolutionRecursively(name, node);
139 } 139 }
140 140
141 private static ProjectNode FindProjectInSolutionRecursively(string name, SolutionNode solution) 141 private static ProjectNode FindProjectInSolutionRecursively(string name, SolutionNode solution)
142 { 142 {
143 if (solution.ProjectsTable.ContainsKey(name)) 143 if (solution.ProjectsTable.ContainsKey(name))
144 return solution.ProjectsTable[name]; 144 return solution.ProjectsTable[name];
145 145
146 foreach (SolutionNode child in solution.Solutions) 146 foreach (SolutionNode child in solution.Solutions)
147 { 147 {
148 ProjectNode node = FindProjectInSolutionRecursively(name, child); 148 ProjectNode node = FindProjectInSolutionRecursively(name, child);
149 if (node != null) 149 if (node != null)
150 return node; 150 return node;
151 } 151 }
152 152
153 return null; 153 return null;
154 } 154 }
155 155
156 private void WriteProject(SolutionNode solution, ProjectNode project) 156 private void WriteProject(SolutionNode solution, ProjectNode project)
157 { 157 {
158 if (!tools.ContainsKey(project.Language)) 158 if (!tools.ContainsKey(project.Language))
159 { 159 {
160 throw new UnknownLanguageException("Unknown .NET language: " + project.Language); 160 throw new UnknownLanguageException("Unknown .NET language: " + project.Language);
161 } 161 }
162 162
163 ToolInfo toolInfo = tools[project.Language]; 163 ToolInfo toolInfo = tools[project.Language];
164 string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); 164 string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension);
165 StreamWriter ps = new StreamWriter(projectFile); 165 StreamWriter ps = new StreamWriter(projectFile);
166 166
167 kernel.CurrentWorkingDirectory.Push(); 167 kernel.CurrentWorkingDirectory.Push();
168 Helper.SetCurrentDir(Path.GetDirectoryName(projectFile)); 168 Helper.SetCurrentDir(Path.GetDirectoryName(projectFile));
169 169
170 #region Project File 170 #region Project File
171 using (ps) 171 using (ps)
172 { 172 {
173 string targets = ""; 173 string targets = "";
174 174
175 if(project.Files.CopyFiles > 0) 175 if(project.Files.CopyFiles > 0)
@@ -177,347 +177,353 @@ namespace Prebuild.Core.Targets
177 else 177 else
178 targets = "Build"; 178 targets = "Build";
179 179
180 ps.WriteLine("<Project DefaultTargets=\"{0}\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\" {1}>", targets, GetToolsVersionXml(project.FrameworkVersion)); 180 ps.WriteLine("<Project DefaultTargets=\"{0}\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\" {1}>", targets, GetToolsVersionXml(project.FrameworkVersion));
181 ps.WriteLine(" <PropertyGroup>"); 181 ps.WriteLine(" <PropertyGroup>");
182 ps.WriteLine(" <ProjectType>Local</ProjectType>"); 182 ps.WriteLine(" <ProjectType>Local</ProjectType>");
183 ps.WriteLine(" <ProductVersion>{0}</ProductVersion>", ProductVersion); 183 ps.WriteLine(" <ProductVersion>{0}</ProductVersion>", ProductVersion);
184 ps.WriteLine(" <SchemaVersion>{0}</SchemaVersion>", SchemaVersion); 184 ps.WriteLine(" <SchemaVersion>{0}</SchemaVersion>", SchemaVersion);
185 ps.WriteLine(" <ProjectGuid>{{{0}}}</ProjectGuid>", project.Guid.ToString().ToUpper()); 185 ps.WriteLine(" <ProjectGuid>{{{0}}}</ProjectGuid>", project.Guid.ToString().ToUpper());
186 186
187 // Visual Studio has a hard coded guid for the project type 187 // Visual Studio has a hard coded guid for the project type
188 if (project.Type == ProjectType.Web) 188 if (project.Type == ProjectType.Web)
189 ps.WriteLine(" <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>"); 189 ps.WriteLine(" <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>");
190 ps.WriteLine(" <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>"); 190 ps.WriteLine(" <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>");
191 ps.WriteLine(" <ApplicationIcon>{0}</ApplicationIcon>", project.AppIcon); 191 ps.WriteLine(" <ApplicationIcon>{0}</ApplicationIcon>", project.AppIcon);
192 ps.WriteLine(" <AssemblyKeyContainerName>"); 192 ps.WriteLine(" <AssemblyKeyContainerName>");
193 ps.WriteLine(" </AssemblyKeyContainerName>"); 193 ps.WriteLine(" </AssemblyKeyContainerName>");
194 ps.WriteLine(" <AssemblyName>{0}</AssemblyName>", project.AssemblyName); 194 ps.WriteLine(" <AssemblyName>{0}</AssemblyName>", project.AssemblyName);
195 foreach (ConfigurationNode conf in project.Configurations) 195 foreach (ConfigurationNode conf in project.Configurations)
196 {
197 if (conf.Options.KeyFile != "")
198 {
199 ps.WriteLine(" <AssemblyOriginatorKeyFile>{0}</AssemblyOriginatorKeyFile>", conf.Options.KeyFile);
200 ps.WriteLine(" <SignAssembly>true</SignAssembly>");
201 break;
202 }
203 }
204 ps.WriteLine(" <DefaultClientScript>JScript</DefaultClientScript>");
205 ps.WriteLine(" <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>");
206 ps.WriteLine(" <DefaultTargetSchema>IE50</DefaultTargetSchema>");
207 ps.WriteLine(" <DelaySign>false</DelaySign>");
208 ps.WriteLine(" <TargetFrameworkVersion>{0}</TargetFrameworkVersion>", project.FrameworkVersion.ToString().Replace("_", "."));
209
210 ps.WriteLine(" <OutputType>{0}</OutputType>", project.Type == ProjectType.Web ? ProjectType.Library.ToString() : project.Type.ToString());
211 ps.WriteLine(" <AppDesignerFolder>{0}</AppDesignerFolder>", project.DesignerFolder);
212 ps.WriteLine(" <RootNamespace>{0}</RootNamespace>", project.RootNamespace);
213 ps.WriteLine(" <StartupObject>{0}</StartupObject>", project.StartupObject);
214 if (string.IsNullOrEmpty(project.DebugStartParameters))
215 {
216 ps.WriteLine(" <StartArguments>{0}</StartArguments>", project.DebugStartParameters);
217 }
218 ps.WriteLine(" <FileUpgradeFlags>");
219 ps.WriteLine(" </FileUpgradeFlags>");
220
221 ps.WriteLine(" </PropertyGroup>");
222 if (!string.IsNullOrEmpty(project.ApplicationManifest))
196 { 223 {
197 if (conf.Options.KeyFile != "") 224 ps.WriteLine(" <PropertyGroup>");
198 { 225 ps.WriteLine(" <ApplicationManifest>" + project.ApplicationManifest + "</ApplicationManifest>");
199 ps.WriteLine(" <AssemblyOriginatorKeyFile>{0}</AssemblyOriginatorKeyFile>", conf.Options.KeyFile);
200 ps.WriteLine(" <SignAssembly>true</SignAssembly>");
201 break;
202 }
203 }
204 ps.WriteLine(" <DefaultClientScript>JScript</DefaultClientScript>");
205 ps.WriteLine(" <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>");
206 ps.WriteLine(" <DefaultTargetSchema>IE50</DefaultTargetSchema>");
207 ps.WriteLine(" <DelaySign>false</DelaySign>");
208 ps.WriteLine(" <TargetFrameworkVersion>{0}</TargetFrameworkVersion>", project.FrameworkVersion.ToString().Replace("_", "."));
209
210 ps.WriteLine(" <OutputType>{0}</OutputType>", project.Type == ProjectType.Web ? ProjectType.Library.ToString() : project.Type.ToString());
211 ps.WriteLine(" <AppDesignerFolder>{0}</AppDesignerFolder>", project.DesignerFolder);
212 ps.WriteLine(" <RootNamespace>{0}</RootNamespace>", project.RootNamespace);
213 ps.WriteLine(" <StartupObject>{0}</StartupObject>", project.StartupObject);
214 if (string.IsNullOrEmpty(project.DebugStartParameters))
215 {
216 ps.WriteLine(" <StartArguments>{0}</StartArguments>", project.DebugStartParameters);
217 }
218 ps.WriteLine(" <FileUpgradeFlags>");
219 ps.WriteLine(" </FileUpgradeFlags>");
220
221 ps.WriteLine(" </PropertyGroup>");
222
223 foreach (ConfigurationNode conf in project.Configurations)
224 {
225 ps.Write(" <PropertyGroup ");
226 ps.WriteLine("Condition=\" '$(Configuration)|$(Platform)' == '{0}|{1}' \">", conf.Name, conf.Platform);
227 ps.WriteLine(" <AllowUnsafeBlocks>{0}</AllowUnsafeBlocks>", conf.Options["AllowUnsafe"]);
228 ps.WriteLine(" <BaseAddress>{0}</BaseAddress>", conf.Options["BaseAddress"]);
229 ps.WriteLine(" <CheckForOverflowUnderflow>{0}</CheckForOverflowUnderflow>", conf.Options["CheckUnderflowOverflow"]);
230 ps.WriteLine(" <ConfigurationOverrideFile>");
231 ps.WriteLine(" </ConfigurationOverrideFile>");
232 ps.WriteLine(" <DefineConstants>{0}</DefineConstants>", conf.Options["CompilerDefines"]);
233 ps.WriteLine(" <DocumentationFile>{0}</DocumentationFile>", Helper.NormalizePath(conf.Options["XmlDocFile"].ToString()));
234 ps.WriteLine(" <DebugSymbols>{0}</DebugSymbols>", conf.Options["DebugInformation"]);
235 ps.WriteLine(" <FileAlignment>{0}</FileAlignment>", conf.Options["FileAlignment"]);
236 ps.WriteLine(" <Optimize>{0}</Optimize>", conf.Options["OptimizeCode"]);
237 if (project.Type != ProjectType.Web)
238 ps.WriteLine(" <OutputPath>{0}</OutputPath>",
239 Helper.EndPath(Helper.NormalizePath(conf.Options["OutputPath"].ToString())));
240 else
241 ps.WriteLine(" <OutputPath>{0}</OutputPath>",
242 Helper.EndPath(Helper.NormalizePath("bin\\")));
243
244 ps.WriteLine(" <RegisterForComInterop>{0}</RegisterForComInterop>", conf.Options["RegisterComInterop"]);
245 ps.WriteLine(" <RemoveIntegerChecks>{0}</RemoveIntegerChecks>", conf.Options["RemoveIntegerChecks"]);
246 ps.WriteLine(" <TreatWarningsAsErrors>{0}</TreatWarningsAsErrors>", conf.Options["WarningsAsErrors"]);
247 ps.WriteLine(" <WarningLevel>{0}</WarningLevel>", conf.Options["WarningLevel"]);
248 ps.WriteLine(" <NoStdLib>{0}</NoStdLib>", conf.Options["NoStdLib"]);
249 ps.WriteLine(" <NoWarn>{0}</NoWarn>", conf.Options["SuppressWarnings"]);
250 ps.WriteLine(" <PlatformTarget>{0}</PlatformTarget>", conf.Platform);
251 ps.WriteLine(" </PropertyGroup>"); 226 ps.WriteLine(" </PropertyGroup>");
252 } 227 }
253 228 foreach (ConfigurationNode conf in project.Configurations)
254 //ps.WriteLine(" </Settings>"); 229 {
255 230 ps.Write(" <PropertyGroup ");
256 Dictionary<ReferenceNode, ProjectNode> projectReferences = new Dictionary<ReferenceNode, ProjectNode>(); 231 ps.WriteLine("Condition=\" '$(Configuration)|$(Platform)' == '{0}|{1}' \">", conf.Name, conf.Platform);
257 List<ReferenceNode> otherReferences = new List<ReferenceNode>(); 232 ps.WriteLine(" <AllowUnsafeBlocks>{0}</AllowUnsafeBlocks>", conf.Options["AllowUnsafe"]);
258 233 ps.WriteLine(" <BaseAddress>{0}</BaseAddress>", conf.Options["BaseAddress"]);
259 foreach (ReferenceNode refr in project.References) 234 ps.WriteLine(" <CheckForOverflowUnderflow>{0}</CheckForOverflowUnderflow>", conf.Options["CheckUnderflowOverflow"]);
260 { 235 ps.WriteLine(" <ConfigurationOverrideFile>");
261 ProjectNode projectNode = FindProjectInSolution(refr.Name, solution); 236 ps.WriteLine(" </ConfigurationOverrideFile>");
262 237 ps.WriteLine(" <DefineConstants>{0}</DefineConstants>",
263 if (projectNode == null) 238 conf.Options["CompilerDefines"] == "" ? this.kernel.ForcedConditionals : conf.Options["CompilerDefines"] + ";" + kernel.ForcedConditionals);
264 otherReferences.Add(refr); 239 ps.WriteLine(" <DocumentationFile>{0}</DocumentationFile>", Helper.NormalizePath(conf.Options["XmlDocFile"].ToString()));
265 else 240 ps.WriteLine(" <DebugSymbols>{0}</DebugSymbols>", conf.Options["DebugInformation"]);
266 projectReferences.Add(refr, projectNode); 241 ps.WriteLine(" <FileAlignment>{0}</FileAlignment>", conf.Options["FileAlignment"]);
267 } 242 ps.WriteLine(" <Optimize>{0}</Optimize>", conf.Options["OptimizeCode"]);
268 // Assembly References 243 if (project.Type != ProjectType.Web)
269 ps.WriteLine(" <ItemGroup>"); 244 ps.WriteLine(" <OutputPath>{0}</OutputPath>",
270 245 Helper.EndPath(Helper.NormalizePath(conf.Options["OutputPath"].ToString())));
271 foreach (ReferenceNode refr in otherReferences) 246 else
272 { 247 ps.WriteLine(" <OutputPath>{0}</OutputPath>",
273 ps.Write(" <Reference"); 248 Helper.EndPath(Helper.NormalizePath("bin\\")));
274 ps.Write(" Include=\""); 249
275 ps.Write(refr.Name); 250 ps.WriteLine(" <RegisterForComInterop>{0}</RegisterForComInterop>", conf.Options["RegisterComInterop"]);
276 ps.WriteLine("\" >"); 251 ps.WriteLine(" <RemoveIntegerChecks>{0}</RemoveIntegerChecks>", conf.Options["RemoveIntegerChecks"]);
277 ps.Write(" <Name>"); 252 ps.WriteLine(" <TreatWarningsAsErrors>{0}</TreatWarningsAsErrors>", conf.Options["WarningsAsErrors"]);
278 ps.Write(refr.Name); 253 ps.WriteLine(" <WarningLevel>{0}</WarningLevel>", conf.Options["WarningLevel"]);
279 ps.WriteLine("</Name>"); 254 ps.WriteLine(" <NoStdLib>{0}</NoStdLib>", conf.Options["NoStdLib"]);
280 255 ps.WriteLine(" <NoWarn>{0}</NoWarn>", conf.Options["SuppressWarnings"]);
281 if(!String.IsNullOrEmpty(refr.Path)) 256 ps.WriteLine(" <PlatformTarget>{0}</PlatformTarget>", conf.Platform);
282 { 257 ps.WriteLine(" </PropertyGroup>");
283 // Use absolute path to assembly (for determining assembly type) 258 }
284 string absolutePath = Path.Combine(project.FullPath, refr.Path); 259
285 if(File.Exists(Helper.MakeFilePath(absolutePath, refr.Name, "exe"))) { 260 //ps.WriteLine(" </Settings>");
286 // Assembly is an executable (exe) 261
287 ps.WriteLine(" <HintPath>{0}</HintPath>", Helper.MakeFilePath(refr.Path, refr.Name, "exe")); 262 Dictionary<ReferenceNode, ProjectNode> projectReferences = new Dictionary<ReferenceNode, ProjectNode>();
288 } else if(File.Exists(Helper.MakeFilePath(absolutePath, refr.Name, "dll"))) { 263 List<ReferenceNode> otherReferences = new List<ReferenceNode>();
289 // Assembly is an library (dll) 264
290 ps.WriteLine(" <HintPath>{0}</HintPath>", Helper.MakeFilePath(refr.Path, refr.Name, "dll")); 265 foreach (ReferenceNode refr in project.References)
291 } else { 266 {
292 string referencePath = Helper.MakeFilePath(refr.Path, refr.Name, "dll"); 267 ProjectNode projectNode = FindProjectInSolution(refr.Name, solution);
293 kernel.Log.Write(LogType.Warning, "Reference \"{0}\": The specified file doesn't exist.", referencePath); 268
294 ps.WriteLine(" <HintPath>{0}</HintPath>", Helper.MakeFilePath(refr.Path, refr.Name, "dll")); 269 if (projectNode == null)
295 } 270 otherReferences.Add(refr);
296 } 271 else
297 272 projectReferences.Add(refr, projectNode);
298 ps.WriteLine(" <Private>{0}</Private>", refr.LocalCopy); 273 }
299 ps.WriteLine(" </Reference>"); 274 // Assembly References
300 } 275 ps.WriteLine(" <ItemGroup>");
301 ps.WriteLine(" </ItemGroup>"); 276
302 277 foreach (ReferenceNode refr in otherReferences)
303 //Project References 278 {
304 ps.WriteLine(" <ItemGroup>"); 279 ps.Write(" <Reference");
305 foreach (KeyValuePair<ReferenceNode, ProjectNode> pair in projectReferences) 280 ps.Write(" Include=\"");
306 { 281 ps.Write(refr.Name);
307 ToolInfo tool = tools[pair.Value.Language]; 282 ps.WriteLine("\" >");
308 if (tools == null) 283 ps.Write(" <Name>");
309 throw new UnknownLanguageException(); 284 ps.Write(refr.Name);
310 285 ps.WriteLine("</Name>");
311 string path = 286
312 Helper.MakePathRelativeTo(project.FullPath, 287 if(!String.IsNullOrEmpty(refr.Path))
313 Helper.MakeFilePath(pair.Value.FullPath, pair.Value.Name, tool.FileExtension)); 288 {
314 ps.WriteLine(" <ProjectReference Include=\"{0}\">", path); 289 // Use absolute path to assembly (for determining assembly type)
315 290 string absolutePath = Path.Combine(project.FullPath, refr.Path);
316 // TODO: Allow reference to visual basic projects 291 if(File.Exists(Helper.MakeFilePath(absolutePath, refr.Name, "exe"))) {
317 ps.WriteLine(" <Name>{0}</Name>", pair.Value.Name); 292 // Assembly is an executable (exe)
318 ps.WriteLine(" <Project>{0}</Project>", pair.Value.Guid.ToString("B").ToUpper()); 293 ps.WriteLine(" <HintPath>{0}</HintPath>", Helper.MakeFilePath(refr.Path, refr.Name, "exe"));
319 ps.WriteLine(" <Package>{0}</Package>", tool.Guid.ToUpper()); 294 } else if(File.Exists(Helper.MakeFilePath(absolutePath, refr.Name, "dll"))) {
320 295 // Assembly is an library (dll)
321 //This is the Copy Local flag in VS 296 ps.WriteLine(" <HintPath>{0}</HintPath>", Helper.MakeFilePath(refr.Path, refr.Name, "dll"));
322 ps.WriteLine(" <Private>{0}</Private>", pair.Key.LocalCopy); 297 } else {
323 298 string referencePath = Helper.MakeFilePath(refr.Path, refr.Name, "dll");
324 ps.WriteLine(" </ProjectReference>"); 299 kernel.Log.Write(LogType.Warning, "Reference \"{0}\": The specified file doesn't exist.", referencePath);
325 } 300 ps.WriteLine(" <HintPath>{0}</HintPath>", Helper.MakeFilePath(refr.Path, refr.Name, "dll"));
326 ps.WriteLine(" </ItemGroup>"); 301 }
327 302 }
328 // ps.WriteLine(" </Build>"); 303
329 ps.WriteLine(" <ItemGroup>"); 304 ps.WriteLine(" <Private>{0}</Private>", refr.LocalCopy);
330 305 ps.WriteLine(" </Reference>");
331 // ps.WriteLine(" <Include>"); 306 }
332 List<string> list = new List<string>(); 307 ps.WriteLine(" </ItemGroup>");
333 308
334 foreach (string path in project.Files) 309 //Project References
335 { 310 ps.WriteLine(" <ItemGroup>");
336 string lower = path.ToLower(); 311 foreach (KeyValuePair<ReferenceNode, ProjectNode> pair in projectReferences)
337 if (lower.EndsWith(".resx")) 312 {
338 { 313 ToolInfo tool = tools[pair.Value.Language];
339 string codebehind = String.Format("{0}.Designer{1}", path.Substring(0, path.LastIndexOf('.')), toolInfo.LanguageExtension); 314 if (tools == null)
340 if (!list.Contains(codebehind)) 315 throw new UnknownLanguageException();
341 list.Add(codebehind); 316
342 } 317 string path =
343 318 Helper.MakePathRelativeTo(project.FullPath,
344 } 319 Helper.MakeFilePath(pair.Value.FullPath, pair.Value.Name, tool.FileExtension));
345 320 ps.WriteLine(" <ProjectReference Include=\"{0}\">", path);
346 321
347 foreach (string filePath in project.Files) 322 // TODO: Allow reference to visual basic projects
348 { 323 ps.WriteLine(" <Name>{0}</Name>", pair.Value.Name);
324 ps.WriteLine(" <Project>{0}</Project>", pair.Value.Guid.ToString("B").ToUpper());
325 ps.WriteLine(" <Package>{0}</Package>", tool.Guid.ToUpper());
326
327 //This is the Copy Local flag in VS
328 ps.WriteLine(" <Private>{0}</Private>", pair.Key.LocalCopy);
329
330 ps.WriteLine(" </ProjectReference>");
331 }
332 ps.WriteLine(" </ItemGroup>");
333
334 // ps.WriteLine(" </Build>");
335 ps.WriteLine(" <ItemGroup>");
336
337 // ps.WriteLine(" <Include>");
338 List<string> list = new List<string>();
339
340 foreach (string path in project.Files)
341 {
342 string lower = path.ToLower();
343 if (lower.EndsWith(".resx"))
344 {
345 string codebehind = String.Format("{0}.Designer{1}", path.Substring(0, path.LastIndexOf('.')), toolInfo.LanguageExtension);
346 if (!list.Contains(codebehind))
347 list.Add(codebehind);
348 }
349
350 }
351
352
353 foreach (string filePath in project.Files)
354 {
349 // Add the filePath with the destination as the key 355 // Add the filePath with the destination as the key
350 // will use it later to form the copy parameters with Include lists 356 // will use it later to form the copy parameters with Include lists
351 // for each destination 357 // for each destination
352 if (project.Files.GetBuildAction(filePath) == BuildAction.Copy) 358 if (project.Files.GetBuildAction(filePath) == BuildAction.Copy)
353 continue; 359 continue;
354 // if (file == "Properties\\Bind.Designer.cs") 360 // if (file == "Properties\\Bind.Designer.cs")
355 // { 361 // {
356 // Console.WriteLine("Wait a minute!"); 362 // Console.WriteLine("Wait a minute!");
357 // Console.WriteLine(project.Files.GetSubType(file).ToString()); 363 // Console.WriteLine(project.Files.GetSubType(file).ToString());
358 // } 364 // }
359 SubType subType = project.Files.GetSubType(filePath); 365 SubType subType = project.Files.GetSubType(filePath);
360 366
361 // Visual Studio chokes on file names if forward slash is used as a path separator 367 // Visual Studio chokes on file names if forward slash is used as a path separator
362 // instead of backslash. So we must make sure that all file paths written to the 368 // instead of backslash. So we must make sure that all file paths written to the
363 // project file use \ as a path separator. 369 // project file use \ as a path separator.
364 string file = filePath.Replace(@"/", @"\"); 370 string file = filePath.Replace(@"/", @"\");
365 371
366 if (subType != SubType.Code && subType != SubType.Settings && subType != SubType.Designer 372 if (subType != SubType.Code && subType != SubType.Settings && subType != SubType.Designer
367 && subType != SubType.CodeBehind) 373 && subType != SubType.CodeBehind)
368 { 374 {
369 ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".resx"); 375 ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".resx");
370 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file)); 376 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file));
371 ps.WriteLine(" <SubType>Designer</SubType>"); 377 ps.WriteLine(" <SubType>Designer</SubType>");
372 ps.WriteLine(" </EmbeddedResource>"); 378 ps.WriteLine(" </EmbeddedResource>");
373 // 379 //
374 } 380 }
375 381
376 if (subType == SubType.Designer) 382 if (subType == SubType.Designer)
377 { 383 {
378 ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file); 384 ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file);
379 385
380 string autogen_name = file.Substring(0, file.LastIndexOf('.')) + ".Designer.cs"; 386 string autogen_name = file.Substring(0, file.LastIndexOf('.')) + ".Designer.cs";
381 string dependent_name = filePath.Substring(0, file.LastIndexOf('.')) + ".cs"; 387 string dependent_name = filePath.Substring(0, file.LastIndexOf('.')) + ".cs";
382 388
383 // Check for a parent .cs file with the same name as this designer file 389 // Check for a parent .cs file with the same name as this designer file
384 if (File.Exists(Helper.NormalizePath(dependent_name))) 390 if (File.Exists(Helper.NormalizePath(dependent_name)))
385 { 391 {
386 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(dependent_name)); 392 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(dependent_name));
387 } 393 }
388 else 394 else
389 { 395 {
390 ps.WriteLine(" <Generator>ResXFileCodeGenerator</Generator>"); 396 ps.WriteLine(" <Generator>ResXFileCodeGenerator</Generator>");
391 ps.WriteLine(" <LastGenOutput>{0}</LastGenOutput>", Path.GetFileName(autogen_name)); 397 ps.WriteLine(" <LastGenOutput>{0}</LastGenOutput>", Path.GetFileName(autogen_name));
392 ps.WriteLine(" <SubType>" + subType + "</SubType>"); 398 ps.WriteLine(" <SubType>" + subType + "</SubType>");
393 } 399 }
394 400
395 ps.WriteLine(" </EmbeddedResource>"); 401 ps.WriteLine(" </EmbeddedResource>");
396 if (File.Exists(Helper.NormalizePath(autogen_name))) 402 if (File.Exists(Helper.NormalizePath(autogen_name)))
397 { 403 {
398 ps.WriteLine(" <Compile Include=\"{0}\">", autogen_name); 404 ps.WriteLine(" <Compile Include=\"{0}\">", autogen_name);
399 //ps.WriteLine(" <DesignTime>True</DesignTime>"); 405 //ps.WriteLine(" <DesignTime>True</DesignTime>");
400 406
401 // If a parent .cs file exists, link this autogen file to it. Otherwise link 407 // If a parent .cs file exists, link this autogen file to it. Otherwise link
402 // to the designer file 408 // to the designer file
403 if (File.Exists(dependent_name)) 409 if (File.Exists(dependent_name))
404 { 410 {
405 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(dependent_name)); 411 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(dependent_name));
406 } 412 }
407 else 413 else
408 { 414 {
409 ps.WriteLine(" <AutoGen>True</AutoGen>"); 415 ps.WriteLine(" <AutoGen>True</AutoGen>");
410 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(filePath)); 416 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(filePath));
411 } 417 }
412 418
413 ps.WriteLine(" </Compile>"); 419 ps.WriteLine(" </Compile>");
414 } 420 }
415 list.Add(autogen_name); 421 list.Add(autogen_name);
416 } 422 }
417 if (subType == SubType.Settings) 423 if (subType == SubType.Settings)
418 { 424 {
419 ps.Write(" <{0} ", project.Files.GetBuildAction(filePath)); 425 ps.Write(" <{0} ", project.Files.GetBuildAction(filePath));
420 ps.WriteLine("Include=\"{0}\">", file); 426 ps.WriteLine("Include=\"{0}\">", file);
421 string fileName = Path.GetFileName(filePath); 427 string fileName = Path.GetFileName(filePath);
422 if (project.Files.GetBuildAction(filePath) == BuildAction.None) 428 if (project.Files.GetBuildAction(filePath) == BuildAction.None)
423 { 429 {
424 ps.WriteLine(" <Generator>SettingsSingleFileGenerator</Generator>"); 430 ps.WriteLine(" <Generator>SettingsSingleFileGenerator</Generator>");
425 ps.WriteLine(" <LastGenOutput>{0}</LastGenOutput>", fileName.Substring(0, fileName.LastIndexOf('.')) + ".Designer.cs"); 431 ps.WriteLine(" <LastGenOutput>{0}</LastGenOutput>", fileName.Substring(0, fileName.LastIndexOf('.')) + ".Designer.cs");
426 } 432 }
427 else 433 else
428 { 434 {
429 ps.WriteLine(" <SubType>Code</SubType>"); 435 ps.WriteLine(" <SubType>Code</SubType>");
430 ps.WriteLine(" <AutoGen>True</AutoGen>"); 436 ps.WriteLine(" <AutoGen>True</AutoGen>");
431 ps.WriteLine(" <DesignTimeSharedInput>True</DesignTimeSharedInput>"); 437 ps.WriteLine(" <DesignTimeSharedInput>True</DesignTimeSharedInput>");
432 string fileNameShort = fileName.Substring(0, fileName.LastIndexOf('.')); 438 string fileNameShort = fileName.Substring(0, fileName.LastIndexOf('.'));
433 string fileNameShorter = fileNameShort.Substring(0, fileNameShort.LastIndexOf('.')); 439 string fileNameShorter = fileNameShort.Substring(0, fileNameShort.LastIndexOf('.'));
434 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(fileNameShorter + ".settings")); 440 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(fileNameShorter + ".settings"));
435 } 441 }
436 ps.WriteLine(" </{0}>", project.Files.GetBuildAction(filePath)); 442 ps.WriteLine(" </{0}>", project.Files.GetBuildAction(filePath));
437 } 443 }
438 else if (subType != SubType.Designer) 444 else if (subType != SubType.Designer)
439 { 445 {
440 string path = Helper.NormalizePath(file); 446 string path = Helper.NormalizePath(file);
441 string path_lower = path.ToLower(); 447 string path_lower = path.ToLower();
442 448
443 if (!list.Contains(filePath)) 449 if (!list.Contains(filePath))
444 { 450 {
445 ps.Write(" <{0} ", project.Files.GetBuildAction(filePath)); 451 ps.Write(" <{0} ", project.Files.GetBuildAction(filePath));
446 452
447 int startPos = 0; 453 int startPos = 0;
448 if (project.Files.GetPreservePath(filePath)) 454 if (project.Files.GetPreservePath(filePath))
449 { 455 {
450 while ((@"./\").IndexOf(file.Substring(startPos, 1)) != -1) 456 while ((@"./\").IndexOf(file.Substring(startPos, 1)) != -1)
451 startPos++; 457 startPos++;
452 458
453 } 459 }
454 else 460 else
455 { 461 {
456 startPos = file.LastIndexOf(Path.GetFileName(path)); 462 startPos = file.LastIndexOf(Path.GetFileName(path));
457 } 463 }
458 464
459 // be sure to write out the path with backslashes so VS recognizes 465 // be sure to write out the path with backslashes so VS recognizes
460 // the file properly. 466 // the file properly.
461 ps.WriteLine("Include=\"{0}\">", file); 467 ps.WriteLine("Include=\"{0}\">", file);
462 468
463 int last_period_index = file.LastIndexOf('.'); 469 int last_period_index = file.LastIndexOf('.');
464 string short_file_name = (last_period_index >= 0) 470 string short_file_name = (last_period_index >= 0)
465 ? file.Substring(0, last_period_index) 471 ? file.Substring(0, last_period_index)
466 : file; 472 : file;
467 string extension = Path.GetExtension(path); 473 string extension = Path.GetExtension(path);
468 // make this upper case, so that when File.Exists tests for the 474 // make this upper case, so that when File.Exists tests for the
469 // existence of a designer file on a case-sensitive platform, 475 // existence of a designer file on a case-sensitive platform,
470 // it is correctly identified. 476 // it is correctly identified.
471 string designer_format = string.Format(".Designer{0}", extension); 477 string designer_format = string.Format(".Designer{0}", extension);
472 478
473 if (path_lower.EndsWith(designer_format.ToLowerInvariant())) 479 if (path_lower.EndsWith(designer_format.ToLowerInvariant()))
474 { 480 {
475 int designer_index = path.IndexOf(designer_format); 481 int designer_index = path.IndexOf(designer_format);
476 string file_name = path.Substring(0, designer_index); 482 string file_name = path.Substring(0, designer_index);
477 483
478 // There are two corrections to the next lines: 484 // There are two corrections to the next lines:
479 // 1. Fix the connection between a designer file and a form 485 // 1. Fix the connection between a designer file and a form
480 // or usercontrol that don't have an associated resx file. 486 // or usercontrol that don't have an associated resx file.
481 // 2. Connect settings files to associated designer files. 487 // 2. Connect settings files to associated designer files.
482 if (File.Exists(file_name + extension)) 488 if (File.Exists(file_name + extension))
483 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file_name + extension)); 489 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file_name + extension));
484 else if (File.Exists(file_name + ".resx")) 490 else if (File.Exists(file_name + ".resx"))
485 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file_name + ".resx")); 491 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file_name + ".resx"));
486 else if (File.Exists(file_name + ".settings")) 492 else if (File.Exists(file_name + ".settings"))
487 { 493 {
488 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file_name + ".settings")); 494 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file_name + ".settings"));
489 ps.WriteLine(" <AutoGen>True</AutoGen>"); 495 ps.WriteLine(" <AutoGen>True</AutoGen>");
490 ps.WriteLine(" <DesignTimeSharedInput>True</DesignTimeSharedInput>"); 496 ps.WriteLine(" <DesignTimeSharedInput>True</DesignTimeSharedInput>");
491 } 497 }
492 } 498 }
493 else if (subType == SubType.CodeBehind) 499 else if (subType == SubType.CodeBehind)
494 { 500 {
495 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(short_file_name)); 501 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(short_file_name));
496 } 502 }
497 if (project.Files.GetIsLink(filePath)) 503 if (project.Files.GetIsLink(filePath))
498 { 504 {
499 string alias = project.Files.GetLinkPath(filePath); 505 string alias = project.Files.GetLinkPath(filePath);
500 alias += file.Substring(startPos); 506 alias += file.Substring(startPos);
501 alias = Helper.NormalizePath(alias); 507 alias = Helper.NormalizePath(alias);
502 ps.WriteLine(" <Link>{0}</Link>", alias); 508 ps.WriteLine(" <Link>{0}</Link>", alias);
503 } 509 }
504 else if (project.Files.GetBuildAction(filePath) != BuildAction.None) 510 else if (project.Files.GetBuildAction(filePath) != BuildAction.None)
505 { 511 {
506 if (project.Files.GetBuildAction(filePath) != BuildAction.EmbeddedResource) 512 if (project.Files.GetBuildAction(filePath) != BuildAction.EmbeddedResource)
507 { 513 {
508 ps.WriteLine(" <SubType>{0}</SubType>", subType); 514 ps.WriteLine(" <SubType>{0}</SubType>", subType);
509 } 515 }
510 } 516 }
511 517
512 if (project.Files.GetCopyToOutput(filePath) != CopyToOutput.Never) 518 if (project.Files.GetCopyToOutput(filePath) != CopyToOutput.Never)
513 { 519 {
514 ps.WriteLine(" <CopyToOutputDirectory>{0}</CopyToOutputDirectory>", project.Files.GetCopyToOutput(filePath)); 520 ps.WriteLine(" <CopyToOutputDirectory>{0}</CopyToOutputDirectory>", project.Files.GetCopyToOutput(filePath));
515 } 521 }
516 522
517 ps.WriteLine(" </{0}>", project.Files.GetBuildAction(filePath)); 523 ps.WriteLine(" </{0}>", project.Files.GetBuildAction(filePath));
518 } 524 }
519 } 525 }
520 } 526 }
521 ps.WriteLine(" </ItemGroup>"); 527 ps.WriteLine(" </ItemGroup>");
522 528
523 /* 529 /*
@@ -553,420 +559,420 @@ namespace Prebuild.Core.Targets
553 ps.WriteLine(" </Target>"); 559 ps.WriteLine(" </Target>");
554 } 560 }
555 561
556 ps.WriteLine(" <Import Project=\"" + toolInfo.ImportProject + "\" />"); 562 ps.WriteLine(" <Import Project=\"" + toolInfo.ImportProject + "\" />");
557 ps.WriteLine(" <PropertyGroup>"); 563 ps.WriteLine(" <PropertyGroup>");
558 ps.WriteLine(" <PreBuildEvent>"); 564 ps.WriteLine(" <PreBuildEvent>");
559 ps.WriteLine(" </PreBuildEvent>"); 565 ps.WriteLine(" </PreBuildEvent>");
560 ps.WriteLine(" <PostBuildEvent>"); 566 ps.WriteLine(" <PostBuildEvent>");
561 ps.WriteLine(" </PostBuildEvent>"); 567 ps.WriteLine(" </PostBuildEvent>");
562 ps.WriteLine(" </PropertyGroup>"); 568 ps.WriteLine(" </PropertyGroup>");
563 ps.WriteLine("</Project>"); 569 ps.WriteLine("</Project>");
564 } 570 }
565 #endregion 571 #endregion
566 572
567 #region User File 573 #region User File
568 574
569 ps = new StreamWriter(projectFile + ".user"); 575 ps = new StreamWriter(projectFile + ".user");
570 using (ps) 576 using (ps)
571 { 577 {
572 // Get the first configuration from the project. 578 // Get the first configuration from the project.
573 ConfigurationNode firstConfiguration = null; 579 ConfigurationNode firstConfiguration = null;
574 580
575 if (project.Configurations.Count > 0) 581 if (project.Configurations.Count > 0)
576 { 582 {
577 firstConfiguration = project.Configurations[0]; 583 firstConfiguration = project.Configurations[0];
578 } 584 }
579 585
580 ps.WriteLine("<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">"); 586 ps.WriteLine("<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">");
581 //ps.WriteLine( "<VisualStudioProject>" ); 587 //ps.WriteLine( "<VisualStudioProject>" );
582 //ps.WriteLine(" <{0}>", toolInfo.XMLTag); 588 //ps.WriteLine(" <{0}>", toolInfo.XMLTag);
583 //ps.WriteLine(" <Build>"); 589 //ps.WriteLine(" <Build>");
584 ps.WriteLine(" <PropertyGroup>"); 590 ps.WriteLine(" <PropertyGroup>");
585 //ps.WriteLine(" <Settings ReferencePath=\"{0}\">", MakeRefPath(project)); 591 //ps.WriteLine(" <Settings ReferencePath=\"{0}\">", MakeRefPath(project));
586 592
587 if (firstConfiguration != null) 593 if (firstConfiguration != null)
588 { 594 {
589 ps.WriteLine(" <Configuration Condition=\" '$(Configuration)' == '' \">{0}</Configuration>", firstConfiguration.Name); 595 ps.WriteLine(" <Configuration Condition=\" '$(Configuration)' == '' \">{0}</Configuration>", firstConfiguration.Name);
590 ps.WriteLine(" <Platform Condition=\" '$(Platform)' == '' \">{0}</Platform>", firstConfiguration.Platform); 596 ps.WriteLine(" <Platform Condition=\" '$(Platform)' == '' \">{0}</Platform>", firstConfiguration.Platform);
591 } 597 }
592 598
593 ps.WriteLine(" <ReferencePath>{0}</ReferencePath>", MakeRefPath(project)); 599 ps.WriteLine(" <ReferencePath>{0}</ReferencePath>", MakeRefPath(project));
594 ps.WriteLine(" <LastOpenVersion>{0}</LastOpenVersion>", ProductVersion); 600 ps.WriteLine(" <LastOpenVersion>{0}</LastOpenVersion>", ProductVersion);
595 ps.WriteLine(" <ProjectView>ProjectFiles</ProjectView>"); 601 ps.WriteLine(" <ProjectView>ProjectFiles</ProjectView>");
596 ps.WriteLine(" <ProjectTrust>0</ProjectTrust>"); 602 ps.WriteLine(" <ProjectTrust>0</ProjectTrust>");
597 ps.WriteLine(" </PropertyGroup>"); 603 ps.WriteLine(" </PropertyGroup>");
598 foreach (ConfigurationNode conf in project.Configurations) 604 foreach (ConfigurationNode conf in project.Configurations)
599 { 605 {
600 ps.Write(" <PropertyGroup"); 606 ps.Write(" <PropertyGroup");
601 ps.Write(" Condition = \" '$(Configuration)|$(Platform)' == '{0}|{1}' \"", conf.Name, conf.Platform); 607 ps.Write(" Condition = \" '$(Configuration)|$(Platform)' == '{0}|{1}' \"", conf.Name, conf.Platform);
602 ps.WriteLine(" />"); 608 ps.WriteLine(" />");
603 } 609 }
604 ps.WriteLine("</Project>"); 610 ps.WriteLine("</Project>");
605 } 611 }
606 #endregion 612 #endregion
607 613
608 kernel.CurrentWorkingDirectory.Pop(); 614 kernel.CurrentWorkingDirectory.Pop();
609 } 615 }
610 616
611 private void WriteSolution(SolutionNode solution, bool writeSolutionToDisk) 617 private void WriteSolution(SolutionNode solution, bool writeSolutionToDisk)
612 { 618 {
613 kernel.Log.Write("Creating {0} solution and project files", VersionName); 619 kernel.Log.Write("Creating {0} solution and project files", VersionName);
614 620
615 foreach (SolutionNode child in solution.Solutions) 621 foreach (SolutionNode child in solution.Solutions)
616 { 622 {
617 kernel.Log.Write("...Creating folder: {0}", child.Name); 623 kernel.Log.Write("...Creating folder: {0}", child.Name);
618 WriteSolution(child, false); 624 WriteSolution(child, false);
619 } 625 }
620 626
621 foreach (ProjectNode project in solution.Projects) 627 foreach (ProjectNode project in solution.Projects)
622 { 628 {
623 kernel.Log.Write("...Creating project: {0}", project.Name); 629 kernel.Log.Write("...Creating project: {0}", project.Name);
624 WriteProject(solution, project); 630 WriteProject(solution, project);
625 } 631 }
626 632
627 foreach (DatabaseProjectNode project in solution.DatabaseProjects) 633 foreach (DatabaseProjectNode project in solution.DatabaseProjects)
628 { 634 {
629 kernel.Log.Write("...Creating database project: {0}", project.Name); 635 kernel.Log.Write("...Creating database project: {0}", project.Name);
630 WriteDatabaseProject(solution, project); 636 WriteDatabaseProject(solution, project);
631 } 637 }
632 638
633 if (writeSolutionToDisk) // only write main solution 639 if (writeSolutionToDisk) // only write main solution
634 { 640 {
635 kernel.Log.Write(""); 641 kernel.Log.Write("");
636 string solutionFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln"); 642 string solutionFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln");
637 643
638 using (StreamWriter ss = new StreamWriter(solutionFile)) 644 using (StreamWriter ss = new StreamWriter(solutionFile))
639 { 645 {
640 kernel.CurrentWorkingDirectory.Push(); 646 kernel.CurrentWorkingDirectory.Push();
641 Helper.SetCurrentDir(Path.GetDirectoryName(solutionFile)); 647 Helper.SetCurrentDir(Path.GetDirectoryName(solutionFile));
642 648
643 ss.WriteLine("Microsoft Visual Studio Solution File, Format Version {0}", SolutionVersion); 649 ss.WriteLine("Microsoft Visual Studio Solution File, Format Version {0}", SolutionVersion);
644 ss.WriteLine(SolutionTag); 650 ss.WriteLine(SolutionTag);
645 651
646 WriteProjectDeclarations(ss, solution, solution); 652 WriteProjectDeclarations(ss, solution, solution);
647 653
648 ss.WriteLine("Global"); 654 ss.WriteLine("Global");
649 655
650 ss.WriteLine("\tGlobalSection(SolutionConfigurationPlatforms) = preSolution"); 656 ss.WriteLine("\tGlobalSection(SolutionConfigurationPlatforms) = preSolution");
651 foreach (ConfigurationNode conf in solution.Configurations) 657 foreach (ConfigurationNode conf in solution.Configurations)
652 { 658 {
653 ss.WriteLine("\t\t{0} = {0}", conf.NameAndPlatform); 659 ss.WriteLine("\t\t{0} = {0}", conf.NameAndPlatform);
654 } 660 }
655 ss.WriteLine("\tEndGlobalSection"); 661 ss.WriteLine("\tEndGlobalSection");
656 662
657 ss.WriteLine("\tGlobalSection(ProjectConfigurationPlatforms) = postSolution"); 663 ss.WriteLine("\tGlobalSection(ProjectConfigurationPlatforms) = postSolution");
658 WriteConfigurationLines(solution.Configurations, solution, ss); 664 WriteConfigurationLines(solution.Configurations, solution, ss);
659 ss.WriteLine("\tEndGlobalSection"); 665 ss.WriteLine("\tEndGlobalSection");
660 666
661 if (solution.Solutions.Count > 0) 667 if (solution.Solutions.Count > 0)
662 { 668 {
663 ss.WriteLine("\tGlobalSection(NestedProjects) = preSolution"); 669 ss.WriteLine("\tGlobalSection(NestedProjects) = preSolution");
664 foreach (SolutionNode embeddedSolution in solution.Solutions) 670 foreach (SolutionNode embeddedSolution in solution.Solutions)
665 { 671 {
666 WriteNestedProjectMap(ss, embeddedSolution); 672 WriteNestedProjectMap(ss, embeddedSolution);
667 } 673 }
668 ss.WriteLine("\tEndGlobalSection"); 674 ss.WriteLine("\tEndGlobalSection");
669 } 675 }
670 676
671 ss.WriteLine("EndGlobal"); 677 ss.WriteLine("EndGlobal");
672 } 678 }
673 679
674 kernel.CurrentWorkingDirectory.Pop(); 680 kernel.CurrentWorkingDirectory.Pop();
675 } 681 }
676 } 682 }
677 683
678 private void WriteProjectDeclarations(TextWriter writer, SolutionNode actualSolution, SolutionNode embeddedSolution) 684 private void WriteProjectDeclarations(TextWriter writer, SolutionNode actualSolution, SolutionNode embeddedSolution)
679 { 685 {
680 foreach (SolutionNode childSolution in embeddedSolution.Solutions) 686 foreach (SolutionNode childSolution in embeddedSolution.Solutions)
681 { 687 {
682 WriteEmbeddedSolution(writer, childSolution); 688 WriteEmbeddedSolution(writer, childSolution);
683 WriteProjectDeclarations(writer, actualSolution, childSolution); 689 WriteProjectDeclarations(writer, actualSolution, childSolution);
684 } 690 }
685 691
686 foreach (ProjectNode project in embeddedSolution.Projects) 692 foreach (ProjectNode project in embeddedSolution.Projects)
687 { 693 {
688 WriteProject(actualSolution, writer, project); 694 WriteProject(actualSolution, writer, project);
689 } 695 }
690 696
691 foreach (DatabaseProjectNode dbProject in embeddedSolution.DatabaseProjects) 697 foreach (DatabaseProjectNode dbProject in embeddedSolution.DatabaseProjects)
692 { 698 {
693 WriteProject(actualSolution, writer, dbProject); 699 WriteProject(actualSolution, writer, dbProject);
694 } 700 }
695 701
696 if (actualSolution.Guid == embeddedSolution.Guid) 702 if (actualSolution.Guid == embeddedSolution.Guid)
697 { 703 {
698 WriteSolutionFiles(actualSolution, writer); 704 WriteSolutionFiles(actualSolution, writer);
699 } 705 }
700 } 706 }
701 707
702 private static void WriteNestedProjectMap(TextWriter writer, SolutionNode embeddedSolution) 708 private static void WriteNestedProjectMap(TextWriter writer, SolutionNode embeddedSolution)
703 { 709 {
704 foreach (ProjectNode project in embeddedSolution.Projects) 710 foreach (ProjectNode project in embeddedSolution.Projects)
705 { 711 {
706 WriteNestedProject(writer, embeddedSolution, project.Guid); 712 WriteNestedProject(writer, embeddedSolution, project.Guid);
707 } 713 }
708 714
709 foreach (DatabaseProjectNode dbProject in embeddedSolution.DatabaseProjects) 715 foreach (DatabaseProjectNode dbProject in embeddedSolution.DatabaseProjects)
710 { 716 {
711 WriteNestedProject(writer, embeddedSolution, dbProject.Guid); 717 WriteNestedProject(writer, embeddedSolution, dbProject.Guid);
712 } 718 }
713 719
714 foreach (SolutionNode child in embeddedSolution.Solutions) 720 foreach (SolutionNode child in embeddedSolution.Solutions)
715 { 721 {
716 WriteNestedProject(writer, embeddedSolution, child.Guid); 722 WriteNestedProject(writer, embeddedSolution, child.Guid);
717 WriteNestedProjectMap(writer, child); 723 WriteNestedProjectMap(writer, child);
718 } 724 }
719 } 725 }
720 726
721 private static void WriteNestedProject(TextWriter writer, SolutionNode solution, Guid projectGuid) 727 private static void WriteNestedProject(TextWriter writer, SolutionNode solution, Guid projectGuid)
722 { 728 {
723 WriteNestedFolder(writer, solution.Guid, projectGuid); 729 WriteNestedFolder(writer, solution.Guid, projectGuid);
724 } 730 }
725 731
726 private static void WriteNestedFolder(TextWriter writer, Guid parentGuid, Guid childGuid) 732 private static void WriteNestedFolder(TextWriter writer, Guid parentGuid, Guid childGuid)
727 { 733 {
728 writer.WriteLine("\t\t{0} = {1}", 734 writer.WriteLine("\t\t{0} = {1}",
729 childGuid.ToString("B").ToUpper(), 735 childGuid.ToString("B").ToUpper(),
730 parentGuid.ToString("B").ToUpper()); 736 parentGuid.ToString("B").ToUpper());
731 } 737 }
732 738
733 private static void WriteConfigurationLines(IEnumerable<ConfigurationNode> configurations, SolutionNode solution, TextWriter ss) 739 private static void WriteConfigurationLines(IEnumerable<ConfigurationNode> configurations, SolutionNode solution, TextWriter ss)
734 { 740 {
735 foreach (ProjectNode project in solution.Projects) 741 foreach (ProjectNode project in solution.Projects)
736 { 742 {
737 foreach (ConfigurationNode conf in configurations) 743 foreach (ConfigurationNode conf in configurations)
738 { 744 {
739 ss.WriteLine("\t\t{0}.{1}.ActiveCfg = {1}", 745 ss.WriteLine("\t\t{0}.{1}.ActiveCfg = {1}",
740 project.Guid.ToString("B").ToUpper(), 746 project.Guid.ToString("B").ToUpper(),
741 conf.NameAndPlatform); 747 conf.NameAndPlatform);
742 748
743 ss.WriteLine("\t\t{0}.{1}.Build.0 = {1}", 749 ss.WriteLine("\t\t{0}.{1}.Build.0 = {1}",
744 project.Guid.ToString("B").ToUpper(), 750 project.Guid.ToString("B").ToUpper(),
745 conf.NameAndPlatform); 751 conf.NameAndPlatform);
746 } 752 }
747 } 753 }
748 754
749 foreach (SolutionNode child in solution.Solutions) 755 foreach (SolutionNode child in solution.Solutions)
750 { 756 {
751 WriteConfigurationLines(configurations, child, ss); 757 WriteConfigurationLines(configurations, child, ss);
752 } 758 }
753 } 759 }
754 760
755 private void WriteSolutionFiles(SolutionNode solution, TextWriter ss) 761 private void WriteSolutionFiles(SolutionNode solution, TextWriter ss)
756 { 762 {
757 if(solution.Files != null && solution.Files.Count > 0) 763 if(solution.Files != null && solution.Files.Count > 0)
758 WriteProject(ss, "Folder", solution.Guid, "Solution Files", "Solution Files", solution.Files); 764 WriteProject(ss, "Folder", solution.Guid, "Solution Files", "Solution Files", solution.Files);
759 } 765 }
760 766
761 private void WriteEmbeddedSolution(TextWriter writer, SolutionNode embeddedSolution) 767 private void WriteEmbeddedSolution(TextWriter writer, SolutionNode embeddedSolution)
762 { 768 {
763 WriteProject(writer, "Folder", embeddedSolution.Guid, embeddedSolution.Name, embeddedSolution.Name, embeddedSolution.Files); 769 WriteProject(writer, "Folder", embeddedSolution.Guid, embeddedSolution.Name, embeddedSolution.Name, embeddedSolution.Files);
764 } 770 }
765 771
766 private void WriteProject(SolutionNode solution, TextWriter ss, ProjectNode project) 772 private void WriteProject(SolutionNode solution, TextWriter ss, ProjectNode project)
767 { 773 {
768 WriteProject(ss, solution, project.Language, project.Guid, project.Name, project.FullPath); 774 WriteProject(ss, solution, project.Language, project.Guid, project.Name, project.FullPath);
769 } 775 }
770 776
771 private void WriteProject(SolutionNode solution, TextWriter ss, DatabaseProjectNode dbProject) 777 private void WriteProject(SolutionNode solution, TextWriter ss, DatabaseProjectNode dbProject)
772 { 778 {
773 if (solution.Files != null && solution.Files.Count > 0) 779 if (solution.Files != null && solution.Files.Count > 0)
774 WriteProject(ss, solution, "Database", dbProject.Guid, dbProject.Name, dbProject.FullPath); 780 WriteProject(ss, solution, "Database", dbProject.Guid, dbProject.Name, dbProject.FullPath);
775 } 781 }
776 782
777 const string ProjectDeclarationBeginFormat = "Project(\"{0}\") = \"{1}\", \"{2}\", \"{3}\""; 783 const string ProjectDeclarationBeginFormat = "Project(\"{0}\") = \"{1}\", \"{2}\", \"{3}\"";
778 const string ProjectDeclarationEndFormat = "EndProject"; 784 const string ProjectDeclarationEndFormat = "EndProject";
779 785
780 private void WriteProject(TextWriter ss, SolutionNode solution, string language, Guid guid, string name, string projectFullPath) 786 private void WriteProject(TextWriter ss, SolutionNode solution, string language, Guid guid, string name, string projectFullPath)
781 { 787 {
782 if (!tools.ContainsKey(language)) 788 if (!tools.ContainsKey(language))
783 throw new UnknownLanguageException("Unknown .NET language: " + language); 789 throw new UnknownLanguageException("Unknown .NET language: " + language);
784 790
785 ToolInfo toolInfo = tools[language]; 791 ToolInfo toolInfo = tools[language];
786 792
787 string path = Helper.MakePathRelativeTo(solution.FullPath, projectFullPath); 793 string path = Helper.MakePathRelativeTo(solution.FullPath, projectFullPath);
788 794
789 path = Helper.MakeFilePath(path, name, toolInfo.FileExtension); 795 path = Helper.MakeFilePath(path, name, toolInfo.FileExtension);
790 796
791 WriteProject(ss, language, guid, name, path); 797 WriteProject(ss, language, guid, name, path);
792 } 798 }
793 799
794 private void WriteProject(TextWriter writer, string language, Guid projectGuid, string name, string location) 800 private void WriteProject(TextWriter writer, string language, Guid projectGuid, string name, string location)
795 { 801 {
796 WriteProject(writer, language, projectGuid, name, location, null); 802 WriteProject(writer, language, projectGuid, name, location, null);
797 } 803 }
798 804
799 private void WriteProject(TextWriter writer, string language, Guid projectGuid, string name, string location, FilesNode files) 805 private void WriteProject(TextWriter writer, string language, Guid projectGuid, string name, string location, FilesNode files)
800 { 806 {
801 if (!tools.ContainsKey(language)) 807 if (!tools.ContainsKey(language))
802 throw new UnknownLanguageException("Unknown .NET language: " + language); 808 throw new UnknownLanguageException("Unknown .NET language: " + language);
803 809
804 ToolInfo toolInfo = tools[language]; 810 ToolInfo toolInfo = tools[language];
805 811
806 writer.WriteLine(ProjectDeclarationBeginFormat, 812 writer.WriteLine(ProjectDeclarationBeginFormat,
807 toolInfo.Guid, 813 toolInfo.Guid,
808 name, 814 name,
809 location, 815 location,
810 projectGuid.ToString("B").ToUpper()); 816 projectGuid.ToString("B").ToUpper());
811 817
812 if (files != null) 818 if (files != null)
813 { 819 {
814 writer.WriteLine("\tProjectSection(SolutionItems) = preProject"); 820 writer.WriteLine("\tProjectSection(SolutionItems) = preProject");
815 821
816 foreach (string file in files) 822 foreach (string file in files)
817 writer.WriteLine("\t\t{0} = {0}", file); 823 writer.WriteLine("\t\t{0} = {0}", file);
818 824
819 writer.WriteLine("\tEndProjectSection"); 825 writer.WriteLine("\tEndProjectSection");
820 } 826 }
821 827
822 writer.WriteLine(ProjectDeclarationEndFormat); 828 writer.WriteLine(ProjectDeclarationEndFormat);
823 } 829 }
824 830
825 private void WriteDatabaseProject(SolutionNode solution, DatabaseProjectNode project) 831 private void WriteDatabaseProject(SolutionNode solution, DatabaseProjectNode project)
826 { 832 {
827 string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, "dbp"); 833 string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, "dbp");
828 IndentedTextWriter ps = new IndentedTextWriter(new StreamWriter(projectFile), " "); 834 IndentedTextWriter ps = new IndentedTextWriter(new StreamWriter(projectFile), " ");
829 835
830 kernel.CurrentWorkingDirectory.Push(); 836 kernel.CurrentWorkingDirectory.Push();
831 837
832 Helper.SetCurrentDir(Path.GetDirectoryName(projectFile)); 838 Helper.SetCurrentDir(Path.GetDirectoryName(projectFile));
833 839
834 using (ps) 840 using (ps)
835 { 841 {
836 ps.WriteLine("# Microsoft Developer Studio Project File - Database Project"); 842 ps.WriteLine("# Microsoft Developer Studio Project File - Database Project");
837 ps.WriteLine("Begin DataProject = \"{0}\"", project.Name); 843 ps.WriteLine("Begin DataProject = \"{0}\"", project.Name);
838 ps.Indent++; 844 ps.Indent++;
839 ps.WriteLine("MSDTVersion = \"80\""); 845 ps.WriteLine("MSDTVersion = \"80\"");
840 // TODO: Use the project.Files property 846 // TODO: Use the project.Files property
841 if (ContainsSqlFiles(Path.GetDirectoryName(projectFile))) 847 if (ContainsSqlFiles(Path.GetDirectoryName(projectFile)))
842 WriteDatabaseFoldersAndFiles(ps, Path.GetDirectoryName(projectFile)); 848 WriteDatabaseFoldersAndFiles(ps, Path.GetDirectoryName(projectFile));
843 849
844 ps.WriteLine("Begin DBRefFolder = \"Database References\""); 850 ps.WriteLine("Begin DBRefFolder = \"Database References\"");
845 ps.Indent++; 851 ps.Indent++;
846 foreach (DatabaseReferenceNode reference in project.References) 852 foreach (DatabaseReferenceNode reference in project.References)
847 { 853 {
848 ps.WriteLine("Begin DBRefNode = \"{0}\"", reference.Name); 854 ps.WriteLine("Begin DBRefNode = \"{0}\"", reference.Name);
849 ps.Indent++; 855 ps.Indent++;
850 ps.WriteLine("ConnectStr = \"{0}\"", reference.ConnectionString); 856 ps.WriteLine("ConnectStr = \"{0}\"", reference.ConnectionString);
851 ps.WriteLine("Provider = \"{0}\"", reference.ProviderId.ToString("B").ToUpper()); 857 ps.WriteLine("Provider = \"{0}\"", reference.ProviderId.ToString("B").ToUpper());
852 //ps.WriteLine("Colorizer = 5"); 858 //ps.WriteLine("Colorizer = 5");
853 ps.Indent--; 859 ps.Indent--;
854 ps.WriteLine("End"); 860 ps.WriteLine("End");
855 } 861 }
856 ps.Indent--; 862 ps.Indent--;
857 ps.WriteLine("End"); 863 ps.WriteLine("End");
858 ps.Indent--; 864 ps.Indent--;
859 ps.WriteLine("End"); 865 ps.WriteLine("End");
860 866
861 ps.Flush(); 867 ps.Flush();
862 } 868 }
863 869
864 kernel.CurrentWorkingDirectory.Pop(); 870 kernel.CurrentWorkingDirectory.Pop();
865 } 871 }
866 872
867 private static bool ContainsSqlFiles(string folder) 873 private static bool ContainsSqlFiles(string folder)
868 { 874 {
869 if(Directory.GetFiles(folder, "*.sql").Length > 0) 875 if(Directory.GetFiles(folder, "*.sql").Length > 0)
870 return true; // if the folder contains 1 .sql file, that's good enough 876 return true; // if the folder contains 1 .sql file, that's good enough
871 877
872 foreach (string child in Directory.GetDirectories(folder)) 878 foreach (string child in Directory.GetDirectories(folder))
873 { 879 {
874 if (ContainsSqlFiles(child)) 880 if (ContainsSqlFiles(child))
875 return true; // if 1 child folder contains a .sql file, still good enough 881 return true; // if 1 child folder contains a .sql file, still good enough
876 } 882 }
877 883
878 return false; 884 return false;
879 } 885 }
880 886
881 private static void WriteDatabaseFoldersAndFiles(IndentedTextWriter writer, string folder) 887 private static void WriteDatabaseFoldersAndFiles(IndentedTextWriter writer, string folder)
882 { 888 {
883 foreach (string child in Directory.GetDirectories(folder)) 889 foreach (string child in Directory.GetDirectories(folder))
884 { 890 {
885 if (ContainsSqlFiles(child)) 891 if (ContainsSqlFiles(child))
886 { 892 {
887 writer.WriteLine("Begin Folder = \"{0}\"", Path.GetFileName(child)); 893 writer.WriteLine("Begin Folder = \"{0}\"", Path.GetFileName(child));
888 writer.Indent++; 894 writer.Indent++;
889 WriteDatabaseFoldersAndFiles(writer, child); 895 WriteDatabaseFoldersAndFiles(writer, child);
890 writer.Indent--; 896 writer.Indent--;
891 writer.WriteLine("End"); 897 writer.WriteLine("End");
892 } 898 }
893 } 899 }
894 foreach (string file in Directory.GetFiles(folder, "*.sql")) 900 foreach (string file in Directory.GetFiles(folder, "*.sql"))
895 { 901 {
896 writer.WriteLine("Script = \"{0}\"", Path.GetFileName(file)); 902 writer.WriteLine("Script = \"{0}\"", Path.GetFileName(file));
897 } 903 }
898 } 904 }
899 905
900 private void CleanProject(ProjectNode project) 906 private void CleanProject(ProjectNode project)
901 { 907 {
902 kernel.Log.Write("...Cleaning project: {0}", project.Name); 908 kernel.Log.Write("...Cleaning project: {0}", project.Name);
903 909
904 ToolInfo toolInfo = tools[project.Language]; 910 ToolInfo toolInfo = tools[project.Language];
905 string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); 911 string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension);
906 string userFile = projectFile + ".user"; 912 string userFile = projectFile + ".user";
907 913
908 Helper.DeleteIfExists(projectFile); 914 Helper.DeleteIfExists(projectFile);
909 Helper.DeleteIfExists(userFile); 915 Helper.DeleteIfExists(userFile);
910 } 916 }
911 917
912 private void CleanSolution(SolutionNode solution) 918 private void CleanSolution(SolutionNode solution)
913 { 919 {
914 kernel.Log.Write("Cleaning {0} solution and project files", VersionName, solution.Name); 920 kernel.Log.Write("Cleaning {0} solution and project files", VersionName, solution.Name);
915 921
916 string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln"); 922 string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln");
917 string suoFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "suo"); 923 string suoFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "suo");
918 924
919 Helper.DeleteIfExists(slnFile); 925 Helper.DeleteIfExists(slnFile);
920 Helper.DeleteIfExists(suoFile); 926 Helper.DeleteIfExists(suoFile);
921 927
922 foreach (ProjectNode project in solution.Projects) 928 foreach (ProjectNode project in solution.Projects)
923 { 929 {
924 CleanProject(project); 930 CleanProject(project);
925 } 931 }
926 932
927 kernel.Log.Write(""); 933 kernel.Log.Write("");
928 } 934 }
929 935
930 #endregion 936 #endregion
931 937
932 #region ITarget Members 938 #region ITarget Members
933 939
934 /// <summary> 940 /// <summary>
935 /// Writes the specified kern. 941 /// Writes the specified kern.
936 /// </summary> 942 /// </summary>
937 /// <param name="kern">The kern.</param> 943 /// <param name="kern">The kern.</param>
938 public virtual void Write(Kernel kern) 944 public virtual void Write(Kernel kern)
939 { 945 {
940 if (kern == null) 946 if (kern == null)
941 { 947 {
942 throw new ArgumentNullException("kern"); 948 throw new ArgumentNullException("kern");
943 } 949 }
944 kernel = kern; 950 kernel = kern;
945 foreach (SolutionNode sol in kernel.Solutions) 951 foreach (SolutionNode sol in kernel.Solutions)
946 { 952 {
947 WriteSolution(sol, true); 953 WriteSolution(sol, true);
948 } 954 }
949 kernel = null; 955 kernel = null;
950 } 956 }
951 957
952 /// <summary> 958 /// <summary>
953 /// Cleans the specified kern. 959 /// Cleans the specified kern.
954 /// </summary> 960 /// </summary>
955 /// <param name="kern">The kern.</param> 961 /// <param name="kern">The kern.</param>
956 public virtual void Clean(Kernel kern) 962 public virtual void Clean(Kernel kern)
957 { 963 {
958 if (kern == null) 964 if (kern == null)
959 { 965 {
960 throw new ArgumentNullException("kern"); 966 throw new ArgumentNullException("kern");
961 } 967 }
962 kernel = kern; 968 kernel = kern;
963 foreach (SolutionNode sol in kernel.Solutions) 969 foreach (SolutionNode sol in kernel.Solutions)
964 { 970 {
965 CleanSolution(sol); 971 CleanSolution(sol);
966 } 972 }
967 kernel = null; 973 kernel = null;
968 } 974 }
969 975
970 #endregion 976 #endregion
971 } 977 }
972} 978}