aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Prebuild/src/Core/Targets/VS2003Target.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Prebuild/src/Core/Targets/VS2003Target.cs')
-rw-r--r--Prebuild/src/Core/Targets/VS2003Target.cs1266
1 files changed, 633 insertions, 633 deletions
diff --git a/Prebuild/src/Core/Targets/VS2003Target.cs b/Prebuild/src/Core/Targets/VS2003Target.cs
index b3236a8..c3ca930 100644
--- a/Prebuild/src/Core/Targets/VS2003Target.cs
+++ b/Prebuild/src/Core/Targets/VS2003Target.cs
@@ -1,633 +1,633 @@
1#region BSD License 1#region BSD License
2/* 2/*
3Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) 3Copyright (c) 2004-2005 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: 2006-09-29 21:11:40 +0200 (fr, 29 sep 2006) $ 30 * $Date: 2006-09-29 21:11:40 +0200 (fr, 29 sep 2006) $
31 * $Revision: 177 $ 31 * $Revision: 177 $
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;
39 39
40using Prebuild.Core.Attributes; 40using Prebuild.Core.Attributes;
41using Prebuild.Core.Interfaces; 41using Prebuild.Core.Interfaces;
42using Prebuild.Core.Nodes; 42using Prebuild.Core.Nodes;
43using Prebuild.Core.Utilities; 43using Prebuild.Core.Utilities;
44 44
45namespace Prebuild.Core.Targets 45namespace Prebuild.Core.Targets
46{ 46{
47 /// <summary> 47 /// <summary>
48 /// 48 ///
49 /// </summary> 49 /// </summary>
50 public enum VSVersion 50 public enum VSVersion
51 { 51 {
52 /// <summary> 52 /// <summary>
53 /// 53 ///
54 /// </summary> 54 /// </summary>
55 VS70, 55 VS70,
56 /// <summary> 56 /// <summary>
57 /// 57 ///
58 /// </summary> 58 /// </summary>
59 VS71, 59 VS71,
60 /// <summary> 60 /// <summary>
61 /// 61 ///
62 /// </summary> 62 /// </summary>
63 VS80 63 VS80
64 } 64 }
65 65
66 /// <summary> 66 /// <summary>
67 /// 67 ///
68 /// </summary> 68 /// </summary>
69 [Target("vs2003")] 69 [Target("vs2003")]
70 public class VS2003Target : ITarget 70 public class VS2003Target : ITarget
71 { 71 {
72 72
73 #region Fields 73 #region Fields
74 74
75 string solutionVersion = "8.00"; 75 string solutionVersion = "8.00";
76 string productVersion = "7.10.3077"; 76 string productVersion = "7.10.3077";
77 string schemaVersion = "2.0"; 77 string schemaVersion = "2.0";
78 string versionName = "2003"; 78 string versionName = "2003";
79 VSVersion version = VSVersion.VS71; 79 VSVersion version = VSVersion.VS71;
80 80
81 Hashtable m_Tools; 81 Hashtable m_Tools;
82 Kernel m_Kernel; 82 Kernel m_Kernel;
83 83
84 /// <summary> 84 /// <summary>
85 /// Gets or sets the solution version. 85 /// Gets or sets the solution version.
86 /// </summary> 86 /// </summary>
87 /// <value>The solution version.</value> 87 /// <value>The solution version.</value>
88 protected string SolutionVersion 88 protected string SolutionVersion
89 { 89 {
90 get 90 get
91 { 91 {
92 return this.solutionVersion; 92 return this.solutionVersion;
93 } 93 }
94 set 94 set
95 { 95 {
96 this.solutionVersion = value; 96 this.solutionVersion = value;
97 } 97 }
98 } 98 }
99 /// <summary> 99 /// <summary>
100 /// Gets or sets the product version. 100 /// Gets or sets the product version.
101 /// </summary> 101 /// </summary>
102 /// <value>The product version.</value> 102 /// <value>The product version.</value>
103 protected string ProductVersion 103 protected string ProductVersion
104 { 104 {
105 get 105 get
106 { 106 {
107 return this.productVersion; 107 return this.productVersion;
108 } 108 }
109 set 109 set
110 { 110 {
111 this.productVersion = value; 111 this.productVersion = value;
112 } 112 }
113 } 113 }
114 /// <summary> 114 /// <summary>
115 /// Gets or sets the schema version. 115 /// Gets or sets the schema version.
116 /// </summary> 116 /// </summary>
117 /// <value>The schema version.</value> 117 /// <value>The schema version.</value>
118 protected string SchemaVersion 118 protected string SchemaVersion
119 { 119 {
120 get 120 get
121 { 121 {
122 return this.schemaVersion; 122 return this.schemaVersion;
123 } 123 }
124 set 124 set
125 { 125 {
126 this.schemaVersion = value; 126 this.schemaVersion = value;
127 } 127 }
128 } 128 }
129 /// <summary> 129 /// <summary>
130 /// Gets or sets the name of the version. 130 /// Gets or sets the name of the version.
131 /// </summary> 131 /// </summary>
132 /// <value>The name of the version.</value> 132 /// <value>The name of the version.</value>
133 protected string VersionName 133 protected string VersionName
134 { 134 {
135 get 135 get
136 { 136 {
137 return this.versionName; 137 return this.versionName;
138 } 138 }
139 set 139 set
140 { 140 {
141 this.versionName = value; 141 this.versionName = value;
142 } 142 }
143 } 143 }
144 /// <summary> 144 /// <summary>
145 /// Gets or sets the version. 145 /// Gets or sets the version.
146 /// </summary> 146 /// </summary>
147 /// <value>The version.</value> 147 /// <value>The version.</value>
148 protected VSVersion Version 148 protected VSVersion Version
149 { 149 {
150 get 150 get
151 { 151 {
152 return this.version; 152 return this.version;
153 } 153 }
154 set 154 set
155 { 155 {
156 this.version = value; 156 this.version = value;
157 } 157 }
158 } 158 }
159 159
160 #endregion 160 #endregion
161 161
162 #region Constructors 162 #region Constructors
163 163
164 /// <summary> 164 /// <summary>
165 /// Initializes a new instance of the <see cref="VS2003Target"/> class. 165 /// Initializes a new instance of the <see cref="VS2003Target"/> class.
166 /// </summary> 166 /// </summary>
167 public VS2003Target() 167 public VS2003Target()
168 { 168 {
169 m_Tools = new Hashtable(); 169 m_Tools = new Hashtable();
170 170
171 m_Tools["C#"] = new ToolInfo("C#", "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}", "csproj", "CSHARP"); 171 m_Tools["C#"] = new ToolInfo("C#", "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}", "csproj", "CSHARP");
172 m_Tools["VB.NET"] = new ToolInfo("VB.NET", "{F184B08F-C81C-45F6-A57F-5ABD9991F28F}", "vbproj", "VisualBasic"); 172 m_Tools["VB.NET"] = new ToolInfo("VB.NET", "{F184B08F-C81C-45F6-A57F-5ABD9991F28F}", "vbproj", "VisualBasic");
173 } 173 }
174 174
175 #endregion 175 #endregion
176 176
177 #region Private Methods 177 #region Private Methods
178 178
179 private string MakeRefPath(ProjectNode project) 179 private string MakeRefPath(ProjectNode project)
180 { 180 {
181 string ret = ""; 181 string ret = "";
182 foreach(ReferencePathNode node in project.ReferencePaths) 182 foreach(ReferencePathNode node in project.ReferencePaths)
183 { 183 {
184 try 184 try
185 { 185 {
186 string fullPath = Helper.ResolvePath(node.Path); 186 string fullPath = Helper.ResolvePath(node.Path);
187 if(ret.Length < 1) 187 if(ret.Length < 1)
188 { 188 {
189 ret = fullPath; 189 ret = fullPath;
190 } 190 }
191 else 191 else
192 { 192 {
193 ret += ";" + fullPath; 193 ret += ";" + fullPath;
194 } 194 }
195 } 195 }
196 catch(ArgumentException) 196 catch(ArgumentException)
197 { 197 {
198 m_Kernel.Log.Write(LogType.Warning, "Could not resolve reference path: {0}", node.Path); 198 m_Kernel.Log.Write(LogType.Warning, "Could not resolve reference path: {0}", node.Path);
199 } 199 }
200 } 200 }
201 201
202 return ret; 202 return ret;
203 } 203 }
204 204
205 private void WriteProject(SolutionNode solution, ProjectNode project) 205 private void WriteProject(SolutionNode solution, ProjectNode project)
206 { 206 {
207 if(!m_Tools.ContainsKey(project.Language)) 207 if(!m_Tools.ContainsKey(project.Language))
208 { 208 {
209 throw new UnknownLanguageException("Unknown .NET language: " + project.Language); 209 throw new UnknownLanguageException("Unknown .NET language: " + project.Language);
210 } 210 }
211 211
212 ToolInfo toolInfo = (ToolInfo)m_Tools[project.Language]; 212 ToolInfo toolInfo = (ToolInfo)m_Tools[project.Language];
213 string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); 213 string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension);
214 StreamWriter ps = new StreamWriter(projectFile); 214 StreamWriter ps = new StreamWriter(projectFile);
215 215
216 m_Kernel.CurrentWorkingDirectory.Push(); 216 m_Kernel.CurrentWorkingDirectory.Push();
217 Helper.SetCurrentDir(Path.GetDirectoryName(projectFile)); 217 Helper.SetCurrentDir(Path.GetDirectoryName(projectFile));
218 218
219 IEnumerator enumerator; 219 IEnumerator enumerator;
220 //ConfigurationNode scripts; 220 //ConfigurationNode scripts;
221 221
222 using(ps) 222 using(ps)
223 { 223 {
224 ps.WriteLine("<VisualStudioProject>"); 224 ps.WriteLine("<VisualStudioProject>");
225 ps.WriteLine(" <{0}", toolInfo.XmlTag); 225 ps.WriteLine(" <{0}", toolInfo.XmlTag);
226 ps.WriteLine("\t\t\t\tProjectType = \"Local\""); 226 ps.WriteLine("\t\t\t\tProjectType = \"Local\"");
227 ps.WriteLine("\t\t\t\tProductVersion = \"{0}\"", this.ProductVersion); 227 ps.WriteLine("\t\t\t\tProductVersion = \"{0}\"", this.ProductVersion);
228 ps.WriteLine("\t\t\t\tSchemaVersion = \"{0}\"", this.SchemaVersion); 228 ps.WriteLine("\t\t\t\tSchemaVersion = \"{0}\"", this.SchemaVersion);
229 ps.WriteLine("\t\t\t\tProjectGuid = \"{{{0}}}\"", project.Guid.ToString().ToUpper()); 229 ps.WriteLine("\t\t\t\tProjectGuid = \"{{{0}}}\"", project.Guid.ToString().ToUpper());
230 ps.WriteLine("\t\t>"); 230 ps.WriteLine("\t\t>");
231 231
232 ps.WriteLine("\t\t\t\t<Build>"); 232 ps.WriteLine("\t\t\t\t<Build>");
233 ps.WriteLine(" <Settings"); 233 ps.WriteLine(" <Settings");
234 ps.WriteLine("\t\t\t\t ApplicationIcon = \"{0}\"",project.AppIcon); 234 ps.WriteLine("\t\t\t\t ApplicationIcon = \"{0}\"",project.AppIcon);
235 ps.WriteLine("\t\t\t\t AssemblyKeyContainerName = \"\""); 235 ps.WriteLine("\t\t\t\t AssemblyKeyContainerName = \"\"");
236 ps.WriteLine("\t\t\t\t AssemblyName = \"{0}\"", project.AssemblyName); 236 ps.WriteLine("\t\t\t\t AssemblyName = \"{0}\"", project.AssemblyName);
237 ps.WriteLine("\t\t\t\t AssemblyOriginatorKeyFile = \"\""); 237 ps.WriteLine("\t\t\t\t AssemblyOriginatorKeyFile = \"\"");
238 ps.WriteLine("\t\t\t\t DefaultClientScript = \"JScript\""); 238 ps.WriteLine("\t\t\t\t DefaultClientScript = \"JScript\"");
239 ps.WriteLine("\t\t\t\t DefaultHTMLPageLayout = \"Grid\""); 239 ps.WriteLine("\t\t\t\t DefaultHTMLPageLayout = \"Grid\"");
240 ps.WriteLine("\t\t\t\t DefaultTargetSchema = \"IE50\""); 240 ps.WriteLine("\t\t\t\t DefaultTargetSchema = \"IE50\"");
241 ps.WriteLine("\t\t\t\t DelaySign = \"false\""); 241 ps.WriteLine("\t\t\t\t DelaySign = \"false\"");
242 242
243 if(this.Version == VSVersion.VS70) 243 if(this.Version == VSVersion.VS70)
244 { 244 {
245 ps.WriteLine("\t\t\t\t NoStandardLibraries = \"false\""); 245 ps.WriteLine("\t\t\t\t NoStandardLibraries = \"false\"");
246 } 246 }
247 247
248 ps.WriteLine("\t\t\t\t OutputType = \"{0}\"", project.Type.ToString()); 248 ps.WriteLine("\t\t\t\t OutputType = \"{0}\"", project.Type.ToString());
249 249
250 enumerator = project.Configurations.GetEnumerator(); 250 enumerator = project.Configurations.GetEnumerator();
251 enumerator.Reset(); 251 enumerator.Reset();
252 enumerator.MoveNext(); 252 enumerator.MoveNext();
253 foreach(ConfigurationNode conf in project.Configurations) 253 foreach(ConfigurationNode conf in project.Configurations)
254 { 254 {
255 if (conf.Options["PreBuildEvent"] != null && conf.Options["PreBuildEvent"].ToString().Length != 0) 255 if (conf.Options["PreBuildEvent"] != null && conf.Options["PreBuildEvent"].ToString().Length != 0)
256 { 256 {
257 ps.WriteLine("\t\t\t\t PreBuildEvent = \"{0}\"", Helper.NormalizePath(conf.Options["PreBuildEvent"].ToString())); 257 ps.WriteLine("\t\t\t\t PreBuildEvent = \"{0}\"", Helper.NormalizePath(conf.Options["PreBuildEvent"].ToString()));
258 } 258 }
259 else 259 else
260 { 260 {
261 ps.WriteLine("\t\t\t\t PreBuildEvent = \"{0}\"", conf.Options["PreBuildEvent"]); 261 ps.WriteLine("\t\t\t\t PreBuildEvent = \"{0}\"", conf.Options["PreBuildEvent"]);
262 } 262 }
263 if (conf.Options["PostBuildEvent"] != null && conf.Options["PostBuildEvent"].ToString().Length != 0) 263 if (conf.Options["PostBuildEvent"] != null && conf.Options["PostBuildEvent"].ToString().Length != 0)
264 { 264 {
265 ps.WriteLine("\t\t\t\t PostBuildEvent = \"{0}\"", Helper.NormalizePath(conf.Options["PostBuildEvent"].ToString())); 265 ps.WriteLine("\t\t\t\t PostBuildEvent = \"{0}\"", Helper.NormalizePath(conf.Options["PostBuildEvent"].ToString()));
266 } 266 }
267 else 267 else
268 { 268 {
269 ps.WriteLine("\t\t\t\t PostBuildEvent = \"{0}\"", conf.Options["PostBuildEvent"]); 269 ps.WriteLine("\t\t\t\t PostBuildEvent = \"{0}\"", conf.Options["PostBuildEvent"]);
270 } 270 }
271 if (conf.Options["RunPostBuildEvent"] == null) 271 if (conf.Options["RunPostBuildEvent"] == null)
272 { 272 {
273 ps.WriteLine("\t\t\t\t RunPostBuildEvent = \"{0}\"", "OnBuildSuccess"); 273 ps.WriteLine("\t\t\t\t RunPostBuildEvent = \"{0}\"", "OnBuildSuccess");
274 } 274 }
275 else 275 else
276 { 276 {
277 ps.WriteLine("\t\t\t\t RunPostBuildEvent = \"{0}\"", conf.Options["RunPostBuildEvent"]); 277 ps.WriteLine("\t\t\t\t RunPostBuildEvent = \"{0}\"", conf.Options["RunPostBuildEvent"]);
278 } 278 }
279 break; 279 break;
280 } 280 }
281 281
282 ps.WriteLine("\t\t\t\t RootNamespace = \"{0}\"", project.RootNamespace); 282 ps.WriteLine("\t\t\t\t RootNamespace = \"{0}\"", project.RootNamespace);
283 ps.WriteLine("\t\t\t\t StartupObject = \"{0}\"", project.StartupObject); 283 ps.WriteLine("\t\t\t\t StartupObject = \"{0}\"", project.StartupObject);
284 ps.WriteLine("\t\t >"); 284 ps.WriteLine("\t\t >");
285 285
286 foreach(ConfigurationNode conf in project.Configurations) 286 foreach(ConfigurationNode conf in project.Configurations)
287 { 287 {
288 ps.WriteLine("\t\t\t\t <Config"); 288 ps.WriteLine("\t\t\t\t <Config");
289 ps.WriteLine("\t\t\t\t Name = \"{0}\"", conf.Name); 289 ps.WriteLine("\t\t\t\t Name = \"{0}\"", conf.Name);
290 ps.WriteLine("\t\t\t\t AllowUnsafeBlocks = \"{0}\"", conf.Options["AllowUnsafe"].ToString().ToLower()); 290 ps.WriteLine("\t\t\t\t AllowUnsafeBlocks = \"{0}\"", conf.Options["AllowUnsafe"].ToString().ToLower());
291 ps.WriteLine("\t\t\t\t BaseAddress = \"{0}\"", conf.Options["BaseAddress"]); 291 ps.WriteLine("\t\t\t\t BaseAddress = \"{0}\"", conf.Options["BaseAddress"]);
292 ps.WriteLine("\t\t\t\t CheckForOverflowUnderflow = \"{0}\"", conf.Options["CheckUnderflowOverflow"].ToString().ToLower()); 292 ps.WriteLine("\t\t\t\t CheckForOverflowUnderflow = \"{0}\"", conf.Options["CheckUnderflowOverflow"].ToString().ToLower());
293 ps.WriteLine("\t\t\t\t ConfigurationOverrideFile = \"\""); 293 ps.WriteLine("\t\t\t\t ConfigurationOverrideFile = \"\"");
294 ps.WriteLine("\t\t\t\t DefineConstants = \"{0}\"", conf.Options["CompilerDefines"]); 294 ps.WriteLine("\t\t\t\t DefineConstants = \"{0}\"", conf.Options["CompilerDefines"]);
295 ps.WriteLine("\t\t\t\t DocumentationFile = \"{0}\"", GetXmlDocFile(project, conf));//default to the assembly name 295 ps.WriteLine("\t\t\t\t DocumentationFile = \"{0}\"", GetXmlDocFile(project, conf));//default to the assembly name
296 ps.WriteLine("\t\t\t\t DebugSymbols = \"{0}\"", conf.Options["DebugInformation"].ToString().ToLower()); 296 ps.WriteLine("\t\t\t\t DebugSymbols = \"{0}\"", conf.Options["DebugInformation"].ToString().ToLower());
297 ps.WriteLine("\t\t\t\t FileAlignment = \"{0}\"", conf.Options["FileAlignment"]); 297 ps.WriteLine("\t\t\t\t FileAlignment = \"{0}\"", conf.Options["FileAlignment"]);
298 ps.WriteLine("\t\t\t\t IncrementalBuild = \"{0}\"", conf.Options["IncrementalBuild"].ToString().ToLower()); 298 ps.WriteLine("\t\t\t\t IncrementalBuild = \"{0}\"", conf.Options["IncrementalBuild"].ToString().ToLower());
299 299
300 if(this.Version == VSVersion.VS71) 300 if(this.Version == VSVersion.VS71)
301 { 301 {
302 ps.WriteLine("\t\t\t\t NoStdLib = \"{0}\"", conf.Options["NoStdLib"].ToString().ToLower()); 302 ps.WriteLine("\t\t\t\t NoStdLib = \"{0}\"", conf.Options["NoStdLib"].ToString().ToLower());
303 ps.WriteLine("\t\t\t\t NoWarn = \"{0}\"", conf.Options["SuppressWarnings"].ToString().ToLower()); 303 ps.WriteLine("\t\t\t\t NoWarn = \"{0}\"", conf.Options["SuppressWarnings"].ToString().ToLower());
304 } 304 }
305 305
306 ps.WriteLine("\t\t\t\t Optimize = \"{0}\"", conf.Options["OptimizeCode"].ToString().ToLower()); 306 ps.WriteLine("\t\t\t\t Optimize = \"{0}\"", conf.Options["OptimizeCode"].ToString().ToLower());
307 ps.WriteLine(" OutputPath = \"{0}\"", 307 ps.WriteLine(" OutputPath = \"{0}\"",
308 Helper.EndPath(Helper.NormalizePath(conf.Options["OutputPath"].ToString()))); 308 Helper.EndPath(Helper.NormalizePath(conf.Options["OutputPath"].ToString())));
309 ps.WriteLine(" RegisterForComInterop = \"{0}\"", conf.Options["RegisterComInterop"].ToString().ToLower()); 309 ps.WriteLine(" RegisterForComInterop = \"{0}\"", conf.Options["RegisterComInterop"].ToString().ToLower());
310 ps.WriteLine(" RemoveIntegerChecks = \"{0}\"", conf.Options["RemoveIntegerChecks"].ToString().ToLower()); 310 ps.WriteLine(" RemoveIntegerChecks = \"{0}\"", conf.Options["RemoveIntegerChecks"].ToString().ToLower());
311 ps.WriteLine(" TreatWarningsAsErrors = \"{0}\"", conf.Options["WarningsAsErrors"].ToString().ToLower()); 311 ps.WriteLine(" TreatWarningsAsErrors = \"{0}\"", conf.Options["WarningsAsErrors"].ToString().ToLower());
312 ps.WriteLine(" WarningLevel = \"{0}\"", conf.Options["WarningLevel"]); 312 ps.WriteLine(" WarningLevel = \"{0}\"", conf.Options["WarningLevel"]);
313 ps.WriteLine(" />"); 313 ps.WriteLine(" />");
314 } 314 }
315 315
316 ps.WriteLine(" </Settings>"); 316 ps.WriteLine(" </Settings>");
317 317
318 ps.WriteLine(" <References>"); 318 ps.WriteLine(" <References>");
319 foreach(ReferenceNode refr in project.References) 319 foreach(ReferenceNode refr in project.References)
320 { 320 {
321 ps.WriteLine(" <Reference"); 321 ps.WriteLine(" <Reference");
322 ps.WriteLine(" Name = \"{0}\"", refr.Name); 322 ps.WriteLine(" Name = \"{0}\"", refr.Name);
323 ps.WriteLine(" AssemblyName = \"{0}\"", refr.Name); 323 ps.WriteLine(" AssemblyName = \"{0}\"", refr.Name);
324 324
325 if(solution.ProjectsTable.ContainsKey(refr.Name)) 325 if(solution.ProjectsTable.ContainsKey(refr.Name))
326 { 326 {
327 ProjectNode refProject = (ProjectNode)solution.ProjectsTable[refr.Name]; 327 ProjectNode refProject = (ProjectNode)solution.ProjectsTable[refr.Name];
328 ps.WriteLine(" Project = \"{{{0}}}\"", refProject.Guid.ToString().ToUpper()); 328 ps.WriteLine(" Project = \"{{{0}}}\"", refProject.Guid.ToString().ToUpper());
329 ps.WriteLine(" Package = \"{0}\"", toolInfo.Guid.ToString().ToUpper()); 329 ps.WriteLine(" Package = \"{0}\"", toolInfo.Guid.ToString().ToUpper());
330 } 330 }
331 else 331 else
332 { 332 {
333 if(refr.Path != null) 333 if(refr.Path != null)
334 { 334 {
335 ps.WriteLine(" HintPath = \"{0}\"", Helper.MakeFilePath(refr.Path, refr.Name, "dll")); 335 ps.WriteLine(" HintPath = \"{0}\"", Helper.MakeFilePath(refr.Path, refr.Name, "dll"));
336 } 336 }
337 337
338 } 338 }
339 339
340 if(refr.LocalCopySpecified) 340 if(refr.LocalCopySpecified)
341 { 341 {
342 ps.WriteLine(" Private = \"{0}\"",refr.LocalCopy); 342 ps.WriteLine(" Private = \"{0}\"",refr.LocalCopy);
343 } 343 }
344 344
345 ps.WriteLine(" />"); 345 ps.WriteLine(" />");
346 } 346 }
347 ps.WriteLine(" </References>"); 347 ps.WriteLine(" </References>");
348 348
349 ps.WriteLine(" </Build>"); 349 ps.WriteLine(" </Build>");
350 ps.WriteLine(" <Files>"); 350 ps.WriteLine(" <Files>");
351 351
352 ps.WriteLine(" <Include>"); 352 ps.WriteLine(" <Include>");
353 353
354 foreach(string file in project.Files) 354 foreach(string file in project.Files)
355 { 355 {
356 string fileName = file.Replace(".\\", ""); 356 string fileName = file.Replace(".\\", "");
357 ps.WriteLine(" <File"); 357 ps.WriteLine(" <File");
358 ps.WriteLine(" RelPath = \"{0}\"", fileName); 358 ps.WriteLine(" RelPath = \"{0}\"", fileName);
359 ps.WriteLine(" SubType = \"{0}\"", project.Files.GetSubType(file)); 359 ps.WriteLine(" SubType = \"{0}\"", project.Files.GetSubType(file));
360 ps.WriteLine(" BuildAction = \"{0}\"", project.Files.GetBuildAction(file)); 360 ps.WriteLine(" BuildAction = \"{0}\"", project.Files.GetBuildAction(file));
361 ps.WriteLine(" />"); 361 ps.WriteLine(" />");
362 362
363 if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings) 363 if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings)
364 { 364 {
365 ps.WriteLine(" <File"); 365 ps.WriteLine(" <File");
366 ps.WriteLine(" RelPath = \"{0}\"", fileName.Substring(0, fileName.LastIndexOf('.')) + ".resx"); 366 ps.WriteLine(" RelPath = \"{0}\"", fileName.Substring(0, fileName.LastIndexOf('.')) + ".resx");
367 int slash = fileName.LastIndexOf('\\'); 367 int slash = fileName.LastIndexOf('\\');
368 if (slash == -1) 368 if (slash == -1)
369 { 369 {
370 ps.WriteLine(" DependentUpon = \"{0}\"", fileName); 370 ps.WriteLine(" DependentUpon = \"{0}\"", fileName);
371 } 371 }
372 else 372 else
373 { 373 {
374 ps.WriteLine(" DependentUpon = \"{0}\"", fileName.Substring(slash + 1, fileName.Length - slash - 1)); 374 ps.WriteLine(" DependentUpon = \"{0}\"", fileName.Substring(slash + 1, fileName.Length - slash - 1));
375 } 375 }
376 ps.WriteLine(" BuildAction = \"{0}\"", "EmbeddedResource"); 376 ps.WriteLine(" BuildAction = \"{0}\"", "EmbeddedResource");
377 ps.WriteLine(" />"); 377 ps.WriteLine(" />");
378 378
379 } 379 }
380 } 380 }
381 ps.WriteLine(" </Include>"); 381 ps.WriteLine(" </Include>");
382 382
383 ps.WriteLine(" </Files>"); 383 ps.WriteLine(" </Files>");
384 ps.WriteLine(" </{0}>", toolInfo.XmlTag); 384 ps.WriteLine(" </{0}>", toolInfo.XmlTag);
385 ps.WriteLine("</VisualStudioProject>"); 385 ps.WriteLine("</VisualStudioProject>");
386 } 386 }
387 387
388 ps = new StreamWriter(projectFile + ".user"); 388 ps = new StreamWriter(projectFile + ".user");
389 using(ps) 389 using(ps)
390 { 390 {
391 ps.WriteLine("<VisualStudioProject>"); 391 ps.WriteLine("<VisualStudioProject>");
392 ps.WriteLine(" <{0}>", toolInfo.XmlTag); 392 ps.WriteLine(" <{0}>", toolInfo.XmlTag);
393 ps.WriteLine(" <Build>"); 393 ps.WriteLine(" <Build>");
394 394
395 ps.WriteLine(" <Settings ReferencePath=\"{0}\">", MakeRefPath(project)); 395 ps.WriteLine(" <Settings ReferencePath=\"{0}\">", MakeRefPath(project));
396 foreach(ConfigurationNode conf in project.Configurations) 396 foreach(ConfigurationNode conf in project.Configurations)
397 { 397 {
398 ps.WriteLine(" <Config"); 398 ps.WriteLine(" <Config");
399 ps.WriteLine(" Name = \"{0}\"", conf.Name); 399 ps.WriteLine(" Name = \"{0}\"", conf.Name);
400 ps.WriteLine(" />"); 400 ps.WriteLine(" />");
401 } 401 }
402 ps.WriteLine(" </Settings>"); 402 ps.WriteLine(" </Settings>");
403 403
404 ps.WriteLine(" </Build>"); 404 ps.WriteLine(" </Build>");
405 ps.WriteLine(" </{0}>", toolInfo.XmlTag); 405 ps.WriteLine(" </{0}>", toolInfo.XmlTag);
406 ps.WriteLine("</VisualStudioProject>"); 406 ps.WriteLine("</VisualStudioProject>");
407 } 407 }
408 408
409 m_Kernel.CurrentWorkingDirectory.Pop(); 409 m_Kernel.CurrentWorkingDirectory.Pop();
410 } 410 }
411 411
412 /// <summary> 412 /// <summary>
413 /// Gets the XML doc file. 413 /// Gets the XML doc file.
414 /// </summary> 414 /// </summary>
415 /// <param name="project">The project.</param> 415 /// <param name="project">The project.</param>
416 /// <param name="conf">The conf.</param> 416 /// <param name="conf">The conf.</param>
417 /// <returns></returns> 417 /// <returns></returns>
418 public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf) 418 public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf)
419 { 419 {
420 if( conf == null ) 420 if( conf == null )
421 { 421 {
422 throw new ArgumentNullException("conf"); 422 throw new ArgumentNullException("conf");
423 } 423 }
424 if( project == null ) 424 if( project == null )
425 { 425 {
426 throw new ArgumentNullException("project"); 426 throw new ArgumentNullException("project");
427 } 427 }
428 // if(!(bool)conf.Options["GenerateXmlDocFile"]) //default to none, if the generate option is false 428 // if(!(bool)conf.Options["GenerateXmlDocFile"]) //default to none, if the generate option is false
429 // { 429 // {
430 // return string.Empty; 430 // return string.Empty;
431 // } 431 // }
432 432
433 //default to "AssemblyName.xml" 433 //default to "AssemblyName.xml"
434 //string defaultValue = Path.GetFileNameWithoutExtension(project.AssemblyName) + ".xml"; 434 //string defaultValue = Path.GetFileNameWithoutExtension(project.AssemblyName) + ".xml";
435 //return (string)conf.Options["XmlDocFile", defaultValue]; 435 //return (string)conf.Options["XmlDocFile", defaultValue];
436 436
437 //default to no XmlDocFile file 437 //default to no XmlDocFile file
438 return (string)conf.Options["XmlDocFile", ""]; 438 return (string)conf.Options["XmlDocFile", ""];
439 } 439 }
440 440
441 private void WriteSolution(SolutionNode solution) 441 private void WriteSolution(SolutionNode solution)
442 { 442 {
443 m_Kernel.Log.Write("Creating Visual Studio {0} solution and project files", this.VersionName); 443 m_Kernel.Log.Write("Creating Visual Studio {0} solution and project files", this.VersionName);
444 444
445 foreach(ProjectNode project in solution.Projects) 445 foreach(ProjectNode project in solution.Projects)
446 { 446 {
447 if(m_Kernel.AllowProject(project.FilterGroups)) 447 if(m_Kernel.AllowProject(project.FilterGroups))
448 { 448 {
449 m_Kernel.Log.Write("...Creating project: {0}", project.Name); 449 m_Kernel.Log.Write("...Creating project: {0}", project.Name);
450 WriteProject(solution, project); 450 WriteProject(solution, project);
451 } 451 }
452 } 452 }
453 453
454 m_Kernel.Log.Write(""); 454 m_Kernel.Log.Write("");
455 string solutionFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln"); 455 string solutionFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln");
456 StreamWriter ss = new StreamWriter(solutionFile); 456 StreamWriter ss = new StreamWriter(solutionFile);
457 457
458 m_Kernel.CurrentWorkingDirectory.Push(); 458 m_Kernel.CurrentWorkingDirectory.Push();
459 Helper.SetCurrentDir(Path.GetDirectoryName(solutionFile)); 459 Helper.SetCurrentDir(Path.GetDirectoryName(solutionFile));
460 460
461 using(ss) 461 using(ss)
462 { 462 {
463 ss.WriteLine("Microsoft Visual Studio Solution File, Format Version {0}", this.SolutionVersion); 463 ss.WriteLine("Microsoft Visual Studio Solution File, Format Version {0}", this.SolutionVersion);
464 foreach(ProjectNode project in solution.Projects) 464 foreach(ProjectNode project in solution.Projects)
465 { 465 {
466 if(!m_Tools.ContainsKey(project.Language)) 466 if(!m_Tools.ContainsKey(project.Language))
467 { 467 {
468 throw new UnknownLanguageException("Unknown .NET language: " + project.Language); 468 throw new UnknownLanguageException("Unknown .NET language: " + project.Language);
469 } 469 }
470 470
471 ToolInfo toolInfo = (ToolInfo)m_Tools[project.Language]; 471 ToolInfo toolInfo = (ToolInfo)m_Tools[project.Language];
472 472
473 string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); 473 string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
474 ss.WriteLine("Project(\"{0}\") = \"{1}\", \"{2}\", \"{{{3}}}\"", 474 ss.WriteLine("Project(\"{0}\") = \"{1}\", \"{2}\", \"{{{3}}}\"",
475 toolInfo.Guid, project.Name, Helper.MakeFilePath(path, project.Name, 475 toolInfo.Guid, project.Name, Helper.MakeFilePath(path, project.Name,
476 toolInfo.FileExtension), project.Guid.ToString().ToUpper()); 476 toolInfo.FileExtension), project.Guid.ToString().ToUpper());
477 477
478 ss.WriteLine("\tProjectSection(ProjectDependencies) = postProject"); 478 ss.WriteLine("\tProjectSection(ProjectDependencies) = postProject");
479 ss.WriteLine("\tEndProjectSection"); 479 ss.WriteLine("\tEndProjectSection");
480 480
481 ss.WriteLine("EndProject"); 481 ss.WriteLine("EndProject");
482 } 482 }
483 483
484 ss.WriteLine("Global"); 484 ss.WriteLine("Global");
485 485
486 ss.WriteLine("\tGlobalSection(SolutionConfiguration) = preSolution"); 486 ss.WriteLine("\tGlobalSection(SolutionConfiguration) = preSolution");
487 foreach(ConfigurationNode conf in solution.Configurations) 487 foreach(ConfigurationNode conf in solution.Configurations)
488 { 488 {
489 ss.WriteLine("\t\t{0} = {0}", conf.Name); 489 ss.WriteLine("\t\t{0} = {0}", conf.Name);
490 } 490 }
491 ss.WriteLine("\tEndGlobalSection"); 491 ss.WriteLine("\tEndGlobalSection");
492 492
493 ss.WriteLine("\tGlobalSection(ProjectDependencies) = postSolution"); 493 ss.WriteLine("\tGlobalSection(ProjectDependencies) = postSolution");
494 foreach(ProjectNode project in solution.Projects) 494 foreach(ProjectNode project in solution.Projects)
495 { 495 {
496 for(int i = 0; i < project.References.Count; i++) 496 for(int i = 0; i < project.References.Count; i++)
497 { 497 {
498 ReferenceNode refr = (ReferenceNode)project.References[i]; 498 ReferenceNode refr = (ReferenceNode)project.References[i];
499 if(solution.ProjectsTable.ContainsKey(refr.Name)) 499 if(solution.ProjectsTable.ContainsKey(refr.Name))
500 { 500 {
501 ProjectNode refProject = (ProjectNode)solution.ProjectsTable[refr.Name]; 501 ProjectNode refProject = (ProjectNode)solution.ProjectsTable[refr.Name];
502 ss.WriteLine("\t\t({{{0}}}).{1} = ({{{2}}})", 502 ss.WriteLine("\t\t({{{0}}}).{1} = ({{{2}}})",
503 project.Guid.ToString().ToUpper() 503 project.Guid.ToString().ToUpper()
504 , i, 504 , i,
505 refProject.Guid.ToString().ToUpper() 505 refProject.Guid.ToString().ToUpper()
506 ); 506 );
507 } 507 }
508 } 508 }
509 } 509 }
510 ss.WriteLine("\tEndGlobalSection"); 510 ss.WriteLine("\tEndGlobalSection");
511 511
512 ss.WriteLine("\tGlobalSection(ProjectConfiguration) = postSolution"); 512 ss.WriteLine("\tGlobalSection(ProjectConfiguration) = postSolution");
513 foreach(ProjectNode project in solution.Projects) 513 foreach(ProjectNode project in solution.Projects)
514 { 514 {
515 foreach(ConfigurationNode conf in solution.Configurations) 515 foreach(ConfigurationNode conf in solution.Configurations)
516 { 516 {
517 ss.WriteLine("\t\t{{{0}}}.{1}.ActiveCfg = {1}|.NET", 517 ss.WriteLine("\t\t{{{0}}}.{1}.ActiveCfg = {1}|.NET",
518 project.Guid.ToString().ToUpper(), 518 project.Guid.ToString().ToUpper(),
519 conf.Name); 519 conf.Name);
520 520
521 ss.WriteLine("\t\t{{{0}}}.{1}.Build.0 = {1}|.NET", 521 ss.WriteLine("\t\t{{{0}}}.{1}.Build.0 = {1}|.NET",
522 project.Guid.ToString().ToUpper(), 522 project.Guid.ToString().ToUpper(),
523 conf.Name); 523 conf.Name);
524 } 524 }
525 } 525 }
526 ss.WriteLine("\tEndGlobalSection"); 526 ss.WriteLine("\tEndGlobalSection");
527 527
528 if(solution.Files != null) 528 if(solution.Files != null)
529 { 529 {
530 ss.WriteLine("\tGlobalSection(SolutionItems) = postSolution"); 530 ss.WriteLine("\tGlobalSection(SolutionItems) = postSolution");
531 foreach(string file in solution.Files) 531 foreach(string file in solution.Files)
532 { 532 {
533 ss.WriteLine("\t\t{0} = {0}", file); 533 ss.WriteLine("\t\t{0} = {0}", file);
534 } 534 }
535 ss.WriteLine("\tEndGlobalSection"); 535 ss.WriteLine("\tEndGlobalSection");
536 } 536 }
537 537
538 ss.WriteLine("\tGlobalSection(ExtensibilityGlobals) = postSolution"); 538 ss.WriteLine("\tGlobalSection(ExtensibilityGlobals) = postSolution");
539 ss.WriteLine("\tEndGlobalSection"); 539 ss.WriteLine("\tEndGlobalSection");
540 ss.WriteLine("\tGlobalSection(ExtensibilityAddIns) = postSolution"); 540 ss.WriteLine("\tGlobalSection(ExtensibilityAddIns) = postSolution");
541 ss.WriteLine("\tEndGlobalSection"); 541 ss.WriteLine("\tEndGlobalSection");
542 542
543 ss.WriteLine("EndGlobal"); 543 ss.WriteLine("EndGlobal");
544 } 544 }
545 545
546 m_Kernel.CurrentWorkingDirectory.Pop(); 546 m_Kernel.CurrentWorkingDirectory.Pop();
547 } 547 }
548 548
549 private void CleanProject(ProjectNode project) 549 private void CleanProject(ProjectNode project)
550 { 550 {
551 m_Kernel.Log.Write("...Cleaning project: {0}", project.Name); 551 m_Kernel.Log.Write("...Cleaning project: {0}", project.Name);
552 552
553 ToolInfo toolInfo = (ToolInfo)m_Tools[project.Language]; 553 ToolInfo toolInfo = (ToolInfo)m_Tools[project.Language];
554 string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); 554 string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension);
555 string userFile = projectFile + ".user"; 555 string userFile = projectFile + ".user";
556 556
557 Helper.DeleteIfExists(projectFile); 557 Helper.DeleteIfExists(projectFile);
558 Helper.DeleteIfExists(userFile); 558 Helper.DeleteIfExists(userFile);
559 } 559 }
560 560
561 private void CleanSolution(SolutionNode solution) 561 private void CleanSolution(SolutionNode solution)
562 { 562 {
563 m_Kernel.Log.Write("Cleaning Visual Studio {0} solution and project files", this.VersionName, solution.Name); 563 m_Kernel.Log.Write("Cleaning Visual Studio {0} solution and project files", this.VersionName, solution.Name);
564 564
565 string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln"); 565 string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln");
566 string suoFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "suo"); 566 string suoFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "suo");
567 567
568 Helper.DeleteIfExists(slnFile); 568 Helper.DeleteIfExists(slnFile);
569 Helper.DeleteIfExists(suoFile); 569 Helper.DeleteIfExists(suoFile);
570 570
571 foreach(ProjectNode project in solution.Projects) 571 foreach(ProjectNode project in solution.Projects)
572 { 572 {
573 CleanProject(project); 573 CleanProject(project);
574 } 574 }
575 575
576 m_Kernel.Log.Write(""); 576 m_Kernel.Log.Write("");
577 } 577 }
578 578
579 #endregion 579 #endregion
580 580
581 #region ITarget Members 581 #region ITarget Members
582 582
583 /// <summary> 583 /// <summary>
584 /// Writes the specified kern. 584 /// Writes the specified kern.
585 /// </summary> 585 /// </summary>
586 /// <param name="kern">The kern.</param> 586 /// <param name="kern">The kern.</param>
587 public virtual void Write(Kernel kern) 587 public virtual void Write(Kernel kern)
588 { 588 {
589 if( kern == null ) 589 if( kern == null )
590 { 590 {
591 throw new ArgumentNullException("kern"); 591 throw new ArgumentNullException("kern");
592 } 592 }
593 m_Kernel = kern; 593 m_Kernel = kern;
594 foreach(SolutionNode sol in m_Kernel.Solutions) 594 foreach(SolutionNode sol in m_Kernel.Solutions)
595 { 595 {
596 WriteSolution(sol); 596 WriteSolution(sol);
597 } 597 }
598 m_Kernel = null; 598 m_Kernel = null;
599 } 599 }
600 600
601 /// <summary> 601 /// <summary>
602 /// Cleans the specified kern. 602 /// Cleans the specified kern.
603 /// </summary> 603 /// </summary>
604 /// <param name="kern">The kern.</param> 604 /// <param name="kern">The kern.</param>
605 public virtual void Clean(Kernel kern) 605 public virtual void Clean(Kernel kern)
606 { 606 {
607 if( kern == null ) 607 if( kern == null )
608 { 608 {
609 throw new ArgumentNullException("kern"); 609 throw new ArgumentNullException("kern");
610 } 610 }
611 m_Kernel = kern; 611 m_Kernel = kern;
612 foreach(SolutionNode sol in m_Kernel.Solutions) 612 foreach(SolutionNode sol in m_Kernel.Solutions)
613 { 613 {
614 CleanSolution(sol); 614 CleanSolution(sol);
615 } 615 }
616 m_Kernel = null; 616 m_Kernel = null;
617 } 617 }
618 618
619 /// <summary> 619 /// <summary>
620 /// Gets the name. 620 /// Gets the name.
621 /// </summary> 621 /// </summary>
622 /// <value>The name.</value> 622 /// <value>The name.</value>
623 public virtual string Name 623 public virtual string Name
624 { 624 {
625 get 625 get
626 { 626 {
627 return "vs2003"; 627 return "vs2003";
628 } 628 }
629 } 629 }
630 630
631 #endregion 631 #endregion
632 } 632 }
633} 633}