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