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