diff options
Diffstat (limited to 'Prebuild/src/Core/Targets/VS2005Target.cs')
-rw-r--r-- | Prebuild/src/Core/Targets/VS2005Target.cs | 883 |
1 files changed, 883 insertions, 0 deletions
diff --git a/Prebuild/src/Core/Targets/VS2005Target.cs b/Prebuild/src/Core/Targets/VS2005Target.cs new file mode 100644 index 0000000..23b6116 --- /dev/null +++ b/Prebuild/src/Core/Targets/VS2005Target.cs | |||
@@ -0,0 +1,883 @@ | |||
1 | #region BSD License | ||
2 | /* | ||
3 | Copyright (c) 2004 Matthew Holmes (matthew@wildfiregames.com) | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted | ||
6 | provided that the following conditions are met: | ||
7 | |||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions | ||
9 | and the following disclaimer. | ||
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions | ||
11 | and the following disclaimer in the documentation and/or other materials provided with the | ||
12 | distribution. | ||
13 | * The name of the author may not be used to endorse or promote products derived from this software | ||
14 | without specific prior written permission. | ||
15 | |||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | #endregion | ||
25 | |||
26 | #region CVS Information | ||
27 | /* | ||
28 | * $Source$ | ||
29 | * $Author: robloach $ | ||
30 | * $Date: 2007-02-27 19:52:34 +0100 (ti, 27 feb 2007) $ | ||
31 | * $Revision: 207 $ | ||
32 | */ | ||
33 | #endregion | ||
34 | |||
35 | using System; | ||
36 | using System.Collections; | ||
37 | using System.Collections.Specialized; | ||
38 | using System.IO; | ||
39 | |||
40 | using Prebuild.Core.Attributes; | ||
41 | using Prebuild.Core.Interfaces; | ||
42 | using Prebuild.Core.Nodes; | ||
43 | using Prebuild.Core.Utilities; | ||
44 | |||
45 | namespace Prebuild.Core.Targets | ||
46 | { | ||
47 | /// <summary> | ||
48 | /// | ||
49 | /// </summary> | ||
50 | public struct ToolInfo | ||
51 | { | ||
52 | string name; | ||
53 | string guid; | ||
54 | string fileExtension; | ||
55 | string xmlTag; | ||
56 | string importProject; | ||
57 | |||
58 | /// <summary> | ||
59 | /// Gets or sets the name. | ||
60 | /// </summary> | ||
61 | /// <value>The name.</value> | ||
62 | public string Name | ||
63 | { | ||
64 | get | ||
65 | { | ||
66 | return name; | ||
67 | } | ||
68 | set | ||
69 | { | ||
70 | name = value; | ||
71 | } | ||
72 | } | ||
73 | |||
74 | /// <summary> | ||
75 | /// Gets or sets the GUID. | ||
76 | /// </summary> | ||
77 | /// <value>The GUID.</value> | ||
78 | public string Guid | ||
79 | { | ||
80 | get | ||
81 | { | ||
82 | return guid; | ||
83 | } | ||
84 | set | ||
85 | { | ||
86 | guid = value; | ||
87 | } | ||
88 | } | ||
89 | |||
90 | /// <summary> | ||
91 | /// Gets or sets the file extension. | ||
92 | /// </summary> | ||
93 | /// <value>The file extension.</value> | ||
94 | public string FileExtension | ||
95 | { | ||
96 | get | ||
97 | { | ||
98 | return fileExtension; | ||
99 | } | ||
100 | set | ||
101 | { | ||
102 | fileExtension = value; | ||
103 | } | ||
104 | } | ||
105 | /// <summary> | ||
106 | /// Gets or sets the XML tag. | ||
107 | /// </summary> | ||
108 | /// <value>The XML tag.</value> | ||
109 | public string XmlTag | ||
110 | { | ||
111 | get | ||
112 | { | ||
113 | return xmlTag; | ||
114 | } | ||
115 | set | ||
116 | { | ||
117 | xmlTag = value; | ||
118 | } | ||
119 | } | ||
120 | |||
121 | /// <summary> | ||
122 | /// Gets or sets the import project property. | ||
123 | /// </summary> | ||
124 | /// <value>The ImportProject tag.</value> | ||
125 | public string ImportProject | ||
126 | { | ||
127 | get | ||
128 | { | ||
129 | return importProject; | ||
130 | } | ||
131 | set | ||
132 | { | ||
133 | importProject = value; | ||
134 | } | ||
135 | } | ||
136 | |||
137 | /// <summary> | ||
138 | /// Initializes a new instance of the <see cref="ToolInfo"/> class. | ||
139 | /// </summary> | ||
140 | /// <param name="name">The name.</param> | ||
141 | /// <param name="guid">The GUID.</param> | ||
142 | /// <param name="fileExtension">The file extension.</param> | ||
143 | /// <param name="xml">The XML.</param> | ||
144 | /// <param name="importProject">The import project.</param> | ||
145 | public ToolInfo(string name, string guid, string fileExtension, string xml, string importProject) | ||
146 | { | ||
147 | this.name = name; | ||
148 | this.guid = guid; | ||
149 | this.fileExtension = fileExtension; | ||
150 | this.xmlTag = xml; | ||
151 | this.importProject = importProject; | ||
152 | } | ||
153 | |||
154 | /// <summary> | ||
155 | /// Initializes a new instance of the <see cref="ToolInfo"/> class. | ||
156 | /// </summary> | ||
157 | /// <param name="name">The name.</param> | ||
158 | /// <param name="guid">The GUID.</param> | ||
159 | /// <param name="fileExtension">The file extension.</param> | ||
160 | /// <param name="xml">The XML.</param> | ||
161 | public ToolInfo(string name, string guid, string fileExtension, string xml) | ||
162 | { | ||
163 | this.name = name; | ||
164 | this.guid = guid; | ||
165 | this.fileExtension = fileExtension; | ||
166 | this.xmlTag = xml; | ||
167 | this.importProject = "$(MSBuildBinPath)\\Microsoft." + xml + ".Targets"; | ||
168 | } | ||
169 | |||
170 | /// <summary> | ||
171 | /// Equals operator | ||
172 | /// </summary> | ||
173 | /// <param name="obj">ToolInfo to compare</param> | ||
174 | /// <returns>true if toolInfos are equal</returns> | ||
175 | public override bool Equals(object obj) | ||
176 | { | ||
177 | if (obj == null) | ||
178 | { | ||
179 | throw new ArgumentNullException("obj"); | ||
180 | } | ||
181 | if (obj.GetType() != typeof(ToolInfo)) | ||
182 | return false; | ||
183 | |||
184 | ToolInfo c = (ToolInfo)obj; | ||
185 | return ((this.name == c.name) && (this.guid == c.guid) && (this.fileExtension == c.fileExtension) && (this.importProject == c.importProject)); | ||
186 | } | ||
187 | |||
188 | /// <summary> | ||
189 | /// Equals operator | ||
190 | /// </summary> | ||
191 | /// <param name="c1">ToolInfo to compare</param> | ||
192 | /// <param name="c2">ToolInfo to compare</param> | ||
193 | /// <returns>True if toolInfos are equal</returns> | ||
194 | public static bool operator ==(ToolInfo c1, ToolInfo c2) | ||
195 | { | ||
196 | return ((c1.name == c2.name) && (c1.guid == c2.guid) && (c1.fileExtension == c2.fileExtension) && (c1.importProject == c2.importProject) && (c1.xmlTag == c2.xmlTag)); | ||
197 | } | ||
198 | |||
199 | /// <summary> | ||
200 | /// Not equals operator | ||
201 | /// </summary> | ||
202 | /// <param name="c1">ToolInfo to compare</param> | ||
203 | /// <param name="c2">ToolInfo to compare</param> | ||
204 | /// <returns>True if toolInfos are not equal</returns> | ||
205 | public static bool operator !=(ToolInfo c1, ToolInfo c2) | ||
206 | { | ||
207 | return !(c1 == c2); | ||
208 | } | ||
209 | |||
210 | /// <summary> | ||
211 | /// Hash Code | ||
212 | /// </summary> | ||
213 | /// <returns>Hash code</returns> | ||
214 | public override int GetHashCode() | ||
215 | { | ||
216 | return name.GetHashCode() ^ guid.GetHashCode() ^ this.fileExtension.GetHashCode() ^ this.importProject.GetHashCode() ^ this.xmlTag.GetHashCode(); | ||
217 | |||
218 | } | ||
219 | } | ||
220 | |||
221 | /// <summary> | ||
222 | /// | ||
223 | /// </summary> | ||
224 | [Target("vs2005")] | ||
225 | public class VS2005Target : ITarget | ||
226 | { | ||
227 | #region Inner Classes | ||
228 | |||
229 | #endregion | ||
230 | |||
231 | #region Fields | ||
232 | |||
233 | string solutionVersion = "9.00"; | ||
234 | string productVersion = "8.0.50727"; | ||
235 | string schemaVersion = "2.0"; | ||
236 | string versionName = "Visual C# 2005"; | ||
237 | VSVersion version = VSVersion.VS80; | ||
238 | |||
239 | Hashtable tools; | ||
240 | Kernel kernel; | ||
241 | |||
242 | /// <summary> | ||
243 | /// Gets or sets the solution version. | ||
244 | /// </summary> | ||
245 | /// <value>The solution version.</value> | ||
246 | protected string SolutionVersion | ||
247 | { | ||
248 | get | ||
249 | { | ||
250 | return this.solutionVersion; | ||
251 | } | ||
252 | set | ||
253 | { | ||
254 | this.solutionVersion = value; | ||
255 | } | ||
256 | } | ||
257 | /// <summary> | ||
258 | /// Gets or sets the product version. | ||
259 | /// </summary> | ||
260 | /// <value>The product version.</value> | ||
261 | protected string ProductVersion | ||
262 | { | ||
263 | get | ||
264 | { | ||
265 | return this.productVersion; | ||
266 | } | ||
267 | set | ||
268 | { | ||
269 | this.productVersion = value; | ||
270 | } | ||
271 | } | ||
272 | /// <summary> | ||
273 | /// Gets or sets the schema version. | ||
274 | /// </summary> | ||
275 | /// <value>The schema version.</value> | ||
276 | protected string SchemaVersion | ||
277 | { | ||
278 | get | ||
279 | { | ||
280 | return this.schemaVersion; | ||
281 | } | ||
282 | set | ||
283 | { | ||
284 | this.schemaVersion = value; | ||
285 | } | ||
286 | } | ||
287 | /// <summary> | ||
288 | /// Gets or sets the name of the version. | ||
289 | /// </summary> | ||
290 | /// <value>The name of the version.</value> | ||
291 | protected string VersionName | ||
292 | { | ||
293 | get | ||
294 | { | ||
295 | return this.versionName; | ||
296 | } | ||
297 | set | ||
298 | { | ||
299 | this.versionName = value; | ||
300 | } | ||
301 | } | ||
302 | /// <summary> | ||
303 | /// Gets or sets the version. | ||
304 | /// </summary> | ||
305 | /// <value>The version.</value> | ||
306 | protected VSVersion Version | ||
307 | { | ||
308 | get | ||
309 | { | ||
310 | return this.version; | ||
311 | } | ||
312 | set | ||
313 | { | ||
314 | this.version = value; | ||
315 | } | ||
316 | } | ||
317 | |||
318 | #endregion | ||
319 | |||
320 | #region Constructors | ||
321 | |||
322 | /// <summary> | ||
323 | /// Initializes a new instance of the <see cref="VS2005Target"/> class. | ||
324 | /// </summary> | ||
325 | public VS2005Target() | ||
326 | { | ||
327 | this.tools = new Hashtable(); | ||
328 | |||
329 | this.tools["C#"] = new ToolInfo("C#", "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}", "csproj", "CSHARP", "$(MSBuildBinPath)\\Microsoft.CSHARP.Targets"); | ||
330 | this.tools["Boo"] = new ToolInfo("Boo", "{45CEA7DC-C2ED-48A6-ACE0-E16144C02365}", "booproj", "Boo", "$(BooBinPath)\\Boo.Microsoft.Build.targets"); | ||
331 | this.tools["VisualBasic"] = new ToolInfo("VisualBasic", "{F184B08F-C81C-45F6-A57F-5ABD9991F28F}", "vbproj", "VisualBasic", "$(MSBuildBinPath)\\Microsoft.VisualBasic.Targets"); | ||
332 | } | ||
333 | |||
334 | #endregion | ||
335 | |||
336 | #region Private Methods | ||
337 | |||
338 | private string MakeRefPath(ProjectNode project) | ||
339 | { | ||
340 | string ret = ""; | ||
341 | foreach (ReferencePathNode node in project.ReferencePaths) | ||
342 | { | ||
343 | try | ||
344 | { | ||
345 | string fullPath = Helper.ResolvePath(node.Path); | ||
346 | if (ret.Length < 1) | ||
347 | { | ||
348 | ret = fullPath; | ||
349 | } | ||
350 | else | ||
351 | { | ||
352 | ret += ";" + fullPath; | ||
353 | } | ||
354 | } | ||
355 | catch (ArgumentException) | ||
356 | { | ||
357 | this.kernel.Log.Write(LogType.Warning, "Could not resolve reference path: {0}", node.Path); | ||
358 | } | ||
359 | } | ||
360 | |||
361 | return ret; | ||
362 | } | ||
363 | |||
364 | private void WriteProject(SolutionNode solution, ProjectNode project) | ||
365 | { | ||
366 | if (!tools.ContainsKey(project.Language)) | ||
367 | { | ||
368 | throw new UnknownLanguageException("Unknown .NET language: " + project.Language); | ||
369 | } | ||
370 | |||
371 | ToolInfo toolInfo = (ToolInfo)tools[project.Language]; | ||
372 | string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); | ||
373 | StreamWriter ps = new StreamWriter(projectFile); | ||
374 | |||
375 | kernel.CurrentWorkingDirectory.Push(); | ||
376 | Helper.SetCurrentDir(Path.GetDirectoryName(projectFile)); | ||
377 | |||
378 | #region Project File | ||
379 | using (ps) | ||
380 | { | ||
381 | ps.WriteLine("<Project DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">"); | ||
382 | //ps.WriteLine(" <{0}", toolInfo.XMLTag); | ||
383 | ps.WriteLine(" <PropertyGroup>"); | ||
384 | ps.WriteLine(" <ProjectType>Local</ProjectType>"); | ||
385 | ps.WriteLine(" <ProductVersion>{0}</ProductVersion>", this.ProductVersion); | ||
386 | ps.WriteLine(" <SchemaVersion>{0}</SchemaVersion>", this.SchemaVersion); | ||
387 | ps.WriteLine(" <ProjectGuid>{{{0}}}</ProjectGuid>", project.Guid.ToString().ToUpper()); | ||
388 | |||
389 | ps.WriteLine(" <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>"); | ||
390 | ps.WriteLine(" <Platform Condition=\" '$(Platform)' == '' \">AnyCPU</Platform>"); | ||
391 | //ps.WriteLine(" <Build>"); | ||
392 | |||
393 | //ps.WriteLine(" <Settings"); | ||
394 | ps.WriteLine(" <ApplicationIcon>{0}</ApplicationIcon>", project.AppIcon); | ||
395 | ps.WriteLine(" <AssemblyKeyContainerName>"); | ||
396 | ps.WriteLine(" </AssemblyKeyContainerName>"); | ||
397 | ps.WriteLine(" <AssemblyName>{0}</AssemblyName>", project.AssemblyName); | ||
398 | foreach (ConfigurationNode conf in project.Configurations) | ||
399 | { | ||
400 | if (conf.Options.KeyFile != "") | ||
401 | { | ||
402 | ps.WriteLine(" <AssemblyOriginatorKeyFile>{0}</AssemblyOriginatorKeyFile>", conf.Options.KeyFile); | ||
403 | ps.WriteLine(" <SignAssembly>true</SignAssembly>"); | ||
404 | break; | ||
405 | } | ||
406 | } | ||
407 | ps.WriteLine(" <DefaultClientScript>JScript</DefaultClientScript>"); | ||
408 | ps.WriteLine(" <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>"); | ||
409 | ps.WriteLine(" <DefaultTargetSchema>IE50</DefaultTargetSchema>"); | ||
410 | ps.WriteLine(" <DelaySign>false</DelaySign>"); | ||
411 | |||
412 | //if(m_Version == VSVersion.VS70) | ||
413 | // ps.WriteLine(" NoStandardLibraries = \"false\""); | ||
414 | |||
415 | ps.WriteLine(" <OutputType>{0}</OutputType>", project.Type.ToString()); | ||
416 | ps.WriteLine(" <AppDesignerFolder>{0}</AppDesignerFolder>", project.DesignerFolder); | ||
417 | ps.WriteLine(" <RootNamespace>{0}</RootNamespace>", project.RootNamespace); | ||
418 | ps.WriteLine(" <StartupObject>{0}</StartupObject>", project.StartupObject); | ||
419 | //ps.WriteLine(" >"); | ||
420 | ps.WriteLine(" <FileUpgradeFlags>"); | ||
421 | ps.WriteLine(" </FileUpgradeFlags>"); | ||
422 | |||
423 | ps.WriteLine(" </PropertyGroup>"); | ||
424 | |||
425 | foreach (ConfigurationNode conf in project.Configurations) | ||
426 | { | ||
427 | ps.Write(" <PropertyGroup "); | ||
428 | ps.WriteLine("Condition=\" '$(Configuration)|$(Platform)' == '{0}|AnyCPU' \">", conf.Name); | ||
429 | ps.WriteLine(" <AllowUnsafeBlocks>{0}</AllowUnsafeBlocks>", conf.Options["AllowUnsafe"]); | ||
430 | ps.WriteLine(" <BaseAddress>{0}</BaseAddress>", conf.Options["BaseAddress"]); | ||
431 | ps.WriteLine(" <CheckForOverflowUnderflow>{0}</CheckForOverflowUnderflow>", conf.Options["CheckUnderflowOverflow"]); | ||
432 | ps.WriteLine(" <ConfigurationOverrideFile>"); | ||
433 | ps.WriteLine(" </ConfigurationOverrideFile>"); | ||
434 | ps.WriteLine(" <DefineConstants>{0}</DefineConstants>", conf.Options["CompilerDefines"]); | ||
435 | ps.WriteLine(" <DocumentationFile>{0}</DocumentationFile>", conf.Options["XmlDocFile"]); | ||
436 | ps.WriteLine(" <DebugSymbols>{0}</DebugSymbols>", conf.Options["DebugInformation"]); | ||
437 | ps.WriteLine(" <FileAlignment>{0}</FileAlignment>", conf.Options["FileAlignment"]); | ||
438 | // ps.WriteLine(" <IncrementalBuild = \"{0}\"", conf.Options["IncrementalBuild"]); | ||
439 | |||
440 | // if(m_Version == VSVersion.VS71) | ||
441 | // { | ||
442 | // ps.WriteLine(" NoStdLib = \"{0}\"", conf.Options["NoStdLib"]); | ||
443 | // ps.WriteLine(" NoWarn = \"{0}\"", conf.Options["SuppressWarnings"]); | ||
444 | // } | ||
445 | |||
446 | ps.WriteLine(" <Optimize>{0}</Optimize>", conf.Options["OptimizeCode"]); | ||
447 | ps.WriteLine(" <OutputPath>{0}</OutputPath>", | ||
448 | Helper.EndPath(Helper.NormalizePath(conf.Options["OutputPath"].ToString()))); | ||
449 | ps.WriteLine(" <RegisterForComInterop>{0}</RegisterForComInterop>", conf.Options["RegisterComInterop"]); | ||
450 | ps.WriteLine(" <RemoveIntegerChecks>{0}</RemoveIntegerChecks>", conf.Options["RemoveIntegerChecks"]); | ||
451 | ps.WriteLine(" <TreatWarningsAsErrors>{0}</TreatWarningsAsErrors>", conf.Options["WarningsAsErrors"]); | ||
452 | ps.WriteLine(" <WarningLevel>{0}</WarningLevel>", conf.Options["WarningLevel"]); | ||
453 | ps.WriteLine(" <NoWarn>{0}</NoWarn>", conf.Options["SuppressWarnings"]); | ||
454 | ps.WriteLine(" </PropertyGroup>"); | ||
455 | } | ||
456 | |||
457 | //ps.WriteLine(" </Settings>"); | ||
458 | |||
459 | // Assembly References | ||
460 | ps.WriteLine(" <ItemGroup>"); | ||
461 | string refPath = ((ReferencePathNode) project.ReferencePaths[0]).Path; | ||
462 | |||
463 | foreach (ReferenceNode refr in project.References) | ||
464 | { | ||
465 | if (!solution.ProjectsTable.ContainsKey(refr.Name)) | ||
466 | { | ||
467 | ps.Write(" <Reference"); | ||
468 | ps.Write(" Include=\""); | ||
469 | ps.Write(refr.Name); | ||
470 | |||
471 | ps.WriteLine("\" >"); | ||
472 | |||
473 | string path; | ||
474 | |||
475 | if( refr.Name.EndsWith(".dll", StringComparison.InvariantCultureIgnoreCase )) | ||
476 | { | ||
477 | path = Helper.NormalizePath(Path.Combine( refPath, refr.Name), '\\'); | ||
478 | } | ||
479 | else | ||
480 | { | ||
481 | path = refr.Name + ".dll"; | ||
482 | } | ||
483 | |||
484 | // TODO: Allow reference to *.exe files | ||
485 | ps.WriteLine(" <HintPath>{0}</HintPath>", path ); | ||
486 | ps.WriteLine(" <Private>{0}</Private>", refr.LocalCopy); | ||
487 | ps.WriteLine(" </Reference>"); | ||
488 | } | ||
489 | } | ||
490 | ps.WriteLine(" </ItemGroup>"); | ||
491 | |||
492 | //Project References | ||
493 | ps.WriteLine(" <ItemGroup>"); | ||
494 | foreach (ReferenceNode refr in project.References) | ||
495 | { | ||
496 | if (solution.ProjectsTable.ContainsKey(refr.Name)) | ||
497 | { | ||
498 | ProjectNode refProject = (ProjectNode)solution.ProjectsTable[refr.Name]; | ||
499 | // TODO: Allow reference to visual basic projects | ||
500 | string path = | ||
501 | Helper.MakePathRelativeTo(project.FullPath, | ||
502 | Helper.MakeFilePath(refProject.FullPath, refProject.Name, "csproj")); | ||
503 | ps.WriteLine(" <ProjectReference Include=\"{0}\">", path ); | ||
504 | //<ProjectReference Include="..\..\RealmForge\Utility\RealmForge.Utility.csproj"> | ||
505 | ps.WriteLine(" <Name>{0}</Name>", refProject.Name); | ||
506 | // <Name>RealmForge.Utility</Name> | ||
507 | ps.WriteLine(" <Project>{{{0}}}</Project>", refProject.Guid.ToString().ToUpper()); | ||
508 | // <Project>{6880D1D3-69EE-461B-B841-5319845B20D3}</Project> | ||
509 | ps.WriteLine(" <Package>{0}</Package>", toolInfo.Guid.ToString().ToUpper()); | ||
510 | // <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> | ||
511 | ps.WriteLine("\t\t\t<Private>{0}</Private>", refr.LocalCopy); | ||
512 | ps.WriteLine(" </ProjectReference>"); | ||
513 | //</ProjectReference> | ||
514 | } | ||
515 | else | ||
516 | { | ||
517 | } | ||
518 | } | ||
519 | ps.WriteLine(" </ItemGroup>"); | ||
520 | |||
521 | // ps.WriteLine(" </Build>"); | ||
522 | ps.WriteLine(" <ItemGroup>"); | ||
523 | |||
524 | // ps.WriteLine(" <Include>"); | ||
525 | ArrayList list = new ArrayList(); | ||
526 | foreach (string file in project.Files) | ||
527 | { | ||
528 | // if (file == "Properties\\Bind.Designer.cs") | ||
529 | // { | ||
530 | // Console.WriteLine("Wait a minute!"); | ||
531 | // Console.WriteLine(project.Files.GetSubType(file).ToString()); | ||
532 | // } | ||
533 | |||
534 | if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings && project.Files.GetSubType(file) != SubType.Designer) | ||
535 | { | ||
536 | ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".resx"); | ||
537 | |||
538 | int slash = file.LastIndexOf('\\'); | ||
539 | if (slash == -1) | ||
540 | { | ||
541 | ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", file); | ||
542 | } | ||
543 | else | ||
544 | { | ||
545 | ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", file.Substring(slash + 1, file.Length - slash - 1)); | ||
546 | } | ||
547 | ps.WriteLine(" <SubType>Designer</SubType>"); | ||
548 | ps.WriteLine(" </EmbeddedResource>"); | ||
549 | // | ||
550 | } | ||
551 | |||
552 | if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) == SubType.Designer) | ||
553 | { | ||
554 | ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".resx"); | ||
555 | ps.WriteLine(" <SubType>" + project.Files.GetSubType(file) + "</SubType>"); | ||
556 | ps.WriteLine(" <Generator>ResXFileCodeGenerator</Generator>"); | ||
557 | ps.WriteLine(" <LastGenOutput>Resources.Designer.cs</LastGenOutput>"); | ||
558 | ps.WriteLine(" </EmbeddedResource>"); | ||
559 | ps.WriteLine(" <Compile Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".Designer.cs"); | ||
560 | ps.WriteLine(" <AutoGen>True</AutoGen>"); | ||
561 | ps.WriteLine(" <DesignTime>True</DesignTime>"); | ||
562 | ps.WriteLine(" <DependentUpon>Resources.resx</DependentUpon>"); | ||
563 | ps.WriteLine(" </Compile>"); | ||
564 | list.Add(file.Substring(0, file.LastIndexOf('.')) + ".Designer.cs"); | ||
565 | } | ||
566 | if (project.Files.GetSubType(file).ToString() == "Settings") | ||
567 | { | ||
568 | //Console.WriteLine("File: " + file); | ||
569 | //Console.WriteLine("Last index: " + file.LastIndexOf('.')); | ||
570 | //Console.WriteLine("Length: " + file.Length); | ||
571 | ps.Write(" <{0} ", project.Files.GetBuildAction(file)); | ||
572 | ps.WriteLine("Include=\"{0}\">", file); | ||
573 | int slash = file.LastIndexOf('\\'); | ||
574 | string fileName = file.Substring(slash + 1, file.Length - slash - 1); | ||
575 | if (project.Files.GetBuildAction(file) == BuildAction.None) | ||
576 | { | ||
577 | ps.WriteLine(" <Generator>SettingsSingleFileGenerator</Generator>"); | ||
578 | |||
579 | //Console.WriteLine("FileName: " + fileName); | ||
580 | //Console.WriteLine("FileNameMain: " + fileName.Substring(0, fileName.LastIndexOf('.'))); | ||
581 | //Console.WriteLine("FileNameExt: " + fileName.Substring(fileName.LastIndexOf('.'), fileName.Length - fileName.LastIndexOf('.'))); | ||
582 | if (slash == -1) | ||
583 | { | ||
584 | ps.WriteLine(" <LastGenOutput>{0}</LastGenOutput>", fileName.Substring(0, fileName.LastIndexOf('.')) + ".Designer.cs"); | ||
585 | } | ||
586 | else | ||
587 | { | ||
588 | ps.WriteLine(" <LastGenOutput>{0}</LastGenOutput>", fileName.Substring(0, fileName.LastIndexOf('.')) + ".Designer.cs"); | ||
589 | } | ||
590 | } | ||
591 | else | ||
592 | { | ||
593 | ps.WriteLine(" <SubType>Code</SubType>"); | ||
594 | ps.WriteLine(" <AutoGen>True</AutoGen>"); | ||
595 | ps.WriteLine(" <DesignTimeSharedInput>True</DesignTimeSharedInput>"); | ||
596 | string fileNameShort = fileName.Substring(0, fileName.LastIndexOf('.')); | ||
597 | string fileNameShorter = fileNameShort.Substring(0, fileNameShort.LastIndexOf('.')); | ||
598 | ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", fileNameShorter + ".settings"); | ||
599 | } | ||
600 | ps.WriteLine(" </{0}>", project.Files.GetBuildAction(file)); | ||
601 | } | ||
602 | else if (project.Files.GetSubType(file) != SubType.Designer) | ||
603 | { | ||
604 | if (!list.Contains(file)) | ||
605 | { | ||
606 | ps.Write(" <{0} ", project.Files.GetBuildAction(file)); | ||
607 | ps.WriteLine("Include=\"{0}\">", file); | ||
608 | |||
609 | |||
610 | if (file.Contains("Designer.cs")) | ||
611 | { | ||
612 | ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", file.Substring(0, file.IndexOf(".Designer.cs")) + ".cs"); | ||
613 | } | ||
614 | |||
615 | if (project.Files.GetIsLink(file)) | ||
616 | { | ||
617 | ps.WriteLine(" <Link>{0}</Link>", Path.GetFileName(file)); | ||
618 | } | ||
619 | else if (project.Files.GetBuildAction(file) != BuildAction.None) | ||
620 | { | ||
621 | if (project.Files.GetBuildAction(file) != BuildAction.EmbeddedResource) | ||
622 | { | ||
623 | ps.WriteLine(" <SubType>{0}</SubType>", project.Files.GetSubType(file)); | ||
624 | } | ||
625 | } | ||
626 | if (project.Files.GetCopyToOutput(file) != CopyToOutput.Never) | ||
627 | { | ||
628 | ps.WriteLine(" <CopyToOutputDirectory>{0}</CopyToOutputDirectory>", project.Files.GetCopyToOutput(file)); | ||
629 | } | ||
630 | |||
631 | ps.WriteLine(" </{0}>", project.Files.GetBuildAction(file)); | ||
632 | } | ||
633 | } | ||
634 | } | ||
635 | // ps.WriteLine(" </Include>"); | ||
636 | |||
637 | ps.WriteLine(" </ItemGroup>"); | ||
638 | ps.WriteLine(" <Import Project=\"" + toolInfo.ImportProject + "\" />"); | ||
639 | ps.WriteLine(" <PropertyGroup>"); | ||
640 | ps.WriteLine(" <PreBuildEvent>"); | ||
641 | ps.WriteLine(" </PreBuildEvent>"); | ||
642 | ps.WriteLine(" <PostBuildEvent>"); | ||
643 | ps.WriteLine(" </PostBuildEvent>"); | ||
644 | ps.WriteLine(" </PropertyGroup>"); | ||
645 | // ps.WriteLine(" </{0}>", toolInfo.XMLTag); | ||
646 | ps.WriteLine("</Project>"); | ||
647 | } | ||
648 | #endregion | ||
649 | |||
650 | #region User File | ||
651 | |||
652 | ps = new StreamWriter(projectFile + ".user"); | ||
653 | using (ps) | ||
654 | { | ||
655 | ps.WriteLine("<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">"); | ||
656 | //ps.WriteLine( "<VisualStudioProject>" ); | ||
657 | //ps.WriteLine(" <{0}>", toolInfo.XMLTag); | ||
658 | //ps.WriteLine(" <Build>"); | ||
659 | ps.WriteLine(" <PropertyGroup>"); | ||
660 | //ps.WriteLine(" <Settings ReferencePath=\"{0}\">", MakeRefPath(project)); | ||
661 | |||
662 | |||
663 | ps.WriteLine(" <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>"); | ||
664 | ps.WriteLine(" <Platform Condition=\" '$(Platform)' == '' \">AnyCPU</Platform>"); | ||
665 | |||
666 | if (projectFile.Contains( "OpenSim.csproj" )) | ||
667 | { | ||
668 | ps.WriteLine(" <StartArguments>-loginserver -sandbox -accounts</StartArguments>"); | ||
669 | } | ||
670 | |||
671 | ps.WriteLine(" <ReferencePath>{0}</ReferencePath>", MakeRefPath(project)); | ||
672 | ps.WriteLine(" <LastOpenVersion>{0}</LastOpenVersion>", this.ProductVersion); | ||
673 | ps.WriteLine(" <ProjectView>ProjectFiles</ProjectView>"); | ||
674 | ps.WriteLine(" <ProjectTrust>0</ProjectTrust>"); | ||
675 | ps.WriteLine(" </PropertyGroup>"); | ||
676 | foreach (ConfigurationNode conf in project.Configurations) | ||
677 | { | ||
678 | ps.Write(" <PropertyGroup"); | ||
679 | ps.Write(" Condition = \" '$(Configuration)|$(Platform)' == '{0}|AnyCPU' \"", conf.Name); | ||
680 | ps.WriteLine(" />"); | ||
681 | } | ||
682 | |||
683 | ps.WriteLine("</Project>"); | ||
684 | } | ||
685 | #endregion | ||
686 | |||
687 | kernel.CurrentWorkingDirectory.Pop(); | ||
688 | } | ||
689 | |||
690 | private void WriteSolution(SolutionNode solution) | ||
691 | { | ||
692 | kernel.Log.Write("Creating {0} solution and project files", this.VersionName); | ||
693 | |||
694 | foreach (ProjectNode project in solution.Projects) | ||
695 | { | ||
696 | kernel.Log.Write("...Creating project: {0}", project.Name); | ||
697 | WriteProject(solution, project); | ||
698 | } | ||
699 | |||
700 | kernel.Log.Write(""); | ||
701 | string solutionFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln"); | ||
702 | StreamWriter ss = new StreamWriter(solutionFile); | ||
703 | |||
704 | kernel.CurrentWorkingDirectory.Push(); | ||
705 | Helper.SetCurrentDir(Path.GetDirectoryName(solutionFile)); | ||
706 | |||
707 | using (ss) | ||
708 | { | ||
709 | ss.WriteLine("Microsoft Visual Studio Solution File, Format Version {0}", this.SolutionVersion); | ||
710 | ss.WriteLine("# Visual Studio 2005"); | ||
711 | foreach (ProjectNode project in solution.Projects) | ||
712 | { | ||
713 | if (!tools.ContainsKey(project.Language)) | ||
714 | { | ||
715 | throw new UnknownLanguageException("Unknown .NET language: " + project.Language); | ||
716 | } | ||
717 | |||
718 | ToolInfo toolInfo = (ToolInfo)tools[project.Language]; | ||
719 | |||
720 | string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); | ||
721 | ss.WriteLine("Project(\"{0}\") = \"{1}\", \"{2}\", \"{{{3}}}\"", | ||
722 | toolInfo.Guid, project.Name, Helper.MakeFilePath(path, project.Name, | ||
723 | toolInfo.FileExtension), project.Guid.ToString().ToUpper()); | ||
724 | |||
725 | //ss.WriteLine(" ProjectSection(ProjectDependencies) = postProject"); | ||
726 | //ss.WriteLine(" EndProjectSection"); | ||
727 | |||
728 | ss.WriteLine("EndProject"); | ||
729 | } | ||
730 | |||
731 | if (solution.Files != null) | ||
732 | { | ||
733 | ss.WriteLine("Project(\"{0}\") = \"Solution Items\", \"Solution Items\", \"{1}\"", "{2150E333-8FDC-42A3-9474-1A3956D46DE8}", "{468F1D07-AD17-4CC3-ABD0-2CA268E4E1A6}"); | ||
734 | ss.WriteLine("\tProjectSection(SolutionItems) = preProject"); | ||
735 | foreach (string file in solution.Files) | ||
736 | ss.WriteLine("\t\t{0} = {0}", file); | ||
737 | ss.WriteLine("\tEndProjectSection"); | ||
738 | ss.WriteLine("EndProject"); | ||
739 | } | ||
740 | |||
741 | ss.WriteLine("Global"); | ||
742 | |||
743 | ss.WriteLine(" GlobalSection(SolutionConfigurationPlatforms) = preSolution"); | ||
744 | foreach (ConfigurationNode conf in solution.Configurations) | ||
745 | { | ||
746 | ss.WriteLine(" {0}|Any CPU = {0}|Any CPU", conf.Name); | ||
747 | } | ||
748 | ss.WriteLine(" EndGlobalSection"); | ||
749 | |||
750 | if (solution.Projects.Count > 1) | ||
751 | { | ||
752 | ss.WriteLine(" GlobalSection(ProjectDependencies) = postSolution"); | ||
753 | } | ||
754 | foreach (ProjectNode project in solution.Projects) | ||
755 | { | ||
756 | for (int i = 0; i < project.References.Count; i++) | ||
757 | { | ||
758 | ReferenceNode refr = (ReferenceNode)project.References[i]; | ||
759 | if (solution.ProjectsTable.ContainsKey(refr.Name)) | ||
760 | { | ||
761 | ProjectNode refProject = (ProjectNode)solution.ProjectsTable[refr.Name]; | ||
762 | ss.WriteLine(" ({{{0}}}).{1} = ({{{2}}})", | ||
763 | project.Guid.ToString().ToUpper() | ||
764 | , i, | ||
765 | refProject.Guid.ToString().ToUpper() | ||
766 | ); | ||
767 | } | ||
768 | } | ||
769 | } | ||
770 | if (solution.Projects.Count > 1) | ||
771 | { | ||
772 | ss.WriteLine(" EndGlobalSection"); | ||
773 | } | ||
774 | ss.WriteLine(" GlobalSection(ProjectConfigurationPlatforms) = postSolution"); | ||
775 | foreach (ProjectNode project in solution.Projects) | ||
776 | { | ||
777 | foreach (ConfigurationNode conf in solution.Configurations) | ||
778 | { | ||
779 | ss.WriteLine(" {{{0}}}.{1}|Any CPU.ActiveCfg = {1}|Any CPU", | ||
780 | project.Guid.ToString().ToUpper(), | ||
781 | conf.Name); | ||
782 | |||
783 | ss.WriteLine(" {{{0}}}.{1}|Any CPU.Build.0 = {1}|Any CPU", | ||
784 | project.Guid.ToString().ToUpper(), | ||
785 | conf.Name); | ||
786 | } | ||
787 | } | ||
788 | ss.WriteLine(" EndGlobalSection"); | ||
789 | ss.WriteLine(" GlobalSection(SolutionProperties) = preSolution"); | ||
790 | ss.WriteLine(" HideSolutionNode = FALSE"); | ||
791 | ss.WriteLine(" EndGlobalSection"); | ||
792 | |||
793 | ss.WriteLine("EndGlobal"); | ||
794 | } | ||
795 | |||
796 | kernel.CurrentWorkingDirectory.Pop(); | ||
797 | } | ||
798 | |||
799 | private void CleanProject(ProjectNode project) | ||
800 | { | ||
801 | kernel.Log.Write("...Cleaning project: {0}", project.Name); | ||
802 | |||
803 | ToolInfo toolInfo = (ToolInfo)tools[project.Language]; | ||
804 | string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); | ||
805 | string userFile = projectFile + ".user"; | ||
806 | |||
807 | Helper.DeleteIfExists(projectFile); | ||
808 | Helper.DeleteIfExists(userFile); | ||
809 | } | ||
810 | |||
811 | private void CleanSolution(SolutionNode solution) | ||
812 | { | ||
813 | kernel.Log.Write("Cleaning {0} solution and project files", this.VersionName, solution.Name); | ||
814 | |||
815 | string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln"); | ||
816 | string suoFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "suo"); | ||
817 | |||
818 | Helper.DeleteIfExists(slnFile); | ||
819 | Helper.DeleteIfExists(suoFile); | ||
820 | |||
821 | foreach (ProjectNode project in solution.Projects) | ||
822 | { | ||
823 | CleanProject(project); | ||
824 | } | ||
825 | |||
826 | kernel.Log.Write(""); | ||
827 | } | ||
828 | |||
829 | #endregion | ||
830 | |||
831 | #region ITarget Members | ||
832 | |||
833 | /// <summary> | ||
834 | /// Writes the specified kern. | ||
835 | /// </summary> | ||
836 | /// <param name="kern">The kern.</param> | ||
837 | public virtual void Write(Kernel kern) | ||
838 | { | ||
839 | if (kern == null) | ||
840 | { | ||
841 | throw new ArgumentNullException("kern"); | ||
842 | } | ||
843 | kernel = kern; | ||
844 | foreach (SolutionNode sol in kernel.Solutions) | ||
845 | { | ||
846 | WriteSolution(sol); | ||
847 | } | ||
848 | kernel = null; | ||
849 | } | ||
850 | |||
851 | /// <summary> | ||
852 | /// Cleans the specified kern. | ||
853 | /// </summary> | ||
854 | /// <param name="kern">The kern.</param> | ||
855 | public virtual void Clean(Kernel kern) | ||
856 | { | ||
857 | if (kern == null) | ||
858 | { | ||
859 | throw new ArgumentNullException("kern"); | ||
860 | } | ||
861 | kernel = kern; | ||
862 | foreach (SolutionNode sol in kernel.Solutions) | ||
863 | { | ||
864 | CleanSolution(sol); | ||
865 | } | ||
866 | kernel = null; | ||
867 | } | ||
868 | |||
869 | /// <summary> | ||
870 | /// Gets the name. | ||
871 | /// </summary> | ||
872 | /// <value>The name.</value> | ||
873 | public virtual string Name | ||
874 | { | ||
875 | get | ||
876 | { | ||
877 | return "vs2005"; | ||
878 | } | ||
879 | } | ||
880 | |||
881 | #endregion | ||
882 | } | ||
883 | } | ||