diff options
Diffstat (limited to '')
-rw-r--r-- | Prebuild/src/Core/Targets/AutotoolsTarget.cs | 112 | ||||
-rw-r--r-- | Prebuild/src/Core/Targets/DebugTarget.cs | 2 | ||||
-rw-r--r-- | Prebuild/src/Core/Targets/MonoDevelopTarget.cs | 9 | ||||
-rw-r--r-- | Prebuild/src/Core/Targets/NAntTarget.cs | 859 | ||||
-rw-r--r-- | Prebuild/src/Core/Targets/SharpDevelop2Target.cs | 33 | ||||
-rw-r--r-- | Prebuild/src/Core/Targets/SharpDevelopTarget.cs | 9 | ||||
-rw-r--r-- | Prebuild/src/Core/Targets/ToolInfo.cs | 197 | ||||
-rw-r--r-- | Prebuild/src/Core/Targets/VS2002Target.cs | 9 | ||||
-rw-r--r-- | Prebuild/src/Core/Targets/VS2003Target.cs | 31 | ||||
-rw-r--r-- | Prebuild/src/Core/Targets/VS2005Target.cs | 837 | ||||
-rw-r--r-- | Prebuild/src/Core/Targets/VS2008Target.cs | 152 | ||||
-rw-r--r-- | Prebuild/src/Core/Targets/VSGenericTarget.cs | 884 | ||||
-rw-r--r-- | Prebuild/src/Core/Targets/VSVersion.cs | 50 | ||||
-rw-r--r-- | Prebuild/src/Core/Targets/XcodeTarget.cs | 9 |
14 files changed, 1751 insertions, 1442 deletions
diff --git a/Prebuild/src/Core/Targets/AutotoolsTarget.cs b/Prebuild/src/Core/Targets/AutotoolsTarget.cs index f102038..5dcbb38 100644 --- a/Prebuild/src/Core/Targets/AutotoolsTarget.cs +++ b/Prebuild/src/Core/Targets/AutotoolsTarget.cs | |||
@@ -65,18 +65,9 @@ POSSIBILITY OF SUCH DAMAGE. | |||
65 | */ | 65 | */ |
66 | 66 | ||
67 | #endregion | 67 | #endregion |
68 | |||
69 | #region CVS Information | ||
70 | /* | ||
71 | * $Source$ | ||
72 | * $Author: jendave $ | ||
73 | * $Date: 2006-07-28 22:43:24 -0700 (Fri, 28 Jul 2006) $ | ||
74 | * $Revision: 136 $ | ||
75 | */ | ||
76 | #endregion | ||
77 | |||
78 | using System; | 68 | using System; |
79 | using System.Collections; | 69 | using System.Collections; |
70 | using System.Collections.Generic; | ||
80 | using System.Collections.Specialized; | 71 | using System.Collections.Specialized; |
81 | using System.IO; | 72 | using System.IO; |
82 | using System.Reflection; | 73 | using System.Reflection; |
@@ -182,8 +173,7 @@ namespace Prebuild.Core.Targets | |||
182 | Hashtable assemblyPathToPackage = new Hashtable(); | 173 | Hashtable assemblyPathToPackage = new Hashtable(); |
183 | Hashtable assemblyFullNameToPath = new Hashtable(); | 174 | Hashtable assemblyFullNameToPath = new Hashtable(); |
184 | Hashtable packagesHash = new Hashtable(); | 175 | Hashtable packagesHash = new Hashtable(); |
185 | ArrayList packages = new ArrayList(); | 176 | readonly List<SystemPackage> packages = new List<SystemPackage>(); |
186 | ClrVersion currentVersion; | ||
187 | 177 | ||
188 | #endregion | 178 | #endregion |
189 | 179 | ||
@@ -203,22 +193,6 @@ namespace Prebuild.Core.Targets | |||
203 | di.Create(); | 193 | di.Create(); |
204 | } | 194 | } |
205 | 195 | ||
206 | private void mkStubFiles(string dirName, ArrayList fileNames) | ||
207 | { | ||
208 | for (int i = 0; i < fileNames.Count; i++) | ||
209 | { | ||
210 | string tmpFile = dirName + "/" + (string)fileNames[i]; | ||
211 | |||
212 | FileStream tmpFileStream = | ||
213 | new FileStream(tmpFile, FileMode.Create); | ||
214 | |||
215 | StreamWriter sw = new StreamWriter(tmpFileStream); | ||
216 | sw.WriteLine("These are not the files you are looking for."); | ||
217 | sw.Flush(); | ||
218 | tmpFileStream.Close(); | ||
219 | } | ||
220 | } | ||
221 | |||
222 | private void chkMkDir(string dirName) | 196 | private void chkMkDir(string dirName) |
223 | { | 197 | { |
224 | System.IO.DirectoryInfo di = | 198 | System.IO.DirectoryInfo di = |
@@ -273,11 +247,11 @@ namespace Prebuild.Core.Targets | |||
273 | } | 247 | } |
274 | } | 248 | } |
275 | 249 | ||
276 | private ArrayList GetAssembliesWithLibInfo(string line, string file) | 250 | private List<string> GetAssembliesWithLibInfo(string line, string file) |
277 | { | 251 | { |
278 | ArrayList references = new ArrayList(); | 252 | List<string> references = new List<string>(); |
279 | ArrayList libdirs = new ArrayList(); | 253 | List<string> libdirs = new List<string>(); |
280 | ArrayList retval = new ArrayList(); | 254 | List<string> retval = new List<string>(); |
281 | foreach (string piece in line.Split(' ')) | 255 | foreach (string piece in line.Split(' ')) |
282 | { | 256 | { |
283 | if (piece.ToLower().Trim().StartsWith("/r:") || piece.ToLower().Trim().StartsWith("-r:")) | 257 | if (piece.ToLower().Trim().StartsWith("/r:") || piece.ToLower().Trim().StartsWith("-r:")) |
@@ -304,9 +278,9 @@ namespace Prebuild.Core.Targets | |||
304 | return retval; | 278 | return retval; |
305 | } | 279 | } |
306 | 280 | ||
307 | private ArrayList GetAssembliesWithoutLibInfo(string line, string file) | 281 | private List<string> GetAssembliesWithoutLibInfo(string line, string file) |
308 | { | 282 | { |
309 | ArrayList references = new ArrayList(); | 283 | List<string> references = new List<string>(); |
310 | foreach (string reference in line.Split(' ')) | 284 | foreach (string reference in line.Split(' ')) |
311 | { | 285 | { |
312 | if (reference.ToLower().Trim().StartsWith("/r:") || reference.ToLower().Trim().StartsWith("-r:")) | 286 | if (reference.ToLower().Trim().StartsWith("/r:") || reference.ToLower().Trim().StartsWith("-r:")) |
@@ -356,7 +330,7 @@ namespace Prebuild.Core.Targets | |||
356 | if (packagesHash.Contains(pname)) | 330 | if (packagesHash.Contains(pname)) |
357 | return; | 331 | return; |
358 | 332 | ||
359 | ArrayList fullassemblies = null; | 333 | List<string> fullassemblies = null; |
360 | string version = ""; | 334 | string version = ""; |
361 | string desc = ""; | 335 | string desc = ""; |
362 | 336 | ||
@@ -404,7 +378,7 @@ namespace Prebuild.Core.Targets | |||
404 | package.Initialize(pname, | 378 | package.Initialize(pname, |
405 | version, | 379 | version, |
406 | desc, | 380 | desc, |
407 | (string[])fullassemblies.ToArray(typeof(string)), | 381 | fullassemblies.ToArray(), |
408 | ClrVersion.Default, | 382 | ClrVersion.Default, |
409 | false); | 383 | false); |
410 | packages.Add(package); | 384 | packages.Add(package); |
@@ -414,7 +388,7 @@ namespace Prebuild.Core.Targets | |||
414 | void RegisterSystemAssemblies(string prefix, string version, ClrVersion ver) | 388 | void RegisterSystemAssemblies(string prefix, string version, ClrVersion ver) |
415 | { | 389 | { |
416 | SystemPackage package = new SystemPackage(); | 390 | SystemPackage package = new SystemPackage(); |
417 | ArrayList list = new ArrayList(); | 391 | List<string> list = new List<string>(); |
418 | 392 | ||
419 | string dir = Path.Combine(prefix, version); | 393 | string dir = Path.Combine(prefix, version); |
420 | if (!Directory.Exists(dir)) | 394 | if (!Directory.Exists(dir)) |
@@ -431,7 +405,7 @@ namespace Prebuild.Core.Targets | |||
431 | package.Initialize("mono", | 405 | package.Initialize("mono", |
432 | version, | 406 | version, |
433 | "The Mono runtime", | 407 | "The Mono runtime", |
434 | (string[])list.ToArray(typeof(string)), | 408 | list.ToArray(), |
435 | ver, | 409 | ver, |
436 | false); | 410 | false); |
437 | packages.Add(package); | 411 | packages.Add(package); |
@@ -444,12 +418,10 @@ namespace Prebuild.Core.Targets | |||
444 | if (Environment.Version.Major == 1) | 418 | if (Environment.Version.Major == 1) |
445 | { | 419 | { |
446 | versionDir = "1.0"; | 420 | versionDir = "1.0"; |
447 | currentVersion = ClrVersion.Net_1_1; | ||
448 | } | 421 | } |
449 | else | 422 | else |
450 | { | 423 | { |
451 | versionDir = "2.0"; | 424 | versionDir = "2.0"; |
452 | currentVersion = ClrVersion.Net_2_0; | ||
453 | } | 425 | } |
454 | 426 | ||
455 | //Pull up assemblies from the installed mono system. | 427 | //Pull up assemblies from the installed mono system. |
@@ -483,9 +455,9 @@ namespace Prebuild.Core.Targets | |||
483 | } | 455 | } |
484 | } | 456 | } |
485 | search_dirs += Path.PathSeparator + libpath; | 457 | search_dirs += Path.PathSeparator + libpath; |
486 | if (search_dirs != null && search_dirs.Length > 0) | 458 | if (!string.IsNullOrEmpty(search_dirs)) |
487 | { | 459 | { |
488 | ArrayList scanDirs = new ArrayList(); | 460 | List<string> scanDirs = new List<string>(); |
489 | foreach (string potentialDir in search_dirs.Split(Path.PathSeparator)) | 461 | foreach (string potentialDir in search_dirs.Split(Path.PathSeparator)) |
490 | { | 462 | { |
491 | if (!scanDirs.Contains(potentialDir)) | 463 | if (!scanDirs.Contains(potentialDir)) |
@@ -763,20 +735,22 @@ namespace Prebuild.Core.Targets | |||
763 | bool hasAssemblyConfig = false; | 735 | bool hasAssemblyConfig = false; |
764 | chkMkDir(projectDir); | 736 | chkMkDir(projectDir); |
765 | 737 | ||
766 | ArrayList | 738 | List<string> |
767 | compiledFiles = new ArrayList(), | 739 | compiledFiles = new List<string>(), |
768 | contentFiles = new ArrayList(), | 740 | contentFiles = new List<string>(), |
769 | embeddedFiles = new ArrayList(), | 741 | embeddedFiles = new List<string>(), |
742 | |||
743 | binaryLibs = new List<string>(), | ||
744 | pkgLibs = new List<string>(), | ||
745 | systemLibs = new List<string>(), | ||
746 | runtimeLibs = new List<string>(), | ||
770 | 747 | ||
771 | binaryLibs = new ArrayList(), | 748 | extraDistFiles = new List<string>(), |
772 | pkgLibs = new ArrayList(), | 749 | localCopyTargets = new List<string>(); |
773 | systemLibs = new ArrayList(), | ||
774 | runtimeLibs = new ArrayList(), | ||
775 | 750 | ||
776 | extraDistFiles = new ArrayList(), | 751 | // If there exists a .config file for this assembly, copy |
777 | localCopyTargets = new ArrayList(); | 752 | // it to the project folder |
778 | 753 | ||
779 | // If there exists a .config file for this assembly, copy it to the project folder | ||
780 | // TODO: Support copying .config.osx files | 754 | // TODO: Support copying .config.osx files |
781 | // TODO: support processing the .config file for native library deps | 755 | // TODO: support processing the .config file for native library deps |
782 | string projectAssemblyName = project.Name; | 756 | string projectAssemblyName = project.Name; |
@@ -839,11 +813,15 @@ namespace Prebuild.Core.Targets | |||
839 | foreach (System.CodeDom.Compiler.CompilerError error in cr.Errors) | 813 | foreach (System.CodeDom.Compiler.CompilerError error in cr.Errors) |
840 | Console.WriteLine("Error! '{0}'", error.ErrorText); | 814 | Console.WriteLine("Error! '{0}'", error.ErrorText); |
841 | 815 | ||
842 | string projectFullName = cr.CompiledAssembly.FullName; | 816 | try { |
843 | Regex verRegex = new Regex("Version=([\\d\\.]+)"); | 817 | string projectFullName = cr.CompiledAssembly.FullName; |
844 | Match verMatch = verRegex.Match(projectFullName); | 818 | Regex verRegex = new Regex("Version=([\\d\\.]+)"); |
845 | if (verMatch.Success) | 819 | Match verMatch = verRegex.Match(projectFullName); |
820 | if (verMatch.Success) | ||
846 | projectVersion = verMatch.Groups[1].Value; | 821 | projectVersion = verMatch.Groups[1].Value; |
822 | }catch{ | ||
823 | Console.WriteLine("Couldn't compile AssemblyInfo.cs"); | ||
824 | } | ||
847 | 825 | ||
848 | // Clean up the temp file | 826 | // Clean up the temp file |
849 | try | 827 | try |
@@ -853,7 +831,7 @@ namespace Prebuild.Core.Targets | |||
853 | } | 831 | } |
854 | catch | 832 | catch |
855 | { | 833 | { |
856 | //Console.WriteLine("Error! '{0}'", e.ToString()); | 834 | Console.WriteLine("Error! '{0}'", e.ToString()); |
857 | } | 835 | } |
858 | 836 | ||
859 | } | 837 | } |
@@ -1013,46 +991,46 @@ namespace Prebuild.Core.Targets | |||
1013 | } | 991 | } |
1014 | } | 992 | } |
1015 | 993 | ||
1016 | string lineSep = " \\\n\t"; | 994 | const string lineSep = " \\\n\t"; |
1017 | string compiledFilesString = string.Empty; | 995 | string compiledFilesString = string.Empty; |
1018 | if (compiledFiles.Count > 0) | 996 | if (compiledFiles.Count > 0) |
1019 | compiledFilesString = | 997 | compiledFilesString = |
1020 | lineSep + string.Join(lineSep, (string[])compiledFiles.ToArray(typeof(string))); | 998 | lineSep + string.Join(lineSep, compiledFiles.ToArray()); |
1021 | 999 | ||
1022 | string embeddedFilesString = ""; | 1000 | string embeddedFilesString = ""; |
1023 | if (embeddedFiles.Count > 0) | 1001 | if (embeddedFiles.Count > 0) |
1024 | embeddedFilesString = | 1002 | embeddedFilesString = |
1025 | lineSep + string.Join(lineSep, (string[])embeddedFiles.ToArray(typeof(string))); | 1003 | lineSep + string.Join(lineSep, embeddedFiles.ToArray()); |
1026 | 1004 | ||
1027 | string contentFilesString = ""; | 1005 | string contentFilesString = ""; |
1028 | if (contentFiles.Count > 0) | 1006 | if (contentFiles.Count > 0) |
1029 | contentFilesString = | 1007 | contentFilesString = |
1030 | lineSep + string.Join(lineSep, (string[])contentFiles.ToArray(typeof(string))); | 1008 | lineSep + string.Join(lineSep, contentFiles.ToArray()); |
1031 | 1009 | ||
1032 | string extraDistFilesString = ""; | 1010 | string extraDistFilesString = ""; |
1033 | if (extraDistFiles.Count > 0) | 1011 | if (extraDistFiles.Count > 0) |
1034 | extraDistFilesString = | 1012 | extraDistFilesString = |
1035 | lineSep + string.Join(lineSep, (string[])extraDistFiles.ToArray(typeof(string))); | 1013 | lineSep + string.Join(lineSep, extraDistFiles.ToArray()); |
1036 | 1014 | ||
1037 | string pkgLibsString = ""; | 1015 | string pkgLibsString = ""; |
1038 | if (pkgLibs.Count > 0) | 1016 | if (pkgLibs.Count > 0) |
1039 | pkgLibsString = | 1017 | pkgLibsString = |
1040 | lineSep + string.Join(lineSep, (string[])pkgLibs.ToArray(typeof(string))); | 1018 | lineSep + string.Join(lineSep, pkgLibs.ToArray()); |
1041 | 1019 | ||
1042 | string binaryLibsString = ""; | 1020 | string binaryLibsString = ""; |
1043 | if (binaryLibs.Count > 0) | 1021 | if (binaryLibs.Count > 0) |
1044 | binaryLibsString = | 1022 | binaryLibsString = |
1045 | lineSep + string.Join(lineSep, (string[])binaryLibs.ToArray(typeof(string))); | 1023 | lineSep + string.Join(lineSep, binaryLibs.ToArray()); |
1046 | 1024 | ||
1047 | string systemLibsString = ""; | 1025 | string systemLibsString = ""; |
1048 | if (systemLibs.Count > 0) | 1026 | if (systemLibs.Count > 0) |
1049 | systemLibsString = | 1027 | systemLibsString = |
1050 | lineSep + string.Join(lineSep, (string[])systemLibs.ToArray(typeof(string))); | 1028 | lineSep + string.Join(lineSep, systemLibs.ToArray()); |
1051 | 1029 | ||
1052 | string localCopyTargetsString = ""; | 1030 | string localCopyTargetsString = ""; |
1053 | if (localCopyTargets.Count > 0) | 1031 | if (localCopyTargets.Count > 0) |
1054 | localCopyTargetsString = | 1032 | localCopyTargetsString = |
1055 | string.Join("\n", (string[])localCopyTargets.ToArray(typeof(string))); | 1033 | string.Join("\n", localCopyTargets.ToArray()); |
1056 | 1034 | ||
1057 | string monoPath = ""; | 1035 | string monoPath = ""; |
1058 | foreach (string runtimeLib in runtimeLibs) | 1036 | foreach (string runtimeLib in runtimeLibs) |
diff --git a/Prebuild/src/Core/Targets/DebugTarget.cs b/Prebuild/src/Core/Targets/DebugTarget.cs index db19e05..dc4e666 100644 --- a/Prebuild/src/Core/Targets/DebugTarget.cs +++ b/Prebuild/src/Core/Targets/DebugTarget.cs | |||
@@ -27,7 +27,7 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O | |||
27 | /* | 27 | /* |
28 | * $Source$ | 28 | * $Source$ |
29 | * $Author: jendave $ | 29 | * $Author: jendave $ |
30 | * $Date: 2006-09-20 16:42:51 +0900 (Wed, 20 Sep 2006) $ | 30 | * $Date: 2006-09-20 09:42:51 +0200 (on, 20 sep 2006) $ |
31 | * $Revision: 164 $ | 31 | * $Revision: 164 $ |
32 | */ | 32 | */ |
33 | #endregion | 33 | #endregion |
diff --git a/Prebuild/src/Core/Targets/MonoDevelopTarget.cs b/Prebuild/src/Core/Targets/MonoDevelopTarget.cs index 5a5dc55..c8401fd 100644 --- a/Prebuild/src/Core/Targets/MonoDevelopTarget.cs +++ b/Prebuild/src/Core/Targets/MonoDevelopTarget.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: cjcollier $ | ||
30 | * $Date: 2007-04-11 07:10:35 +0900 (Wed, 11 Apr 2007) $ | ||
31 | * $Revision: 231 $ | ||
32 | */ | ||
33 | #endregion | ||
34 | |||
35 | using System; | 26 | using System; |
36 | using System.Collections; | 27 | using System.Collections; |
37 | using System.Collections.Specialized; | 28 | using System.Collections.Specialized; |
diff --git a/Prebuild/src/Core/Targets/NAntTarget.cs b/Prebuild/src/Core/Targets/NAntTarget.cs index eb5325d..9a6ee17 100644 --- a/Prebuild/src/Core/Targets/NAntTarget.cs +++ b/Prebuild/src/Core/Targets/NAntTarget.cs | |||
@@ -1,9 +1,9 @@ | |||
1 | #region BSD License | 1 | #region BSD License |
2 | /* | 2 | /* |
3 | Copyright (c) 2004 - 2008 | 3 | Copyright (c) 2004 - 2008 |
4 | Matthew Holmes (matthew@wildfiregames.com), | 4 | Matthew Holmes (matthew@wildfiregames.com), |
5 | Dan Moorehead (dan05a@gmail.com), | 5 | Dan Moorehead (dan05a@gmail.com), |
6 | C.J. Adams-Collier (cjac@colliertech.org), | 6 | C.J. Adams-Collier (cjac@colliertech.org), |
7 | 7 | ||
8 | Redistribution and use in source and binary forms, with or without | 8 | Redistribution and use in source and binary forms, with or without |
9 | modification, are permitted provided that the following conditions are | 9 | modification, are permitted provided that the following conditions are |
@@ -35,15 +35,6 @@ POSSIBILITY OF SUCH DAMAGE. | |||
35 | 35 | ||
36 | #endregion | 36 | #endregion |
37 | 37 | ||
38 | #region CVS Information | ||
39 | /* | ||
40 | * $Source$ | ||
41 | * $Author: cjcollier $ | ||
42 | * $Date: 2008-02-07 10:22:36 +0900 (Thu, 07 Feb 2008) $ | ||
43 | * $Revision: 255 $ | ||
44 | */ | ||
45 | #endregion | ||
46 | |||
47 | using System; | 38 | using System; |
48 | using System.Collections; | 39 | using System.Collections; |
49 | using System.Collections.Specialized; | 40 | using System.Collections.Specialized; |
@@ -58,85 +49,73 @@ using Prebuild.Core.Utilities; | |||
58 | 49 | ||
59 | namespace Prebuild.Core.Targets | 50 | namespace Prebuild.Core.Targets |
60 | { | 51 | { |
61 | /// <summary> | 52 | /// <summary> |
62 | /// | 53 | /// |
63 | /// </summary> | 54 | /// </summary> |
64 | [Target("nant")] | 55 | [Target("nant")] |
65 | public class NAntTarget : ITarget | 56 | public class NAntTarget : ITarget |
66 | { | 57 | { |
67 | #region Fields | 58 | #region Fields |
68 | 59 | ||
69 | private Kernel m_Kernel; | 60 | private Kernel m_Kernel; |
70 | 61 | ||
71 | #endregion | 62 | #endregion |
72 | 63 | ||
73 | #region Private Methods | 64 | #region Private Methods |
74 | 65 | ||
75 | private static string PrependPath(string path) | 66 | private static string PrependPath(string path) |
76 | { | 67 | { |
77 | string tmpPath = Helper.NormalizePath(path, '/'); | 68 | string tmpPath = Helper.NormalizePath(path, '/'); |
78 | Regex regex = new Regex(@"(\w):/(\w+)"); | 69 | Regex regex = new Regex(@"(\w):/(\w+)"); |
79 | Match match = regex.Match(tmpPath); | 70 | Match match = regex.Match(tmpPath); |
80 | //if(match.Success || tmpPath[0] == '.' || tmpPath[0] == '/') | 71 | //if(match.Success || tmpPath[0] == '.' || tmpPath[0] == '/') |
81 | //{ | 72 | //{ |
82 | tmpPath = Helper.NormalizePath(tmpPath); | 73 | tmpPath = Helper.NormalizePath(tmpPath); |
83 | //} | 74 | //} |
84 | // else | 75 | // else |
85 | // { | 76 | // { |
86 | // tmpPath = Helper.NormalizePath("./" + tmpPath); | 77 | // tmpPath = Helper.NormalizePath("./" + tmpPath); |
87 | // } | 78 | // } |
88 | 79 | ||
89 | return tmpPath; | 80 | return tmpPath; |
90 | } | 81 | } |
91 | 82 | ||
92 | private static string BuildReference(SolutionNode solution, ProjectNode currentProject, ReferenceNode refr) | 83 | private static string BuildReference(SolutionNode solution, ProjectNode currentProject, ReferenceNode refr) |
93 | { | 84 | { |
94 | string ret = ""; | ||
95 | string referencePath = ((ReferencePathNode)currentProject.ReferencePaths[0]).Path; | ||
96 | 85 | ||
97 | if (String.IsNullOrEmpty(refr.Path)) | 86 | if (!String.IsNullOrEmpty(refr.Path)) |
98 | { | 87 | { |
99 | if (solution.ProjectsTable.ContainsKey(refr.Name)) | 88 | return refr.Path; |
100 | { | 89 | } |
101 | ProjectNode project = (ProjectNode) solution.ProjectsTable[refr.Name]; | 90 | |
102 | string finalPath = | 91 | if (solution.ProjectsTable.ContainsKey(refr.Name)) |
103 | Helper.NormalizePath(referencePath + refr.Name + GetProjectExtension(project), '/'); | 92 | { |
104 | return finalPath; | 93 | ProjectNode projectRef = (ProjectNode) solution.ProjectsTable[refr.Name]; |
105 | } | 94 | string finalPath = |
106 | else | 95 | Helper.NormalizePath(refr.Name + GetProjectExtension(projectRef), '/'); |
107 | { | 96 | return finalPath; |
108 | ProjectNode project = (ProjectNode) refr.Parent; | 97 | } |
109 | |||
110 | // Do we have an explicit file reference? | ||
111 | string fileRef = FindFileReference(refr.Name, project); | ||
112 | if (fileRef != null) | ||
113 | { | ||
114 | return fileRef; | ||
115 | } | ||
116 | |||
117 | // Is there an explicit path in the project ref? | ||
118 | if (refr.Path != null) | ||
119 | { | ||
120 | return Helper.NormalizePath(refr.Path + "/" + refr.Name + GetProjectExtension(project), '/'); | ||
121 | } | ||
122 | 98 | ||
123 | // Is it a specified extension (dll or exe?) | 99 | ProjectNode project = (ProjectNode) refr.Parent; |
124 | if (ExtensionSpecified(refr.Name)) | ||
125 | { | ||
126 | return Helper.NormalizePath(referencePath + GetRefFileName(refr.Name), '/'); | ||
127 | } | ||
128 | 100 | ||
129 | // No, it's an extensionless GAC ref, but nant needs the .dll extension anyway | 101 | // Do we have an explicit file reference? |
130 | return refr.Name + ".dll"; | 102 | string fileRef = FindFileReference(refr.Name, project); |
131 | } | 103 | if (fileRef != null) |
104 | { | ||
105 | return fileRef; | ||
132 | } | 106 | } |
133 | else | 107 | |
108 | // Is there an explicit path in the project ref? | ||
109 | if (refr.Path != null) | ||
134 | { | 110 | { |
135 | return refr.Path; | 111 | return Helper.NormalizePath(refr.Path + "/" + refr.Name + GetProjectExtension(project), '/'); |
136 | } | 112 | } |
113 | |||
114 | // No, it's an extensionless GAC ref, but nant needs the .dll extension anyway | ||
115 | return refr.Name + ".dll"; | ||
137 | } | 116 | } |
138 | 117 | ||
139 | public static string GetRefFileName(string refName) | 118 | public static string GetRefFileName(string refName) |
140 | { | 119 | { |
141 | if (ExtensionSpecified(refName)) | 120 | if (ExtensionSpecified(refName)) |
142 | { | 121 | { |
@@ -144,7 +123,7 @@ namespace Prebuild.Core.Targets | |||
144 | } | 123 | } |
145 | else | 124 | else |
146 | { | 125 | { |
147 | return refName + ".dll"; | 126 | return refName + ".dll"; |
148 | } | 127 | } |
149 | } | 128 | } |
150 | 129 | ||
@@ -156,268 +135,235 @@ namespace Prebuild.Core.Targets | |||
156 | private static string GetProjectExtension(ProjectNode project) | 135 | private static string GetProjectExtension(ProjectNode project) |
157 | { | 136 | { |
158 | string extension = ".dll"; | 137 | string extension = ".dll"; |
159 | if (project.Type == ProjectType.Exe) | 138 | if (project.Type == ProjectType.Exe || project.Type == ProjectType.WinExe) |
160 | { | 139 | { |
161 | extension = ".exe"; | 140 | extension = ".exe"; |
162 | } | 141 | } |
163 | return extension; | 142 | return extension; |
164 | } | 143 | } |
165 | 144 | ||
166 | //private static string BuildReferencePath(SolutionNode solution, ReferenceNode refr) | 145 | private static string FindFileReference(string refName, ProjectNode project) |
167 | //{ | 146 | { |
168 | // string ret = ""; | 147 | foreach (ReferencePathNode refPath in project.ReferencePaths) |
169 | // if (solution.ProjectsTable.ContainsKey(refr.Name)) | 148 | { |
170 | // { | 149 | string fullPath = Helper.MakeFilePath(refPath.Path, refName); |
171 | // ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name]; | ||
172 | // string finalPath = Helper.NormalizePath(((ReferencePathNode)project.ReferencePaths[0]).Path, '/'); | ||
173 | // return finalPath; | ||
174 | // } | ||
175 | // else | ||
176 | // { | ||
177 | // if (refr.Path == null) | ||
178 | // { | ||
179 | // ProjectNode project = (ProjectNode) refr.Parent; | ||
180 | // string fileRef = FindFileReference(refr.Name, project); | ||
181 | |||
182 | // if (refr.Path != null || fileRef != null) | ||
183 | // { | ||
184 | // string finalPath = (refr.Path != null) ? Helper.NormalizePath(refr.Path, '/') : fileRef; | ||
185 | // ret += finalPath; | ||
186 | // return ret; | ||
187 | // } | ||
188 | |||
189 | // try | ||
190 | // { | ||
191 | // Assembly assem = Assembly.Load(refr.Name); | ||
192 | // if (assem != null) | ||
193 | // { | ||
194 | // ret += ""; | ||
195 | // } | ||
196 | // else | ||
197 | // { | ||
198 | // ret += ""; | ||
199 | // } | ||
200 | // } | ||
201 | // catch (System.NullReferenceException e) | ||
202 | // { | ||
203 | // e.ToString(); | ||
204 | // ret += ""; | ||
205 | // } | ||
206 | // } | ||
207 | // else | ||
208 | // { | ||
209 | // ret = refr.Path; | ||
210 | // } | ||
211 | // } | ||
212 | // return ret; | ||
213 | //} | ||
214 | |||
215 | private static string FindFileReference(string refName, ProjectNode project) | ||
216 | { | ||
217 | foreach (ReferencePathNode refPath in project.ReferencePaths) | ||
218 | { | ||
219 | string fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll"); | ||
220 | 150 | ||
221 | if (File.Exists(fullPath)) | 151 | if (File.Exists(fullPath)) |
222 | { | 152 | { |
223 | return fullPath; | 153 | return fullPath; |
224 | } | 154 | } |
225 | 155 | ||
156 | fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll"); | ||
157 | |||
158 | if (File.Exists(fullPath)) | ||
159 | { | ||
160 | return fullPath; | ||
161 | } | ||
162 | |||
226 | fullPath = Helper.MakeFilePath(refPath.Path, refName, "exe"); | 163 | fullPath = Helper.MakeFilePath(refPath.Path, refName, "exe"); |
227 | 164 | ||
228 | if (File.Exists(fullPath)) | 165 | if (File.Exists(fullPath)) |
229 | { | 166 | { |
230 | return fullPath; | 167 | return fullPath; |
231 | } | 168 | } |
232 | } | 169 | } |
233 | 170 | ||
234 | return null; | 171 | return null; |
235 | } | 172 | } |
236 | 173 | ||
237 | /// <summary> | 174 | /// <summary> |
238 | /// Gets the XML doc file. | 175 | /// Gets the XML doc file. |
239 | /// </summary> | 176 | /// </summary> |
240 | /// <param name="project">The project.</param> | 177 | /// <param name="project">The project.</param> |
241 | /// <param name="conf">The conf.</param> | 178 | /// <param name="conf">The conf.</param> |
242 | /// <returns></returns> | 179 | /// <returns></returns> |
243 | public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf) | 180 | public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf) |
244 | { | 181 | { |
245 | if (conf == null) | 182 | if (conf == null) |
246 | { | 183 | { |
247 | throw new ArgumentNullException("conf"); | 184 | throw new ArgumentNullException("conf"); |
248 | } | 185 | } |
249 | if (project == null) | 186 | if (project == null) |
250 | { | 187 | { |
251 | throw new ArgumentNullException("project"); | 188 | throw new ArgumentNullException("project"); |
252 | } | 189 | } |
253 | string docFile = (string)conf.Options["XmlDocFile"]; | 190 | string docFile = (string)conf.Options["XmlDocFile"]; |
254 | // if(docFile != null && docFile.Length == 0)//default to assembly name if not specified | 191 | // if(docFile != null && docFile.Length == 0)//default to assembly name if not specified |
255 | // { | 192 | // { |
256 | // return Path.GetFileNameWithoutExtension(project.AssemblyName) + ".xml"; | 193 | // return Path.GetFileNameWithoutExtension(project.AssemblyName) + ".xml"; |
257 | // } | 194 | // } |
258 | return docFile; | 195 | return docFile; |
259 | } | 196 | } |
260 | 197 | ||
261 | private void WriteProject(SolutionNode solution, ProjectNode project) | 198 | private void WriteProject(SolutionNode solution, ProjectNode project) |
262 | { | 199 | { |
263 | string projFile = Helper.MakeFilePath(project.FullPath, project.Name + GetProjectExtension(project), "build"); | 200 | string projFile = Helper.MakeFilePath(project.FullPath, project.Name + GetProjectExtension(project), "build"); |
264 | StreamWriter ss = new StreamWriter(projFile); | 201 | StreamWriter ss = new StreamWriter(projFile); |
265 | 202 | ||
266 | m_Kernel.CurrentWorkingDirectory.Push(); | 203 | m_Kernel.CurrentWorkingDirectory.Push(); |
267 | Helper.SetCurrentDir(Path.GetDirectoryName(projFile)); | 204 | Helper.SetCurrentDir(Path.GetDirectoryName(projFile)); |
268 | bool hasDoc = false; | 205 | bool hasDoc = false; |
269 | 206 | ||
270 | using (ss) | 207 | using (ss) |
271 | { | 208 | { |
272 | ss.WriteLine("<?xml version=\"1.0\" ?>"); | 209 | ss.WriteLine("<?xml version=\"1.0\" ?>"); |
273 | ss.WriteLine("<project name=\"{0}\" default=\"build\">", project.Name); | 210 | ss.WriteLine("<project name=\"{0}\" default=\"build\">", project.Name); |
274 | ss.WriteLine(" <target name=\"{0}\">", "build"); | 211 | ss.WriteLine(" <target name=\"{0}\">", "build"); |
275 | ss.WriteLine(" <echo message=\"Build Directory is ${project::get-base-directory()}/${build.dir}\" />"); | 212 | ss.WriteLine(" <echo message=\"Build Directory is ${project::get-base-directory()}/${build.dir}\" />"); |
276 | ss.WriteLine(" <mkdir dir=\"${project::get-base-directory()}/${build.dir}\" />"); | 213 | ss.WriteLine(" <mkdir dir=\"${project::get-base-directory()}/${build.dir}\" />"); |
277 | ss.WriteLine(" <copy todir=\"${project::get-base-directory()}/${build.dir}\" flatten=\"true\">"); | 214 | ss.WriteLine(" <copy todir=\"${project::get-base-directory()}/${build.dir}\" flatten=\"true\">"); |
278 | ss.WriteLine(" <fileset basedir=\"${project::get-base-directory()}\">"); | 215 | ss.WriteLine(" <fileset basedir=\"${project::get-base-directory()}\">"); |
279 | foreach (ReferenceNode refr in project.References) | 216 | foreach (ReferenceNode refr in project.References) |
280 | { | 217 | { |
281 | if (refr.LocalCopy) | 218 | if (refr.LocalCopy) |
282 | { | 219 | { |
283 | ss.WriteLine(" <include name=\"{0}", Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReference(solution, project, refr)) + "\" />", '/')); | 220 | ss.WriteLine(" <include name=\"{0}", Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReference(solution, project, refr)) + "\" />", '/')); |
284 | } | 221 | } |
285 | } | 222 | } |
286 | 223 | ||
287 | ss.WriteLine(" </fileset>"); | 224 | ss.WriteLine(" </fileset>"); |
288 | ss.WriteLine(" </copy>"); | 225 | ss.WriteLine(" </copy>"); |
289 | if (project.ConfigFile != null && project.ConfigFile.Length!=0) | 226 | if (project.ConfigFile != null && project.ConfigFile.Length!=0) |
290 | { | 227 | { |
291 | ss.Write(" <copy file=\"" + project.ConfigFile + "\" tofile=\"${project::get-base-directory()}/${build.dir}/${project::get-name()}"); | 228 | ss.Write(" <copy file=\"" + project.ConfigFile + "\" tofile=\"${project::get-base-directory()}/${build.dir}/${project::get-name()}"); |
292 | 229 | ||
293 | if (project.Type == ProjectType.Library) | 230 | if (project.Type == ProjectType.Library) |
294 | { | 231 | { |
295 | ss.Write(".dll.config\""); | 232 | ss.Write(".dll.config\""); |
296 | } | 233 | } |
297 | else | 234 | else |
298 | { | 235 | { |
299 | ss.Write(".exe.config\""); | 236 | ss.Write(".exe.config\""); |
300 | } | 237 | } |
301 | ss.WriteLine(" />"); | 238 | ss.WriteLine(" />"); |
302 | } | 239 | } |
303 | 240 | ||
304 | // Add the content files to just be copied | 241 | // Add the content files to just be copied |
305 | ss.WriteLine(" {0}", "<copy todir=\"${project::get-base-directory()}/${build.dir}\">"); | 242 | ss.WriteLine(" {0}", "<copy todir=\"${project::get-base-directory()}/${build.dir}\">"); |
306 | ss.WriteLine(" {0}", "<fileset basedir=\".\">"); | 243 | ss.WriteLine(" {0}", "<fileset basedir=\".\">"); |
307 | 244 | ||
308 | foreach (string file in project.Files) | 245 | foreach (string file in project.Files) |
309 | { | 246 | { |
310 | // Ignore if we aren't content | 247 | // Ignore if we aren't content |
311 | if (project.Files.GetBuildAction(file) != BuildAction.Content) | 248 | if (project.Files.GetBuildAction(file) != BuildAction.Content) |
312 | continue; | 249 | continue; |
313 | 250 | ||
314 | // Create a include tag | 251 | // Create a include tag |
315 | ss.WriteLine(" {0}", "<include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />"); | 252 | ss.WriteLine(" {0}", "<include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />"); |
316 | } | 253 | } |
317 | 254 | ||
318 | ss.WriteLine(" {0}", "</fileset>"); | 255 | ss.WriteLine(" {0}", "</fileset>"); |
319 | ss.WriteLine(" {0}", "</copy>"); | 256 | ss.WriteLine(" {0}", "</copy>"); |
320 | 257 | ||
321 | ss.Write(" <csc"); | 258 | ss.Write(" <csc"); |
322 | ss.Write(" target=\"{0}\"", project.Type.ToString().ToLower()); | 259 | ss.Write(" target=\"{0}\"", project.Type.ToString().ToLower()); |
323 | ss.Write(" debug=\"{0}\"", "${build.debug}"); | 260 | ss.Write(" debug=\"{0}\"", "${build.debug}"); |
324 | foreach (ConfigurationNode conf in project.Configurations) | 261 | foreach (ConfigurationNode conf in project.Configurations) |
325 | { | 262 | { |
326 | if (conf.Options.KeyFile != "") | 263 | if (conf.Options.KeyFile != "") |
327 | { | 264 | { |
328 | ss.Write(" keyfile=\"{0}\"", conf.Options.KeyFile); | 265 | ss.Write(" keyfile=\"{0}\"", conf.Options.KeyFile); |
329 | break; | 266 | break; |
330 | } | 267 | } |
331 | } | 268 | } |
332 | foreach (ConfigurationNode conf in project.Configurations) | 269 | foreach (ConfigurationNode conf in project.Configurations) |
270 | { | ||
271 | ss.Write(" unsafe=\"{0}\"", conf.Options.AllowUnsafe); | ||
272 | break; | ||
273 | } | ||
274 | foreach (ConfigurationNode conf in project.Configurations) | ||
275 | { | ||
276 | ss.Write(" warnaserror=\"{0}\"", conf.Options.WarningsAsErrors); | ||
277 | break; | ||
278 | } | ||
279 | foreach (ConfigurationNode conf in project.Configurations) | ||
280 | { | ||
281 | ss.Write(" define=\"{0}\"", conf.Options.CompilerDefines); | ||
282 | break; | ||
283 | } | ||
284 | foreach (ConfigurationNode conf in project.Configurations) | ||
285 | { | ||
286 | ss.Write(" nostdlib=\"{0}\"", conf.Options["NoStdLib"]); | ||
287 | break; | ||
288 | } | ||
289 | |||
290 | ss.Write(" main=\"{0}\"", project.StartupObject); | ||
291 | |||
292 | foreach (ConfigurationNode conf in project.Configurations) | ||
293 | { | ||
294 | if (GetXmlDocFile(project, conf) != "") | ||
295 | { | ||
296 | ss.Write(" doc=\"{0}\"", "${project::get-base-directory()}/${build.dir}/" + GetXmlDocFile(project, conf)); | ||
297 | hasDoc = true; | ||
298 | } | ||
299 | break; | ||
300 | } | ||
301 | ss.Write(" output=\"{0}", "${project::get-base-directory()}/${build.dir}/${project::get-name()}"); | ||
302 | if (project.Type == ProjectType.Library) | ||
303 | { | ||
304 | ss.Write(".dll\""); | ||
305 | } | ||
306 | else | ||
307 | { | ||
308 | ss.Write(".exe\""); | ||
309 | } | ||
310 | if (project.AppIcon != null && project.AppIcon.Length != 0) | ||
311 | { | ||
312 | ss.Write(" win32icon=\"{0}\"", Helper.NormalizePath(project.AppIcon, '/')); | ||
313 | } | ||
314 | ss.WriteLine(">"); | ||
315 | ss.WriteLine(" <resources prefix=\"{0}\" dynamicprefix=\"true\" >", project.RootNamespace); | ||
316 | foreach (string file in project.Files) | ||
317 | { | ||
318 | switch (project.Files.GetBuildAction(file)) | ||
319 | { | ||
320 | case BuildAction.EmbeddedResource: | ||
321 | ss.WriteLine(" {0}", "<include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />"); | ||
322 | break; | ||
323 | default: | ||
324 | if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings) | ||
325 | { | ||
326 | ss.WriteLine(" <include name=\"{0}\" />", file.Substring(0, file.LastIndexOf('.')) + ".resx"); | ||
327 | } | ||
328 | break; | ||
329 | } | ||
330 | } | ||
331 | //if (project.Files.GetSubType(file).ToString() != "Code") | ||
332 | //{ | ||
333 | // ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".resx"); | ||
334 | |||
335 | ss.WriteLine(" </resources>"); | ||
336 | ss.WriteLine(" <sources failonempty=\"true\">"); | ||
337 | foreach (string file in project.Files) | ||
338 | { | ||
339 | switch (project.Files.GetBuildAction(file)) | ||
340 | { | ||
341 | case BuildAction.Compile: | ||
342 | ss.WriteLine(" <include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />"); | ||
343 | break; | ||
344 | default: | ||
345 | break; | ||
346 | } | ||
347 | } | ||
348 | ss.WriteLine(" </sources>"); | ||
349 | ss.WriteLine(" <references basedir=\"${project::get-base-directory()}\">"); | ||
350 | ss.WriteLine(" <lib>"); | ||
351 | ss.WriteLine(" <include name=\"${project::get-base-directory()}\" />"); | ||
352 | foreach(ReferencePathNode refPath in project.ReferencePaths) | ||
333 | { | 353 | { |
334 | ss.Write(" unsafe=\"{0}\"", conf.Options.AllowUnsafe); | 354 | ss.WriteLine(" <include name=\"${project::get-base-directory()}/" + refPath.Path.TrimEnd('/', '\\') + "\" />"); |
335 | break; | ||
336 | } | 355 | } |
337 | foreach (ConfigurationNode conf in project.Configurations) | 356 | ss.WriteLine(" </lib>"); |
338 | { | 357 | foreach (ReferenceNode refr in project.References) |
339 | ss.Write(" warnaserror=\"{0}\"", conf.Options.WarningsAsErrors); | 358 | { |
340 | break; | 359 | string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReference(solution, project, refr)), '/'); |
341 | } | ||
342 | foreach (ConfigurationNode conf in project.Configurations) | ||
343 | { | ||
344 | ss.Write(" define=\"{0}\"", conf.Options.CompilerDefines); | ||
345 | break; | ||
346 | } | ||
347 | ss.Write(" main=\"{0}\"", project.StartupObject); | ||
348 | |||
349 | foreach (ConfigurationNode conf in project.Configurations) | ||
350 | { | ||
351 | if (GetXmlDocFile(project, conf) != "") | ||
352 | { | ||
353 | ss.Write(" doc=\"{0}\"", "${project::get-base-directory()}/${build.dir}/" + GetXmlDocFile(project, conf)); | ||
354 | hasDoc = true; | ||
355 | } | ||
356 | break; | ||
357 | } | ||
358 | ss.Write(" output=\"{0}", "${project::get-base-directory()}/${build.dir}/${project::get-name()}"); | ||
359 | if (project.Type == ProjectType.Library) | ||
360 | { | ||
361 | ss.Write(".dll\""); | ||
362 | } | ||
363 | else | ||
364 | { | ||
365 | ss.Write(".exe\""); | ||
366 | } | ||
367 | if (project.AppIcon != null && project.AppIcon.Length != 0) | ||
368 | { | ||
369 | ss.Write(" win32icon=\"{0}\"", Helper.NormalizePath(project.AppIcon, '/')); | ||
370 | } | ||
371 | ss.WriteLine(">"); | ||
372 | ss.WriteLine(" <resources prefix=\"{0}\" dynamicprefix=\"true\" >", project.RootNamespace); | ||
373 | foreach (string file in project.Files) | ||
374 | { | ||
375 | switch (project.Files.GetBuildAction(file)) | ||
376 | { | ||
377 | case BuildAction.EmbeddedResource: | ||
378 | ss.WriteLine(" {0}", "<include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />"); | ||
379 | break; | ||
380 | default: | ||
381 | if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings) | ||
382 | { | ||
383 | ss.WriteLine(" <include name=\"{0}\" />", file.Substring(0, file.LastIndexOf('.')) + ".resx"); | ||
384 | } | ||
385 | break; | ||
386 | } | ||
387 | } | ||
388 | //if (project.Files.GetSubType(file).ToString() != "Code") | ||
389 | //{ | ||
390 | // ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".resx"); | ||
391 | |||
392 | ss.WriteLine(" </resources>"); | ||
393 | ss.WriteLine(" <sources failonempty=\"true\">"); | ||
394 | foreach (string file in project.Files) | ||
395 | { | ||
396 | switch (project.Files.GetBuildAction(file)) | ||
397 | { | ||
398 | case BuildAction.Compile: | ||
399 | ss.WriteLine(" <include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />"); | ||
400 | break; | ||
401 | default: | ||
402 | break; | ||
403 | } | ||
404 | } | ||
405 | ss.WriteLine(" </sources>"); | ||
406 | ss.WriteLine(" <references basedir=\"${project::get-base-directory()}\">"); | ||
407 | ss.WriteLine(" <lib>"); | ||
408 | ss.WriteLine(" <include name=\"${project::get-base-directory()}\" />"); | ||
409 | ss.WriteLine(" <include name=\"${project::get-base-directory()}/${build.dir}\" />"); | ||
410 | ss.WriteLine(" </lib>"); | ||
411 | foreach (ReferenceNode refr in project.References) | ||
412 | { | ||
413 | string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReference(solution, project, refr)), '/'); | ||
414 | ss.WriteLine(" <include name=\"" + path + "\" />"); | 360 | ss.WriteLine(" <include name=\"" + path + "\" />"); |
415 | } | 361 | } |
416 | ss.WriteLine(" </references>"); | 362 | ss.WriteLine(" </references>"); |
417 | 363 | ||
418 | ss.WriteLine(" </csc>"); | 364 | ss.WriteLine(" </csc>"); |
419 | 365 | ||
420 | foreach (ConfigurationNode conf in project.Configurations) | 366 | foreach (ConfigurationNode conf in project.Configurations) |
421 | { | 367 | { |
422 | if (!String.IsNullOrEmpty(conf.Options.OutputPath)) | 368 | if (!String.IsNullOrEmpty(conf.Options.OutputPath)) |
423 | { | 369 | { |
@@ -432,149 +378,160 @@ namespace Prebuild.Core.Targets | |||
432 | ss.WriteLine(" <include name=\"*.dll\"/>"); | 378 | ss.WriteLine(" <include name=\"*.dll\"/>"); |
433 | ss.WriteLine(" <include name=\"*.exe\"/>"); | 379 | ss.WriteLine(" <include name=\"*.exe\"/>"); |
434 | ss.WriteLine(" <include name=\"*.mdb\" if='${build.debug}'/>"); | 380 | ss.WriteLine(" <include name=\"*.mdb\" if='${build.debug}'/>"); |
381 | ss.WriteLine(" <include name=\"*.pdb\" if='${build.debug}'/>"); | ||
435 | ss.WriteLine(" </fileset>"); | 382 | ss.WriteLine(" </fileset>"); |
436 | ss.WriteLine(" </copy>"); | 383 | ss.WriteLine(" </copy>"); |
437 | break; | 384 | break; |
438 | } | 385 | } |
439 | } | 386 | } |
440 | 387 | ||
441 | ss.WriteLine(" </target>"); | 388 | ss.WriteLine(" </target>"); |
442 | 389 | ||
443 | ss.WriteLine(" <target name=\"clean\">"); | 390 | ss.WriteLine(" <target name=\"clean\">"); |
444 | ss.WriteLine(" <delete dir=\"${obj.dir}\" failonerror=\"false\" />"); | 391 | ss.WriteLine(" <delete dir=\"${bin.dir}\" failonerror=\"false\" />"); |
445 | ss.WriteLine(" <delete dir=\"${bin.dir}\" failonerror=\"false\" />"); | 392 | ss.WriteLine(" <delete dir=\"${obj.dir}\" failonerror=\"false\" />"); |
446 | ss.WriteLine(" </target>"); | 393 | ss.WriteLine(" </target>"); |
447 | 394 | ||
448 | ss.WriteLine(" <target name=\"doc\" description=\"Creates documentation.\">"); | 395 | ss.WriteLine(" <target name=\"doc\" description=\"Creates documentation.\">"); |
449 | if (hasDoc) | 396 | if (hasDoc) |
450 | { | 397 | { |
451 | ss.WriteLine(" <property name=\"doc.target\" value=\"\" />"); | 398 | ss.WriteLine(" <property name=\"doc.target\" value=\"\" />"); |
452 | ss.WriteLine(" <if test=\"${platform::is-unix()}\">"); | 399 | ss.WriteLine(" <if test=\"${platform::is-unix()}\">"); |
453 | ss.WriteLine(" <property name=\"doc.target\" value=\"Web\" />"); | 400 | ss.WriteLine(" <property name=\"doc.target\" value=\"Web\" />"); |
454 | ss.WriteLine(" </if>"); | 401 | ss.WriteLine(" </if>"); |
455 | ss.WriteLine(" <ndoc failonerror=\"false\" verbose=\"true\">"); | 402 | ss.WriteLine(" <ndoc failonerror=\"false\" verbose=\"true\">"); |
456 | ss.WriteLine(" <assemblies basedir=\"${project::get-base-directory()}\">"); | 403 | ss.WriteLine(" <assemblies basedir=\"${project::get-base-directory()}\">"); |
457 | ss.Write(" <include name=\"${build.dir}/${project::get-name()}"); | 404 | ss.Write(" <include name=\"${build.dir}/${project::get-name()}"); |
458 | if (project.Type == ProjectType.Library) | 405 | if (project.Type == ProjectType.Library) |
459 | { | 406 | { |
460 | ss.WriteLine(".dll\" />"); | 407 | ss.WriteLine(".dll\" />"); |
461 | } | 408 | } |
462 | else | 409 | else |
463 | { | 410 | { |
464 | ss.WriteLine(".exe\" />"); | 411 | ss.WriteLine(".exe\" />"); |
465 | } | 412 | } |
466 | 413 | ||
467 | ss.WriteLine(" </assemblies>"); | 414 | ss.WriteLine(" </assemblies>"); |
468 | ss.WriteLine(" <summaries basedir=\"${project::get-base-directory()}\">"); | 415 | ss.WriteLine(" <summaries basedir=\"${project::get-base-directory()}\">"); |
469 | ss.WriteLine(" <include name=\"${build.dir}/${project::get-name()}.xml\"/>"); | 416 | ss.WriteLine(" <include name=\"${build.dir}/${project::get-name()}.xml\"/>"); |
470 | ss.WriteLine(" </summaries>"); | 417 | ss.WriteLine(" </summaries>"); |
471 | ss.WriteLine(" <referencepaths basedir=\"${project::get-base-directory()}\">"); | 418 | ss.WriteLine(" <referencepaths basedir=\"${project::get-base-directory()}\">"); |
472 | ss.WriteLine(" <include name=\"${build.dir}\" />"); | 419 | ss.WriteLine(" <include name=\"${build.dir}\" />"); |
473 | // foreach(ReferenceNode refr in project.References) | 420 | // foreach(ReferenceNode refr in project.References) |
474 | // { | 421 | // { |
475 | // string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReferencePath(solution, refr)), '/'); | 422 | // string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReferencePath(solution, refr)), '/'); |
476 | // if (path != "") | 423 | // if (path != "") |
477 | // { | 424 | // { |
478 | // ss.WriteLine(" <include name=\"{0}\" />", path); | 425 | // ss.WriteLine(" <include name=\"{0}\" />", path); |
479 | // } | 426 | // } |
480 | // } | 427 | // } |
481 | ss.WriteLine(" </referencepaths>"); | 428 | ss.WriteLine(" </referencepaths>"); |
482 | ss.WriteLine(" <documenters>"); | 429 | ss.WriteLine(" <documenters>"); |
483 | ss.WriteLine(" <documenter name=\"MSDN\">"); | 430 | ss.WriteLine(" <documenter name=\"MSDN\">"); |
484 | ss.WriteLine(" <property name=\"OutputDirectory\" value=\"${project::get-base-directory()}/${build.dir}/doc/${project::get-name()}\" />"); | 431 | ss.WriteLine(" <property name=\"OutputDirectory\" value=\"${project::get-base-directory()}/${build.dir}/doc/${project::get-name()}\" />"); |
485 | ss.WriteLine(" <property name=\"OutputTarget\" value=\"${doc.target}\" />"); | 432 | ss.WriteLine(" <property name=\"OutputTarget\" value=\"${doc.target}\" />"); |
486 | ss.WriteLine(" <property name=\"HtmlHelpName\" value=\"${project::get-name()}\" />"); | 433 | ss.WriteLine(" <property name=\"HtmlHelpName\" value=\"${project::get-name()}\" />"); |
487 | ss.WriteLine(" <property name=\"IncludeFavorites\" value=\"False\" />"); | 434 | ss.WriteLine(" <property name=\"IncludeFavorites\" value=\"False\" />"); |
488 | ss.WriteLine(" <property name=\"Title\" value=\"${project::get-name()} SDK Documentation\" />"); | 435 | ss.WriteLine(" <property name=\"Title\" value=\"${project::get-name()} SDK Documentation\" />"); |
489 | ss.WriteLine(" <property name=\"SplitTOCs\" value=\"False\" />"); | 436 | ss.WriteLine(" <property name=\"SplitTOCs\" value=\"False\" />"); |
490 | ss.WriteLine(" <property name=\"DefaulTOC\" value=\"\" />"); | 437 | ss.WriteLine(" <property name=\"DefaulTOC\" value=\"\" />"); |
491 | ss.WriteLine(" <property name=\"ShowVisualBasic\" value=\"True\" />"); | 438 | ss.WriteLine(" <property name=\"ShowVisualBasic\" value=\"True\" />"); |
492 | ss.WriteLine(" <property name=\"AutoDocumentConstructors\" value=\"True\" />"); | 439 | ss.WriteLine(" <property name=\"AutoDocumentConstructors\" value=\"True\" />"); |
493 | ss.WriteLine(" <property name=\"ShowMissingSummaries\" value=\"${build.debug}\" />"); | 440 | ss.WriteLine(" <property name=\"ShowMissingSummaries\" value=\"${build.debug}\" />"); |
494 | ss.WriteLine(" <property name=\"ShowMissingRemarks\" value=\"${build.debug}\" />"); | 441 | ss.WriteLine(" <property name=\"ShowMissingRemarks\" value=\"${build.debug}\" />"); |
495 | ss.WriteLine(" <property name=\"ShowMissingParams\" value=\"${build.debug}\" />"); | 442 | ss.WriteLine(" <property name=\"ShowMissingParams\" value=\"${build.debug}\" />"); |
496 | ss.WriteLine(" <property name=\"ShowMissingReturns\" value=\"${build.debug}\" />"); | 443 | ss.WriteLine(" <property name=\"ShowMissingReturns\" value=\"${build.debug}\" />"); |
497 | ss.WriteLine(" <property name=\"ShowMissingValues\" value=\"${build.debug}\" />"); | 444 | ss.WriteLine(" <property name=\"ShowMissingValues\" value=\"${build.debug}\" />"); |
498 | ss.WriteLine(" <property name=\"DocumentInternals\" value=\"False\" />"); | 445 | ss.WriteLine(" <property name=\"DocumentInternals\" value=\"False\" />"); |
499 | ss.WriteLine(" <property name=\"DocumentPrivates\" value=\"False\" />"); | 446 | ss.WriteLine(" <property name=\"DocumentPrivates\" value=\"False\" />"); |
500 | ss.WriteLine(" <property name=\"DocumentProtected\" value=\"True\" />"); | 447 | ss.WriteLine(" <property name=\"DocumentProtected\" value=\"True\" />"); |
501 | ss.WriteLine(" <property name=\"DocumentEmptyNamespaces\" value=\"${build.debug}\" />"); | 448 | ss.WriteLine(" <property name=\"DocumentEmptyNamespaces\" value=\"${build.debug}\" />"); |
502 | ss.WriteLine(" <property name=\"IncludeAssemblyVersion\" value=\"True\" />"); | 449 | ss.WriteLine(" <property name=\"IncludeAssemblyVersion\" value=\"True\" />"); |
503 | ss.WriteLine(" </documenter>"); | 450 | ss.WriteLine(" </documenter>"); |
504 | ss.WriteLine(" </documenters>"); | 451 | ss.WriteLine(" </documenters>"); |
505 | ss.WriteLine(" </ndoc>"); | 452 | ss.WriteLine(" </ndoc>"); |
506 | } | 453 | } |
507 | ss.WriteLine(" </target>"); | 454 | ss.WriteLine(" </target>"); |
508 | ss.WriteLine("</project>"); | 455 | ss.WriteLine("</project>"); |
509 | } | 456 | } |
510 | m_Kernel.CurrentWorkingDirectory.Pop(); | 457 | m_Kernel.CurrentWorkingDirectory.Pop(); |
511 | } | 458 | } |
512 | 459 | ||
513 | private void WriteCombine(SolutionNode solution) | 460 | private void WriteCombine(SolutionNode solution) |
514 | { | 461 | { |
515 | m_Kernel.Log.Write("Creating NAnt build files"); | 462 | m_Kernel.Log.Write("Creating NAnt build files"); |
516 | foreach (ProjectNode project in solution.Projects) | 463 | foreach (ProjectNode project in solution.Projects) |
517 | { | 464 | { |
518 | if (m_Kernel.AllowProject(project.FilterGroups)) | 465 | if (m_Kernel.AllowProject(project.FilterGroups)) |
519 | { | 466 | { |
520 | m_Kernel.Log.Write("...Creating project: {0}", project.Name); | 467 | m_Kernel.Log.Write("...Creating project: {0}", project.Name); |
521 | WriteProject(solution, project); | 468 | WriteProject(solution, project); |
522 | } | 469 | } |
523 | } | 470 | } |
524 | 471 | ||
525 | m_Kernel.Log.Write(""); | 472 | m_Kernel.Log.Write(""); |
526 | string combFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "build"); | 473 | string combFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "build"); |
527 | StreamWriter ss = new StreamWriter(combFile); | 474 | StreamWriter ss = new StreamWriter(combFile); |
528 | 475 | ||
529 | m_Kernel.CurrentWorkingDirectory.Push(); | 476 | m_Kernel.CurrentWorkingDirectory.Push(); |
530 | Helper.SetCurrentDir(Path.GetDirectoryName(combFile)); | 477 | Helper.SetCurrentDir(Path.GetDirectoryName(combFile)); |
531 | 478 | ||
532 | using (ss) | 479 | using (ss) |
533 | { | 480 | { |
534 | ss.WriteLine("<?xml version=\"1.0\" ?>"); | 481 | ss.WriteLine("<?xml version=\"1.0\" ?>"); |
535 | ss.WriteLine("<project name=\"{0}\" default=\"build\">", solution.Name); | 482 | ss.WriteLine("<project name=\"{0}\" default=\"build\">", solution.Name); |
536 | ss.WriteLine(" <echo message=\"Using '${nant.settings.currentframework}' Framework\"/>"); | 483 | ss.WriteLine(" <echo message=\"Using '${nant.settings.currentframework}' Framework\"/>"); |
537 | ss.WriteLine(); | 484 | ss.WriteLine(); |
538 | 485 | ||
539 | //ss.WriteLine(" <property name=\"dist.dir\" value=\"dist\" />"); | 486 | //ss.WriteLine(" <property name=\"dist.dir\" value=\"dist\" />"); |
540 | //ss.WriteLine(" <property name=\"source.dir\" value=\"source\" />"); | 487 | //ss.WriteLine(" <property name=\"source.dir\" value=\"source\" />"); |
541 | ss.WriteLine(" <property name=\"bin.dir\" value=\"bin\" />"); | 488 | ss.WriteLine(" <property name=\"bin.dir\" value=\"bin\" />"); |
542 | ss.WriteLine(" <property name=\"obj.dir\" value=\"obj\" />"); | 489 | ss.WriteLine(" <property name=\"obj.dir\" value=\"obj\" />"); |
543 | ss.WriteLine(" <property name=\"doc.dir\" value=\"doc\" />"); | 490 | ss.WriteLine(" <property name=\"doc.dir\" value=\"doc\" />"); |
544 | ss.WriteLine(" <property name=\"project.main.dir\" value=\"${project::get-base-directory()}\" />"); | 491 | ss.WriteLine(" <property name=\"project.main.dir\" value=\"${project::get-base-directory()}\" />"); |
545 | 492 | ||
546 | // actually use active config out of prebuild.xml | 493 | // actually use active config out of prebuild.xml |
547 | ss.WriteLine(" <property name=\"project.config\" value=\"{0}\" />", solution.ActiveConfig); | 494 | ss.WriteLine(" <property name=\"project.config\" value=\"{0}\" />", solution.ActiveConfig); |
548 | 495 | ||
549 | foreach (ConfigurationNode conf in solution.Configurations) | 496 | foreach (ConfigurationNode conf in solution.Configurations) |
550 | { | 497 | { |
551 | ss.WriteLine(); | 498 | ss.WriteLine(); |
552 | ss.WriteLine(" <target name=\"{0}\" description=\"\">", conf.Name); | 499 | ss.WriteLine(" <target name=\"{0}\" description=\"\">", conf.Name); |
553 | ss.WriteLine(" <property name=\"project.config\" value=\"{0}\" />", conf.Name); | 500 | ss.WriteLine(" <property name=\"project.config\" value=\"{0}\" />", conf.Name); |
554 | ss.WriteLine(" <property name=\"build.debug\" value=\"{0}\" />", conf.Options["DebugInformation"].ToString().ToLower()); | 501 | ss.WriteLine(" <property name=\"build.debug\" value=\"{0}\" />", conf.Options["DebugInformation"].ToString().ToLower()); |
555 | ss.WriteLine(" </target>"); | 502 | ss.WriteLine(" </target>"); |
556 | ss.WriteLine(); | 503 | ss.WriteLine(); |
557 | } | 504 | } |
558 | 505 | ||
559 | ss.WriteLine(" <target name=\"net-1.1\" description=\"Sets framework to .NET 1.1\">"); | 506 | ss.WriteLine(" <target name=\"net-1.1\" description=\"Sets framework to .NET 1.1\">"); |
560 | ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"net-1.1\" />"); | 507 | ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"net-1.1\" />"); |
561 | ss.WriteLine(" </target>"); | 508 | ss.WriteLine(" </target>"); |
562 | ss.WriteLine(); | 509 | ss.WriteLine(); |
563 | 510 | ||
564 | ss.WriteLine(" <target name=\"net-2.0\" description=\"Sets framework to .NET 2.0\">"); | 511 | ss.WriteLine(" <target name=\"net-2.0\" description=\"Sets framework to .NET 2.0\">"); |
565 | ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"net-2.0\" />"); | 512 | ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"net-2.0\" />"); |
566 | ss.WriteLine(" </target>"); | 513 | ss.WriteLine(" </target>"); |
567 | ss.WriteLine(); | 514 | ss.WriteLine(); |
568 | 515 | ||
569 | ss.WriteLine(" <target name=\"mono-2.0\" description=\"Sets framework to mono 2.0\">"); | 516 | ss.WriteLine(" <target name=\"net-3.5\" description=\"Sets framework to .NET 3.5\">"); |
570 | ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"mono-2.0\" />"); | 517 | ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"net-3.5\" />"); |
571 | ss.WriteLine(" </target>"); | 518 | ss.WriteLine(" </target>"); |
572 | ss.WriteLine(); | 519 | ss.WriteLine(); |
573 | 520 | ||
574 | ss.WriteLine(" <target name=\"mono-1.0\" description=\"Sets framework to mono 1.0\">"); | 521 | ss.WriteLine(" <target name=\"mono-1.0\" description=\"Sets framework to mono 1.0\">"); |
575 | ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"mono-1.0\" />"); | 522 | ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"mono-1.0\" />"); |
576 | ss.WriteLine(" </target>"); | 523 | ss.WriteLine(" </target>"); |
577 | ss.WriteLine(); | 524 | ss.WriteLine(); |
525 | |||
526 | ss.WriteLine(" <target name=\"mono-2.0\" description=\"Sets framework to mono 2.0\">"); | ||
527 | ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"mono-2.0\" />"); | ||
528 | ss.WriteLine(" </target>"); | ||
529 | ss.WriteLine(); | ||
530 | |||
531 | ss.WriteLine(" <target name=\"mono-3.5\" description=\"Sets framework to mono 3.5\">"); | ||
532 | ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"mono-3.5\" />"); | ||
533 | ss.WriteLine(" </target>"); | ||
534 | ss.WriteLine(); | ||
578 | 535 | ||
579 | ss.WriteLine(" <target name=\"init\" description=\"\">"); | 536 | ss.WriteLine(" <target name=\"init\" description=\"\">"); |
580 | ss.WriteLine(" <call target=\"${project.config}\" />"); | 537 | ss.WriteLine(" <call target=\"${project.config}\" />"); |
diff --git a/Prebuild/src/Core/Targets/SharpDevelop2Target.cs b/Prebuild/src/Core/Targets/SharpDevelop2Target.cs index 0d78796..66dd1bc 100644 --- a/Prebuild/src/Core/Targets/SharpDevelop2Target.cs +++ b/Prebuild/src/Core/Targets/SharpDevelop2Target.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: jendave $ | ||
30 | * $Date: 2006-01-27 16:49:58 -0800 (Fri, 27 Jan 2006) $ | ||
31 | * $Revision: 71 $ | ||
32 | */ | ||
33 | #endregion | ||
34 | |||
35 | using System; | 26 | using System; |
36 | 27 | ||
37 | using Prebuild.Core.Attributes; | 28 | using Prebuild.Core.Attributes; |
@@ -43,18 +34,38 @@ namespace Prebuild.Core.Targets | |||
43 | /// </summary> | 34 | /// </summary> |
44 | [Target("sharpdev2")] | 35 | [Target("sharpdev2")] |
45 | public class SharpDevelop2Target : VS2005Target | 36 | public class SharpDevelop2Target : VS2005Target |
46 | { | 37 | { |
47 | protected override string VersionName | 38 | #region Properties |
39 | public override string VersionName | ||
48 | { | 40 | { |
49 | get | 41 | get |
50 | { | 42 | { |
51 | return "SharpDevelop2"; | 43 | return "SharpDevelop2"; |
52 | } | 44 | } |
53 | } | 45 | } |
46 | #endregion | ||
54 | 47 | ||
55 | #region Public Methods | 48 | #region Public Methods |
56 | 49 | ||
57 | /// <summary> | 50 | /// <summary> |
51 | /// Writes the specified kern. | ||
52 | /// </summary> | ||
53 | /// <param name="kern">The kern.</param> | ||
54 | public override void Write(Kernel kern) | ||
55 | { | ||
56 | base.Write(kern); | ||
57 | } | ||
58 | |||
59 | /// <summary> | ||
60 | /// Cleans the specified kern. | ||
61 | /// </summary> | ||
62 | /// <param name="kern">The kern.</param> | ||
63 | public override void Clean(Kernel kern) | ||
64 | { | ||
65 | base.Clean(kern); | ||
66 | } | ||
67 | |||
68 | /// <summary> | ||
58 | /// Gets the name. | 69 | /// Gets the name. |
59 | /// </summary> | 70 | /// </summary> |
60 | /// <value>The name.</value> | 71 | /// <value>The name.</value> |
diff --git a/Prebuild/src/Core/Targets/SharpDevelopTarget.cs b/Prebuild/src/Core/Targets/SharpDevelopTarget.cs index 6fe038b..cf7ce02 100644 --- a/Prebuild/src/Core/Targets/SharpDevelopTarget.cs +++ b/Prebuild/src/Core/Targets/SharpDevelopTarget.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: jendave $ | ||
30 | * $Date: 2007-02-14 05:58:03 +0900 (Wed, 14 Feb 2007) $ | ||
31 | * $Revision: 205 $ | ||
32 | */ | ||
33 | #endregion | ||
34 | |||
35 | using System; | 26 | using System; |
36 | using System.Collections; | 27 | using System.Collections; |
37 | using System.Collections.Specialized; | 28 | using System.Collections.Specialized; |
diff --git a/Prebuild/src/Core/Targets/ToolInfo.cs b/Prebuild/src/Core/Targets/ToolInfo.cs new file mode 100644 index 0000000..935c674 --- /dev/null +++ b/Prebuild/src/Core/Targets/ToolInfo.cs | |||
@@ -0,0 +1,197 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | |||
5 | namespace Prebuild.Core.Targets | ||
6 | { | ||
7 | /// <summary> | ||
8 | /// | ||
9 | /// </summary> | ||
10 | public struct ToolInfo | ||
11 | { | ||
12 | string name; | ||
13 | string guid; | ||
14 | string fileExtension; | ||
15 | string xmlTag; | ||
16 | string importProject; | ||
17 | |||
18 | /// <summary> | ||
19 | /// Gets or sets the name. | ||
20 | /// </summary> | ||
21 | /// <value>The name.</value> | ||
22 | public string Name | ||
23 | { | ||
24 | get | ||
25 | { | ||
26 | return name; | ||
27 | } | ||
28 | set | ||
29 | { | ||
30 | name = value; | ||
31 | } | ||
32 | } | ||
33 | |||
34 | /// <summary> | ||
35 | /// Gets or sets the GUID. | ||
36 | /// </summary> | ||
37 | /// <value>The GUID.</value> | ||
38 | public string Guid | ||
39 | { | ||
40 | get | ||
41 | { | ||
42 | return guid; | ||
43 | } | ||
44 | set | ||
45 | { | ||
46 | guid = value; | ||
47 | } | ||
48 | } | ||
49 | |||
50 | /// <summary> | ||
51 | /// Gets or sets the file extension. | ||
52 | /// </summary> | ||
53 | /// <value>The file extension.</value> | ||
54 | public string FileExtension | ||
55 | { | ||
56 | get | ||
57 | { | ||
58 | return fileExtension; | ||
59 | } | ||
60 | set | ||
61 | { | ||
62 | fileExtension = value; | ||
63 | } | ||
64 | } | ||
65 | public string LanguageExtension | ||
66 | { | ||
67 | get | ||
68 | { | ||
69 | switch (this.Name) | ||
70 | { | ||
71 | case "C#": | ||
72 | return ".cs"; | ||
73 | case "VisualBasic": | ||
74 | return ".vb"; | ||
75 | case "Boo": | ||
76 | return ".boo"; | ||
77 | default: | ||
78 | return ".cs"; | ||
79 | } | ||
80 | } | ||
81 | } | ||
82 | /// <summary> | ||
83 | /// Gets or sets the XML tag. | ||
84 | /// </summary> | ||
85 | /// <value>The XML tag.</value> | ||
86 | public string XmlTag | ||
87 | { | ||
88 | get | ||
89 | { | ||
90 | return xmlTag; | ||
91 | } | ||
92 | set | ||
93 | { | ||
94 | xmlTag = value; | ||
95 | } | ||
96 | } | ||
97 | |||
98 | /// <summary> | ||
99 | /// Gets or sets the import project property. | ||
100 | /// </summary> | ||
101 | /// <value>The ImportProject tag.</value> | ||
102 | public string ImportProject | ||
103 | { | ||
104 | get | ||
105 | { | ||
106 | return importProject; | ||
107 | } | ||
108 | set | ||
109 | { | ||
110 | importProject = value; | ||
111 | } | ||
112 | } | ||
113 | |||
114 | /// <summary> | ||
115 | /// Initializes a new instance of the <see cref="ToolInfo"/> class. | ||
116 | /// </summary> | ||
117 | /// <param name="name">The name.</param> | ||
118 | /// <param name="guid">The GUID.</param> | ||
119 | /// <param name="fileExtension">The file extension.</param> | ||
120 | /// <param name="xml">The XML.</param> | ||
121 | /// <param name="importProject">The import project.</param> | ||
122 | public ToolInfo(string name, string guid, string fileExtension, string xml, string importProject) | ||
123 | { | ||
124 | this.name = name; | ||
125 | this.guid = guid; | ||
126 | this.fileExtension = fileExtension; | ||
127 | this.xmlTag = xml; | ||
128 | this.importProject = importProject; | ||
129 | } | ||
130 | |||
131 | /// <summary> | ||
132 | /// Initializes a new instance of the <see cref="ToolInfo"/> class. | ||
133 | /// </summary> | ||
134 | /// <param name="name">The name.</param> | ||
135 | /// <param name="guid">The GUID.</param> | ||
136 | /// <param name="fileExtension">The file extension.</param> | ||
137 | /// <param name="xml">The XML.</param> | ||
138 | public ToolInfo(string name, string guid, string fileExtension, string xml) | ||
139 | { | ||
140 | this.name = name; | ||
141 | this.guid = guid; | ||
142 | this.fileExtension = fileExtension; | ||
143 | this.xmlTag = xml; | ||
144 | this.importProject = "$(MSBuildBinPath)\\Microsoft." + xml + ".Targets"; | ||
145 | } | ||
146 | |||
147 | /// <summary> | ||
148 | /// Equals operator | ||
149 | /// </summary> | ||
150 | /// <param name="obj">ToolInfo to compare</param> | ||
151 | /// <returns>true if toolInfos are equal</returns> | ||
152 | public override bool Equals(object obj) | ||
153 | { | ||
154 | if (obj == null) | ||
155 | { | ||
156 | throw new ArgumentNullException("obj"); | ||
157 | } | ||
158 | if (obj.GetType() != typeof(ToolInfo)) | ||
159 | return false; | ||
160 | |||
161 | ToolInfo c = (ToolInfo)obj; | ||
162 | return ((this.name == c.name) && (this.guid == c.guid) && (this.fileExtension == c.fileExtension) && (this.importProject == c.importProject)); | ||
163 | } | ||
164 | |||
165 | /// <summary> | ||
166 | /// Equals operator | ||
167 | /// </summary> | ||
168 | /// <param name="c1">ToolInfo to compare</param> | ||
169 | /// <param name="c2">ToolInfo to compare</param> | ||
170 | /// <returns>True if toolInfos are equal</returns> | ||
171 | public static bool operator ==(ToolInfo c1, ToolInfo c2) | ||
172 | { | ||
173 | return ((c1.name == c2.name) && (c1.guid == c2.guid) && (c1.fileExtension == c2.fileExtension) && (c1.importProject == c2.importProject) && (c1.xmlTag == c2.xmlTag)); | ||
174 | } | ||
175 | |||
176 | /// <summary> | ||
177 | /// Not equals operator | ||
178 | /// </summary> | ||
179 | /// <param name="c1">ToolInfo to compare</param> | ||
180 | /// <param name="c2">ToolInfo to compare</param> | ||
181 | /// <returns>True if toolInfos are not equal</returns> | ||
182 | public static bool operator !=(ToolInfo c1, ToolInfo c2) | ||
183 | { | ||
184 | return !(c1 == c2); | ||
185 | } | ||
186 | |||
187 | /// <summary> | ||
188 | /// Hash Code | ||
189 | /// </summary> | ||
190 | /// <returns>Hash code</returns> | ||
191 | public override int GetHashCode() | ||
192 | { | ||
193 | return name.GetHashCode() ^ guid.GetHashCode() ^ this.fileExtension.GetHashCode() ^ this.importProject.GetHashCode() ^ this.xmlTag.GetHashCode(); | ||
194 | |||
195 | } | ||
196 | } | ||
197 | } | ||
diff --git a/Prebuild/src/Core/Targets/VS2002Target.cs b/Prebuild/src/Core/Targets/VS2002Target.cs index 7067cf3..2292624 100644 --- a/Prebuild/src/Core/Targets/VS2002Target.cs +++ b/Prebuild/src/Core/Targets/VS2002Target.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: jendave $ | ||
30 | * $Date: 2006-01-28 09:49:58 +0900 (Sat, 28 Jan 2006) $ | ||
31 | * $Revision: 71 $ | ||
32 | */ | ||
33 | #endregion | ||
34 | |||
35 | using System; | 26 | using System; |
36 | 27 | ||
37 | using Prebuild.Core.Attributes; | 28 | using Prebuild.Core.Attributes; |
diff --git a/Prebuild/src/Core/Targets/VS2003Target.cs b/Prebuild/src/Core/Targets/VS2003Target.cs index 4bf05cb..1bcb7dc 100644 --- a/Prebuild/src/Core/Targets/VS2003Target.cs +++ b/Prebuild/src/Core/Targets/VS2003Target.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: jendave $ | ||
30 | * $Date: 2006-09-30 04:11:40 +0900 (Sat, 30 Sep 2006) $ | ||
31 | * $Revision: 177 $ | ||
32 | */ | ||
33 | #endregion | ||
34 | |||
35 | using System; | 26 | using System; |
36 | using System.Collections; | 27 | using System.Collections; |
37 | using System.Collections.Specialized; | 28 | using System.Collections.Specialized; |
@@ -44,28 +35,6 @@ using Prebuild.Core.Utilities; | |||
44 | 35 | ||
45 | namespace Prebuild.Core.Targets | 36 | namespace Prebuild.Core.Targets |
46 | { | 37 | { |
47 | /// <summary> | ||
48 | /// | ||
49 | /// </summary> | ||
50 | public enum VSVersion | ||
51 | { | ||
52 | /// <summary> | ||
53 | /// | ||
54 | /// </summary> | ||
55 | VS70, | ||
56 | /// <summary> | ||
57 | /// | ||
58 | /// </summary> | ||
59 | VS71, | ||
60 | /// <summary> | ||
61 | /// | ||
62 | /// </summary> | ||
63 | VS80 | ||
64 | } | ||
65 | |||
66 | /// <summary> | ||
67 | /// | ||
68 | /// </summary> | ||
69 | [Target("vs2003")] | 38 | [Target("vs2003")] |
70 | public class VS2003Target : ITarget | 39 | public class VS2003Target : ITarget |
71 | { | 40 | { |
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 | |||
35 | using System; | 26 | using System; |
36 | using System.Collections; | 27 | using System.Collections; |
37 | using System.Collections.Specialized; | 28 | using 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 |
diff --git a/Prebuild/src/Core/Targets/VS2008Target.cs b/Prebuild/src/Core/Targets/VS2008Target.cs index 88bb5e6..f30017b 100644 --- a/Prebuild/src/Core/Targets/VS2008Target.cs +++ b/Prebuild/src/Core/Targets/VS2008Target.cs | |||
@@ -1,56 +1,132 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections; |
3 | using System.Collections.Specialized; | ||
4 | using System.IO; | ||
3 | using System.Text; | 5 | using System.Text; |
6 | |||
4 | using Prebuild.Core.Attributes; | 7 | using Prebuild.Core.Attributes; |
8 | using Prebuild.Core.Interfaces; | ||
9 | using Prebuild.Core.Nodes; | ||
10 | using Prebuild.Core.Utilities; | ||
11 | using System.CodeDom.Compiler; | ||
5 | 12 | ||
6 | namespace Prebuild.Core.Targets | 13 | namespace Prebuild.Core.Targets |
7 | { | 14 | { |
8 | [Target("vs2008")] | ||
9 | public class VS2008Target : VS2005Target | ||
10 | { | ||
11 | protected override string SolutionTag | ||
12 | { | ||
13 | get { return "# Visual Studio 2008"; } | ||
14 | } | ||
15 | 15 | ||
16 | protected override string SolutionVersion | 16 | /// <summary> |
17 | { | 17 | /// |
18 | get | 18 | /// </summary> |
19 | { | 19 | [Target("vs2008")] |
20 | return "10.00"; | 20 | public class VS2008Target : VSGenericTarget |
21 | } | 21 | { |
22 | } | 22 | #region Fields |
23 | string solutionVersion = "10.00"; | ||
24 | string productVersion = "9.0.21022"; | ||
25 | string schemaVersion = "2.0"; | ||
26 | string versionName = "Visual Studio 2008"; | ||
27 | string name = "vs2008"; | ||
28 | VSVersion version = VSVersion.VS90; | ||
23 | 29 | ||
24 | protected override string VersionName | 30 | Hashtable tools; |
25 | { | 31 | Kernel kernel; |
26 | get | ||
27 | { | ||
28 | return "Visual C# 2008"; | ||
29 | } | ||
30 | } | ||
31 | 32 | ||
32 | protected override string ToolsVersionXml | 33 | /// <summary> |
33 | { | 34 | /// Gets or sets the solution version. |
34 | get | 35 | /// </summary> |
35 | { | 36 | /// <value>The solution version.</value> |
36 | return " ToolsVersion=\"3.5\""; | 37 | public override string SolutionVersion |
37 | } | 38 | { |
38 | } | 39 | get |
40 | { | ||
41 | return solutionVersion; | ||
42 | } | ||
43 | } | ||
44 | /// <summary> | ||
45 | /// Gets or sets the product version. | ||
46 | /// </summary> | ||
47 | /// <value>The product version.</value> | ||
48 | public override string ProductVersion | ||
49 | { | ||
50 | get | ||
51 | { | ||
52 | return productVersion; | ||
53 | } | ||
54 | } | ||
55 | /// <summary> | ||
56 | /// Gets or sets the schema version. | ||
57 | /// </summary> | ||
58 | /// <value>The schema version.</value> | ||
59 | public override string SchemaVersion | ||
60 | { | ||
61 | get | ||
62 | { | ||
63 | return schemaVersion; | ||
64 | } | ||
65 | } | ||
66 | /// <summary> | ||
67 | /// Gets or sets the name of the version. | ||
68 | /// </summary> | ||
69 | /// <value>The name of the version.</value> | ||
70 | public override string VersionName | ||
71 | { | ||
72 | get | ||
73 | { | ||
74 | return versionName; | ||
75 | } | ||
76 | } | ||
77 | /// <summary> | ||
78 | /// Gets or sets the version. | ||
79 | /// </summary> | ||
80 | /// <value>The version.</value> | ||
81 | public override VSVersion Version | ||
82 | { | ||
83 | get | ||
84 | { | ||
85 | return version; | ||
86 | } | ||
87 | } | ||
88 | /// <summary> | ||
89 | /// Gets the name. | ||
90 | /// </summary> | ||
91 | /// <value>The name.</value> | ||
92 | public override string Name | ||
93 | { | ||
94 | get | ||
95 | { | ||
96 | return name; | ||
97 | } | ||
98 | } | ||
39 | 99 | ||
40 | protected override string ProductVersion | 100 | protected override string GetToolsVersionXml(FrameworkVersion frameworkVersion) |
41 | { | 101 | { |
42 | get | 102 | switch (frameworkVersion) |
43 | { | 103 | { |
44 | return "9.0.21022"; | 104 | case FrameworkVersion.v3_5: |
105 | return "ToolsVersion=\"3.5\""; | ||
106 | case FrameworkVersion.v3_0: | ||
107 | return "ToolsVersion=\"3.0\""; | ||
108 | default: | ||
109 | return "ToolsVersion=\"2.0\""; | ||
45 | } | 110 | } |
46 | } | 111 | } |
47 | 112 | ||
48 | public override string Name | 113 | public override string SolutionTag |
49 | { | 114 | { |
50 | get | 115 | get { return "# Visual Studio 2008"; } |
51 | { | ||
52 | return "vs2008"; | ||
53 | } | ||
54 | } | 116 | } |
55 | } | 117 | |
118 | #endregion | ||
119 | |||
120 | #region Constructors | ||
121 | |||
122 | /// <summary> | ||
123 | /// Initializes a new instance of the <see cref="VS2005Target"/> class. | ||
124 | /// </summary> | ||
125 | public VS2008Target() | ||
126 | : base() | ||
127 | { | ||
128 | } | ||
129 | |||
130 | #endregion | ||
131 | } | ||
56 | } | 132 | } |
diff --git a/Prebuild/src/Core/Targets/VSGenericTarget.cs b/Prebuild/src/Core/Targets/VSGenericTarget.cs new file mode 100644 index 0000000..a05f6b3 --- /dev/null +++ b/Prebuild/src/Core/Targets/VSGenericTarget.cs | |||
@@ -0,0 +1,884 @@ | |||
1 | #region BSD License | ||
2 | /* | ||
3 | Copyright (c) 2008 Matthew Holmes (matthew@wildfiregames.com), John Anderson (sontek@gmail.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 | using System; | ||
27 | using System.Collections; | ||
28 | using System.Collections.Generic; | ||
29 | using System.Collections.Specialized; | ||
30 | using System.IO; | ||
31 | using System.Text; | ||
32 | |||
33 | using Prebuild.Core.Attributes; | ||
34 | using Prebuild.Core.Interfaces; | ||
35 | using Prebuild.Core.Nodes; | ||
36 | using Prebuild.Core.Utilities; | ||
37 | using System.CodeDom.Compiler; | ||
38 | |||
39 | namespace Prebuild.Core.Targets | ||
40 | { | ||
41 | |||
42 | /// <summary> | ||
43 | /// | ||
44 | /// </summary> | ||
45 | public abstract class VSGenericTarget : ITarget | ||
46 | { | ||
47 | #region Fields | ||
48 | |||
49 | readonly Hashtable tools = new Hashtable(); | ||
50 | Kernel kernel; | ||
51 | #endregion | ||
52 | |||
53 | #region Properties | ||
54 | /// <summary> | ||
55 | /// Gets or sets the solution version. | ||
56 | /// </summary> | ||
57 | /// <value>The solution version.</value> | ||
58 | public abstract string SolutionVersion { get; } | ||
59 | /// <summary> | ||
60 | /// Gets or sets the product version. | ||
61 | /// </summary> | ||
62 | /// <value>The product version.</value> | ||
63 | public abstract string ProductVersion { get; } | ||
64 | /// <summary> | ||
65 | /// Gets or sets the schema version. | ||
66 | /// </summary> | ||
67 | /// <value>The schema version.</value> | ||
68 | public abstract string SchemaVersion { get; } | ||
69 | /// <summary> | ||
70 | /// Gets or sets the name of the version. | ||
71 | /// </summary> | ||
72 | /// <value>The name of the version.</value> | ||
73 | public abstract string VersionName { get; } | ||
74 | /// <summary> | ||
75 | /// Gets or sets the version. | ||
76 | /// </summary> | ||
77 | /// <value>The version.</value> | ||
78 | public abstract VSVersion Version { get; } | ||
79 | /// <summary> | ||
80 | /// Gets the name. | ||
81 | /// </summary> | ||
82 | /// <value>The name.</value> | ||
83 | public abstract string Name { get; } | ||
84 | |||
85 | protected abstract string GetToolsVersionXml(FrameworkVersion version); | ||
86 | public abstract string SolutionTag { get; } | ||
87 | |||
88 | #endregion | ||
89 | |||
90 | #region Constructors | ||
91 | |||
92 | /// <summary> | ||
93 | /// Initializes a new instance of the <see cref="VSGenericTarget"/> class. | ||
94 | /// </summary> | ||
95 | protected VSGenericTarget() | ||
96 | { | ||
97 | this.tools["C#"] = new ToolInfo("C#", "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}", "csproj", "CSHARP", "$(MSBuildBinPath)\\Microsoft.CSHARP.Targets"); | ||
98 | this.tools["Database"] = new ToolInfo("Database", "{4F174C21-8C12-11D0-8340-0000F80270F8}", "dbp", "UNKNOWN"); | ||
99 | this.tools["Boo"] = new ToolInfo("Boo", "{45CEA7DC-C2ED-48A6-ACE0-E16144C02365}", "booproj", "Boo", "$(BooBinPath)\\Boo.Microsoft.Build.targets"); | ||
100 | this.tools["VisualBasic"] = new ToolInfo("VisualBasic", "{F184B08F-C81C-45F6-A57F-5ABD9991F28F}", "vbproj", "VisualBasic", "$(MSBuildBinPath)\\Microsoft.VisualBasic.Targets"); | ||
101 | this.tools["Folder"] = new ToolInfo("Folder", "{2150E333-8FDC-42A3-9474-1A3956D46DE8}", null, null); | ||
102 | } | ||
103 | |||
104 | #endregion | ||
105 | |||
106 | #region Private Methods | ||
107 | |||
108 | private string MakeRefPath(ProjectNode project) | ||
109 | { | ||
110 | string ret = ""; | ||
111 | foreach (ReferencePathNode node in project.ReferencePaths) | ||
112 | { | ||
113 | try | ||
114 | { | ||
115 | string fullPath = Helper.ResolvePath(node.Path); | ||
116 | if (ret.Length < 1) | ||
117 | { | ||
118 | ret = fullPath; | ||
119 | } | ||
120 | else | ||
121 | { | ||
122 | ret += ";" + fullPath; | ||
123 | } | ||
124 | } | ||
125 | catch (ArgumentException) | ||
126 | { | ||
127 | this.kernel.Log.Write(LogType.Warning, "Could not resolve reference path: {0}", node.Path); | ||
128 | } | ||
129 | } | ||
130 | |||
131 | return ret; | ||
132 | } | ||
133 | |||
134 | private static ProjectNode FindProjectInSolution(string name, SolutionNode solution) | ||
135 | { | ||
136 | SolutionNode node = solution; | ||
137 | |||
138 | while (node.Parent is SolutionNode) | ||
139 | node = node.Parent as SolutionNode; | ||
140 | |||
141 | return FindProjectInSolutionRecursively(name, node); | ||
142 | } | ||
143 | |||
144 | private static ProjectNode FindProjectInSolutionRecursively(string name, SolutionNode solution) | ||
145 | { | ||
146 | if (solution.ProjectsTable.ContainsKey(name)) | ||
147 | return (ProjectNode)solution.ProjectsTable[name]; | ||
148 | |||
149 | foreach (SolutionNode child in solution.Solutions) | ||
150 | { | ||
151 | ProjectNode node = FindProjectInSolutionRecursively(name, child); | ||
152 | if (node != null) | ||
153 | return node; | ||
154 | } | ||
155 | |||
156 | return null; | ||
157 | } | ||
158 | |||
159 | private void WriteProject(SolutionNode solution, ProjectNode project) | ||
160 | { | ||
161 | if (!tools.ContainsKey(project.Language)) | ||
162 | { | ||
163 | throw new UnknownLanguageException("Unknown .NET language: " + project.Language); | ||
164 | } | ||
165 | |||
166 | ToolInfo toolInfo = (ToolInfo)tools[project.Language]; | ||
167 | string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); | ||
168 | StreamWriter ps = new StreamWriter(projectFile); | ||
169 | |||
170 | kernel.CurrentWorkingDirectory.Push(); | ||
171 | Helper.SetCurrentDir(Path.GetDirectoryName(projectFile)); | ||
172 | |||
173 | #region Project File | ||
174 | using (ps) | ||
175 | { | ||
176 | ps.WriteLine("<Project DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\" {0}>", GetToolsVersionXml(project.FrameworkVersion)); | ||
177 | ps.WriteLine(" <PropertyGroup>"); | ||
178 | ps.WriteLine(" <ProjectType>Local</ProjectType>"); | ||
179 | ps.WriteLine(" <ProductVersion>{0}</ProductVersion>", this.ProductVersion); | ||
180 | ps.WriteLine(" <SchemaVersion>{0}</SchemaVersion>", this.SchemaVersion); | ||
181 | ps.WriteLine(" <ProjectGuid>{{{0}}}</ProjectGuid>", project.Guid.ToString().ToUpper()); | ||
182 | |||
183 | // Visual Studio has a hard coded guid for the project type | ||
184 | if (project.Type == ProjectType.Web) | ||
185 | ps.WriteLine(" <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>"); | ||
186 | ps.WriteLine(" <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>"); | ||
187 | ps.WriteLine(" <Platform Condition=\" '$(Platform)' == '' \">AnyCPU</Platform>"); | ||
188 | ps.WriteLine(" <ApplicationIcon>{0}</ApplicationIcon>", project.AppIcon); | ||
189 | ps.WriteLine(" <AssemblyKeyContainerName>"); | ||
190 | ps.WriteLine(" </AssemblyKeyContainerName>"); | ||
191 | ps.WriteLine(" <AssemblyName>{0}</AssemblyName>", project.AssemblyName); | ||
192 | foreach (ConfigurationNode conf in project.Configurations) | ||
193 | { | ||
194 | if (conf.Options.KeyFile != "") | ||
195 | { | ||
196 | ps.WriteLine(" <AssemblyOriginatorKeyFile>{0}</AssemblyOriginatorKeyFile>", conf.Options.KeyFile); | ||
197 | ps.WriteLine(" <SignAssembly>true</SignAssembly>"); | ||
198 | break; | ||
199 | } | ||
200 | } | ||
201 | ps.WriteLine(" <DefaultClientScript>JScript</DefaultClientScript>"); | ||
202 | ps.WriteLine(" <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>"); | ||
203 | ps.WriteLine(" <DefaultTargetSchema>IE50</DefaultTargetSchema>"); | ||
204 | ps.WriteLine(" <DelaySign>false</DelaySign>"); | ||
205 | ps.WriteLine(" <TargetFrameworkVersion>{0}</TargetFrameworkVersion>", project.FrameworkVersion.ToString().Replace("_", ".")); | ||
206 | |||
207 | ps.WriteLine(" <OutputType>{0}</OutputType>", project.Type == ProjectType.Web ? ProjectType.Library.ToString() : project.Type.ToString()); | ||
208 | ps.WriteLine(" <AppDesignerFolder>{0}</AppDesignerFolder>", project.DesignerFolder); | ||
209 | ps.WriteLine(" <RootNamespace>{0}</RootNamespace>", project.RootNamespace); | ||
210 | ps.WriteLine(" <StartupObject>{0}</StartupObject>", project.StartupObject); | ||
211 | if (string.IsNullOrEmpty(project.DebugStartParameters)) | ||
212 | { | ||
213 | ps.WriteLine(" <StartArguments>{0}</StartArguments>", project.DebugStartParameters); | ||
214 | } | ||
215 | ps.WriteLine(" <FileUpgradeFlags>"); | ||
216 | ps.WriteLine(" </FileUpgradeFlags>"); | ||
217 | |||
218 | ps.WriteLine(" </PropertyGroup>"); | ||
219 | |||
220 | foreach (ConfigurationNode conf in project.Configurations) | ||
221 | { | ||
222 | ps.Write(" <PropertyGroup "); | ||
223 | ps.WriteLine("Condition=\" '$(Configuration)|$(Platform)' == '{0}|AnyCPU' \">", conf.Name); | ||
224 | ps.WriteLine(" <AllowUnsafeBlocks>{0}</AllowUnsafeBlocks>", conf.Options["AllowUnsafe"]); | ||
225 | ps.WriteLine(" <BaseAddress>{0}</BaseAddress>", conf.Options["BaseAddress"]); | ||
226 | ps.WriteLine(" <CheckForOverflowUnderflow>{0}</CheckForOverflowUnderflow>", conf.Options["CheckUnderflowOverflow"]); | ||
227 | ps.WriteLine(" <ConfigurationOverrideFile>"); | ||
228 | ps.WriteLine(" </ConfigurationOverrideFile>"); | ||
229 | ps.WriteLine(" <DefineConstants>{0}</DefineConstants>", conf.Options["CompilerDefines"]); | ||
230 | ps.WriteLine(" <DocumentationFile>{0}</DocumentationFile>", Helper.NormalizePath(conf.Options["XmlDocFile"].ToString())); | ||
231 | ps.WriteLine(" <DebugSymbols>{0}</DebugSymbols>", conf.Options["DebugInformation"]); | ||
232 | ps.WriteLine(" <FileAlignment>{0}</FileAlignment>", conf.Options["FileAlignment"]); | ||
233 | ps.WriteLine(" <Optimize>{0}</Optimize>", conf.Options["OptimizeCode"]); | ||
234 | if (project.Type != ProjectType.Web) | ||
235 | ps.WriteLine(" <OutputPath>{0}</OutputPath>", | ||
236 | Helper.EndPath(Helper.NormalizePath(conf.Options["OutputPath"].ToString()))); | ||
237 | else | ||
238 | ps.WriteLine(" <OutputPath>{0}</OutputPath>", | ||
239 | Helper.EndPath(Helper.NormalizePath("bin\\"))); | ||
240 | |||
241 | ps.WriteLine(" <RegisterForComInterop>{0}</RegisterForComInterop>", conf.Options["RegisterComInterop"]); | ||
242 | ps.WriteLine(" <RemoveIntegerChecks>{0}</RemoveIntegerChecks>", conf.Options["RemoveIntegerChecks"]); | ||
243 | ps.WriteLine(" <TreatWarningsAsErrors>{0}</TreatWarningsAsErrors>", conf.Options["WarningsAsErrors"]); | ||
244 | ps.WriteLine(" <WarningLevel>{0}</WarningLevel>", conf.Options["WarningLevel"]); | ||
245 | ps.WriteLine(" <NoStdLib>{0}</NoStdLib>", conf.Options["NoStdLib"]); | ||
246 | ps.WriteLine(" <NoWarn>{0}</NoWarn>", conf.Options["SuppressWarnings"]); | ||
247 | ps.WriteLine(" </PropertyGroup>"); | ||
248 | } | ||
249 | |||
250 | //ps.WriteLine(" </Settings>"); | ||
251 | |||
252 | List<ProjectNode> projectReferences = new List<ProjectNode>(); | ||
253 | List<ReferenceNode> otherReferences = new List<ReferenceNode>(); | ||
254 | |||
255 | foreach (ReferenceNode refr in project.References) | ||
256 | { | ||
257 | ProjectNode projectNode = FindProjectInSolution(refr.Name, solution); | ||
258 | |||
259 | if (projectNode == null) | ||
260 | otherReferences.Add(refr); | ||
261 | else | ||
262 | projectReferences.Add(projectNode); | ||
263 | } | ||
264 | // Assembly References | ||
265 | ps.WriteLine(" <ItemGroup>"); | ||
266 | |||
267 | foreach (ReferenceNode refr in otherReferences) | ||
268 | { | ||
269 | ps.Write(" <Reference"); | ||
270 | ps.Write(" Include=\""); | ||
271 | ps.Write(refr.Name); | ||
272 | ps.WriteLine("\" >"); | ||
273 | ps.Write(" <Name>"); | ||
274 | ps.Write(refr.Name); | ||
275 | ps.WriteLine("</Name>"); | ||
276 | // TODO: Allow reference to *.exe files | ||
277 | ps.WriteLine(" <Private>{0}</Private>", refr.LocalCopy); | ||
278 | ps.WriteLine(" </Reference>"); | ||
279 | } | ||
280 | ps.WriteLine(" </ItemGroup>"); | ||
281 | |||
282 | //Project References | ||
283 | ps.WriteLine(" <ItemGroup>"); | ||
284 | foreach (ProjectNode projectReference in projectReferences) | ||
285 | { | ||
286 | ToolInfo tool = (ToolInfo)tools[projectReference.Language]; | ||
287 | if (tools == null) | ||
288 | throw new UnknownLanguageException(); | ||
289 | |||
290 | string path = | ||
291 | Helper.MakePathRelativeTo(project.FullPath, | ||
292 | Helper.MakeFilePath(projectReference.FullPath, projectReference.Name, tool.FileExtension)); | ||
293 | ps.WriteLine(" <ProjectReference Include=\"{0}\">", path); | ||
294 | |||
295 | // TODO: Allow reference to visual basic projects | ||
296 | ps.WriteLine(" <Name>{0}</Name>", projectReference.Name); | ||
297 | ps.WriteLine(" <Project>{0}</Project>", projectReference.Guid.ToString("B").ToUpper()); | ||
298 | ps.WriteLine(" <Package>{0}</Package>", tool.Guid.ToUpper()); | ||
299 | |||
300 | ps.WriteLine(" <Private>False</Private>" ); | ||
301 | |||
302 | ps.WriteLine(" </ProjectReference>"); | ||
303 | } | ||
304 | ps.WriteLine(" </ItemGroup>"); | ||
305 | |||
306 | // ps.WriteLine(" </Build>"); | ||
307 | ps.WriteLine(" <ItemGroup>"); | ||
308 | |||
309 | // ps.WriteLine(" <Include>"); | ||
310 | List<string> list = new List<string>(); | ||
311 | |||
312 | foreach (string path in project.Files) | ||
313 | { | ||
314 | string lower = path.ToLower(); | ||
315 | if (lower.EndsWith(".resx")) | ||
316 | { | ||
317 | string codebehind = String.Format("{0}.Designer{1}", path.Substring(0, path.LastIndexOf('.')), toolInfo.LanguageExtension); | ||
318 | if (!list.Contains(codebehind)) | ||
319 | list.Add(codebehind); | ||
320 | } | ||
321 | } | ||
322 | |||
323 | foreach (string file in project.Files) | ||
324 | { | ||
325 | // if (file == "Properties\\Bind.Designer.cs") | ||
326 | // { | ||
327 | // Console.WriteLine("Wait a minute!"); | ||
328 | // Console.WriteLine(project.Files.GetSubType(file).ToString()); | ||
329 | // } | ||
330 | |||
331 | SubType subType = project.Files.GetSubType(file); | ||
332 | |||
333 | if (subType != SubType.Code && subType != SubType.Settings && subType != SubType.Designer | ||
334 | && subType != SubType.CodeBehind) | ||
335 | { | ||
336 | ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".resx"); | ||
337 | ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file)); | ||
338 | ps.WriteLine(" <SubType>Designer</SubType>"); | ||
339 | ps.WriteLine(" </EmbeddedResource>"); | ||
340 | // | ||
341 | } | ||
342 | |||
343 | if (subType == SubType.Designer) | ||
344 | { | ||
345 | ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file); | ||
346 | ps.WriteLine(" <SubType>" + subType + "</SubType>"); | ||
347 | ps.WriteLine(" <Generator>ResXFileCodeGenerator</Generator>"); | ||
348 | |||
349 | string autogen_name = file.Substring(0, file.LastIndexOf('.')) + ".Designer.cs"; | ||
350 | string dependent_name = file.Substring(0, file.LastIndexOf('.')) + ".cs"; | ||
351 | |||
352 | ps.WriteLine(" <LastGenOutput>{0}</LastGenOutput>", autogen_name); | ||
353 | |||
354 | // Check for a parent .cs file with the same name as this designer file | ||
355 | if (File.Exists(dependent_name)) | ||
356 | ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(dependent_name)); | ||
357 | |||
358 | ps.WriteLine(" </EmbeddedResource>"); | ||
359 | if (File.Exists(autogen_name)) | ||
360 | { | ||
361 | ps.WriteLine(" <Compile Include=\"{0}\">", autogen_name); | ||
362 | ps.WriteLine(" <AutoGen>True</AutoGen>"); | ||
363 | ps.WriteLine(" <DesignTime>True</DesignTime>"); | ||
364 | |||
365 | // If a parent .cs file exists, link this autogen file to it. Otherwise link | ||
366 | // to the designer file | ||
367 | if (File.Exists(dependent_name)) | ||
368 | ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(dependent_name)); | ||
369 | else | ||
370 | ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file)); | ||
371 | |||
372 | ps.WriteLine(" </Compile>"); | ||
373 | } | ||
374 | list.Add(autogen_name); | ||
375 | } | ||
376 | if (subType == SubType.Settings) | ||
377 | { | ||
378 | ps.Write(" <{0} ", project.Files.GetBuildAction(file)); | ||
379 | ps.WriteLine("Include=\"{0}\">", file); | ||
380 | string fileName = Path.GetFileName(file); | ||
381 | if (project.Files.GetBuildAction(file) == BuildAction.None) | ||
382 | { | ||
383 | ps.WriteLine(" <Generator>SettingsSingleFileGenerator</Generator>"); | ||
384 | ps.WriteLine(" <LastGenOutput>{0}</LastGenOutput>", fileName.Substring(0, fileName.LastIndexOf('.')) + ".Designer.cs"); | ||
385 | } | ||
386 | else | ||
387 | { | ||
388 | ps.WriteLine(" <SubType>Code</SubType>"); | ||
389 | ps.WriteLine(" <AutoGen>True</AutoGen>"); | ||
390 | ps.WriteLine(" <DesignTimeSharedInput>True</DesignTimeSharedInput>"); | ||
391 | string fileNameShort = fileName.Substring(0, fileName.LastIndexOf('.')); | ||
392 | string fileNameShorter = fileNameShort.Substring(0, fileNameShort.LastIndexOf('.')); | ||
393 | ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(fileNameShorter + ".settings")); | ||
394 | } | ||
395 | ps.WriteLine(" </{0}>", project.Files.GetBuildAction(file)); | ||
396 | } | ||
397 | else if (subType != SubType.Designer) | ||
398 | { | ||
399 | string path = Helper.NormalizePath(file); | ||
400 | string path_lower = path.ToLower(); | ||
401 | |||
402 | if (!list.Contains(file)) | ||
403 | { | ||
404 | ps.Write(" <{0} ", project.Files.GetBuildAction(path)); | ||
405 | |||
406 | int startPos = 0; | ||
407 | if (project.Files.GetPreservePath(file)) | ||
408 | { | ||
409 | while ((@"./\").IndexOf(file.Substring(startPos, 1)) != -1) | ||
410 | startPos++; | ||
411 | |||
412 | } | ||
413 | else | ||
414 | { | ||
415 | startPos = file.LastIndexOf(Path.GetFileName(path)); | ||
416 | } | ||
417 | |||
418 | ps.WriteLine("Include=\"{0}\">", path); | ||
419 | |||
420 | int last_period_index = file.LastIndexOf('.'); | ||
421 | string short_file_name = file.Substring(0, last_period_index); | ||
422 | string extension = Path.GetExtension(path); | ||
423 | string designer_format = string.Format(".designer{0}", extension); | ||
424 | |||
425 | if (path_lower.EndsWith(designer_format)) | ||
426 | { | ||
427 | int designer_index = path_lower.IndexOf(designer_format); | ||
428 | string file_name = path.Substring(0, designer_index); | ||
429 | |||
430 | if (File.Exists(file_name)) | ||
431 | ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file_name)); | ||
432 | else if (File.Exists(file_name + ".resx")) | ||
433 | ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file_name + ".resx")); | ||
434 | } | ||
435 | else if (subType == SubType.CodeBehind) | ||
436 | { | ||
437 | ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(short_file_name)); | ||
438 | } | ||
439 | if (project.Files.GetIsLink(file)) | ||
440 | { | ||
441 | string alias = project.Files.GetLinkPath(file); | ||
442 | alias += file.Substring(startPos); | ||
443 | alias = Helper.NormalizePath(alias); | ||
444 | ps.WriteLine(" <Link>{0}</Link>", alias); | ||
445 | } | ||
446 | else if (project.Files.GetBuildAction(file) != BuildAction.None) | ||
447 | { | ||
448 | if (project.Files.GetBuildAction(file) != BuildAction.EmbeddedResource) | ||
449 | { | ||
450 | ps.WriteLine(" <SubType>{0}</SubType>", subType); | ||
451 | } | ||
452 | } | ||
453 | |||
454 | if (project.Files.GetCopyToOutput(file) != CopyToOutput.Never) | ||
455 | { | ||
456 | ps.WriteLine(" <CopyToOutputDirectory>{0}</CopyToOutputDirectory>", project.Files.GetCopyToOutput(file)); | ||
457 | } | ||
458 | |||
459 | ps.WriteLine(" </{0}>", project.Files.GetBuildAction(file)); | ||
460 | } | ||
461 | } | ||
462 | } | ||
463 | |||
464 | ps.WriteLine(" </ItemGroup>"); | ||
465 | ps.WriteLine(" <Import Project=\"" + toolInfo.ImportProject + "\" />"); | ||
466 | ps.WriteLine(" <PropertyGroup>"); | ||
467 | ps.WriteLine(" <PreBuildEvent>"); | ||
468 | ps.WriteLine(" </PreBuildEvent>"); | ||
469 | ps.WriteLine(" <PostBuildEvent>"); | ||
470 | ps.WriteLine(" </PostBuildEvent>"); | ||
471 | ps.WriteLine(" </PropertyGroup>"); | ||
472 | ps.WriteLine("</Project>"); | ||
473 | } | ||
474 | #endregion | ||
475 | |||
476 | #region User File | ||
477 | |||
478 | ps = new StreamWriter(projectFile + ".user"); | ||
479 | using (ps) | ||
480 | { | ||
481 | ps.WriteLine("<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">"); | ||
482 | //ps.WriteLine( "<VisualStudioProject>" ); | ||
483 | //ps.WriteLine(" <{0}>", toolInfo.XMLTag); | ||
484 | //ps.WriteLine(" <Build>"); | ||
485 | ps.WriteLine(" <PropertyGroup>"); | ||
486 | //ps.WriteLine(" <Settings ReferencePath=\"{0}\">", MakeRefPath(project)); | ||
487 | ps.WriteLine(" <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>"); | ||
488 | ps.WriteLine(" <Platform Condition=\" '$(Platform)' == '' \">AnyCPU</Platform>"); | ||
489 | ps.WriteLine(" <ReferencePath>{0}</ReferencePath>", MakeRefPath(project)); | ||
490 | ps.WriteLine(" <LastOpenVersion>{0}</LastOpenVersion>", this.ProductVersion); | ||
491 | ps.WriteLine(" <ProjectView>ProjectFiles</ProjectView>"); | ||
492 | ps.WriteLine(" <ProjectTrust>0</ProjectTrust>"); | ||
493 | ps.WriteLine(" </PropertyGroup>"); | ||
494 | foreach (ConfigurationNode conf in project.Configurations) | ||
495 | { | ||
496 | ps.Write(" <PropertyGroup"); | ||
497 | ps.Write(" Condition = \" '$(Configuration)|$(Platform)' == '{0}|AnyCPU' \"", conf.Name); | ||
498 | ps.WriteLine(" />"); | ||
499 | } | ||
500 | ps.WriteLine("</Project>"); | ||
501 | } | ||
502 | #endregion | ||
503 | |||
504 | kernel.CurrentWorkingDirectory.Pop(); | ||
505 | } | ||
506 | |||
507 | private void WriteSolution(SolutionNode solution, bool writeSolutionToDisk) | ||
508 | { | ||
509 | kernel.Log.Write("Creating {0} solution and project files", this.VersionName); | ||
510 | |||
511 | foreach (SolutionNode child in solution.Solutions) | ||
512 | { | ||
513 | kernel.Log.Write("...Creating folder: {0}", child.Name); | ||
514 | WriteSolution(child, false); | ||
515 | } | ||
516 | |||
517 | foreach (ProjectNode project in solution.Projects) | ||
518 | { | ||
519 | kernel.Log.Write("...Creating project: {0}", project.Name); | ||
520 | WriteProject(solution, project); | ||
521 | } | ||
522 | |||
523 | foreach (DatabaseProjectNode project in solution.DatabaseProjects) | ||
524 | { | ||
525 | kernel.Log.Write("...Creating database project: {0}", project.Name); | ||
526 | WriteDatabaseProject(solution, project); | ||
527 | } | ||
528 | |||
529 | if (writeSolutionToDisk) // only write main solution | ||
530 | { | ||
531 | kernel.Log.Write(""); | ||
532 | string solutionFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln"); | ||
533 | |||
534 | using (StreamWriter ss = new StreamWriter(solutionFile)) | ||
535 | { | ||
536 | kernel.CurrentWorkingDirectory.Push(); | ||
537 | Helper.SetCurrentDir(Path.GetDirectoryName(solutionFile)); | ||
538 | |||
539 | ss.WriteLine("Microsoft Visual Studio Solution File, Format Version {0}", this.SolutionVersion); | ||
540 | ss.WriteLine(SolutionTag); | ||
541 | |||
542 | WriteProjectDeclarations(ss, solution, solution); | ||
543 | |||
544 | ss.WriteLine("Global"); | ||
545 | |||
546 | ss.WriteLine("\tGlobalSection(SolutionConfigurationPlatforms) = preSolution"); | ||
547 | foreach (ConfigurationNode conf in solution.Configurations) | ||
548 | { | ||
549 | ss.WriteLine("\t\t{0}|Any CPU = {0}|Any CPU", conf.Name); | ||
550 | } | ||
551 | ss.WriteLine("\tEndGlobalSection"); | ||
552 | |||
553 | ss.WriteLine("\tGlobalSection(ProjectConfigurationPlatforms) = postSolution"); | ||
554 | WriteConfigurationLines(solution.Configurations, solution, ss); | ||
555 | ss.WriteLine("\tEndGlobalSection"); | ||
556 | |||
557 | if (solution.Solutions.Count > 0) | ||
558 | { | ||
559 | ss.WriteLine("\tGlobalSection(NestedProjects) = preSolution"); | ||
560 | foreach (SolutionNode embeddedSolution in solution.Solutions) | ||
561 | { | ||
562 | WriteNestedProjectMap(ss, embeddedSolution); | ||
563 | } | ||
564 | ss.WriteLine("\tEndGlobalSection"); | ||
565 | } | ||
566 | |||
567 | ss.WriteLine("EndGlobal"); | ||
568 | } | ||
569 | |||
570 | kernel.CurrentWorkingDirectory.Pop(); | ||
571 | } | ||
572 | } | ||
573 | |||
574 | private void WriteProjectDeclarations(StreamWriter writer, SolutionNode actualSolution, SolutionNode embeddedSolution) | ||
575 | { | ||
576 | foreach (SolutionNode childSolution in embeddedSolution.Solutions) | ||
577 | { | ||
578 | WriteEmbeddedSolution(writer, childSolution); | ||
579 | WriteProjectDeclarations(writer, actualSolution, childSolution); | ||
580 | } | ||
581 | |||
582 | foreach (ProjectNode project in embeddedSolution.Projects) | ||
583 | { | ||
584 | WriteProject(actualSolution, writer, project); | ||
585 | } | ||
586 | |||
587 | foreach (DatabaseProjectNode dbProject in embeddedSolution.DatabaseProjects) | ||
588 | { | ||
589 | WriteProject(actualSolution, writer, dbProject); | ||
590 | } | ||
591 | |||
592 | if (actualSolution.Guid == embeddedSolution.Guid) | ||
593 | { | ||
594 | WriteSolutionFiles(actualSolution, writer); | ||
595 | } | ||
596 | } | ||
597 | |||
598 | private static void WriteNestedProjectMap(StreamWriter writer, SolutionNode embeddedSolution) | ||
599 | { | ||
600 | foreach (ProjectNode project in embeddedSolution.Projects) | ||
601 | { | ||
602 | WriteNestedProject(writer, embeddedSolution, project.Guid); | ||
603 | } | ||
604 | |||
605 | foreach (DatabaseProjectNode dbProject in embeddedSolution.DatabaseProjects) | ||
606 | { | ||
607 | WriteNestedProject(writer, embeddedSolution, dbProject.Guid); | ||
608 | } | ||
609 | |||
610 | foreach (SolutionNode child in embeddedSolution.Solutions) | ||
611 | { | ||
612 | WriteNestedProject(writer, embeddedSolution, child.Guid); | ||
613 | WriteNestedProjectMap(writer, child); | ||
614 | } | ||
615 | } | ||
616 | |||
617 | private static void WriteNestedProject(StreamWriter writer, SolutionNode solution, Guid projectGuid) | ||
618 | { | ||
619 | WriteNestedFolder(writer, solution.Guid, projectGuid); | ||
620 | } | ||
621 | |||
622 | private static void WriteNestedFolder(StreamWriter writer, Guid parentGuid, Guid childGuid) | ||
623 | { | ||
624 | writer.WriteLine("\t\t{0} = {1}", | ||
625 | childGuid.ToString("B").ToUpper(), | ||
626 | parentGuid.ToString("B").ToUpper()); | ||
627 | } | ||
628 | |||
629 | private static void WriteConfigurationLines(ICollection configurations, SolutionNode solution, StreamWriter ss) | ||
630 | { | ||
631 | foreach (ProjectNode project in solution.Projects) | ||
632 | { | ||
633 | foreach (ConfigurationNode conf in configurations) | ||
634 | { | ||
635 | ss.WriteLine("\t\t{0}.{1}|Any CPU.ActiveCfg = {1}|Any CPU", | ||
636 | project.Guid.ToString("B").ToUpper(), | ||
637 | conf.Name); | ||
638 | |||
639 | ss.WriteLine("\t\t{0}.{1}|Any CPU.Build.0 = {1}|Any CPU", | ||
640 | project.Guid.ToString("B").ToUpper(), | ||
641 | conf.Name); | ||
642 | } | ||
643 | } | ||
644 | |||
645 | foreach (SolutionNode child in solution.Solutions) | ||
646 | { | ||
647 | WriteConfigurationLines(configurations, child, ss); | ||
648 | } | ||
649 | } | ||
650 | |||
651 | private void WriteSolutionFiles(SolutionNode solution, StreamWriter ss) | ||
652 | { | ||
653 | WriteProject(ss, "Folder", solution.Guid, "Solution Files", "Solution Files", solution.Files); | ||
654 | } | ||
655 | |||
656 | private void WriteEmbeddedSolution(StreamWriter writer, SolutionNode embeddedSolution) | ||
657 | { | ||
658 | WriteProject(writer, "Folder", embeddedSolution.Guid, embeddedSolution.Name, embeddedSolution.Name, embeddedSolution.Files); | ||
659 | } | ||
660 | |||
661 | private void WriteProject(SolutionNode solution, StreamWriter ss, ProjectNode project) | ||
662 | { | ||
663 | WriteProject(ss, solution, project.Language, project.Guid, project.Name, project.FullPath); | ||
664 | } | ||
665 | |||
666 | private void WriteProject(SolutionNode solution, StreamWriter ss, DatabaseProjectNode dbProject) | ||
667 | { | ||
668 | if (solution.Files != null && solution.Files.Count > 0) | ||
669 | WriteProject(ss, solution, "Database", dbProject.Guid, dbProject.Name, dbProject.FullPath); | ||
670 | } | ||
671 | |||
672 | private static bool ExtensionSpecified(string refName) | ||
673 | { | ||
674 | return refName.EndsWith(".dll") || refName.EndsWith(".exe"); | ||
675 | } | ||
676 | |||
677 | private static string GetProjectExtension(ProjectNode project) | ||
678 | { | ||
679 | string extension = ".dll"; | ||
680 | if (project.Type == ProjectType.Exe) | ||
681 | { | ||
682 | extension = ".exe"; | ||
683 | } | ||
684 | return extension; | ||
685 | } | ||
686 | |||
687 | const string ProjectDeclarationBeginFormat = "Project(\"{0}\") = \"{1}\", \"{2}\", \"{3}\""; | ||
688 | const string ProjectDeclarationEndFormat = "EndProject"; | ||
689 | |||
690 | private void WriteProject(StreamWriter ss, SolutionNode solution, string language, Guid guid, string name, string projectFullPath) | ||
691 | { | ||
692 | if (!tools.ContainsKey(language)) | ||
693 | throw new UnknownLanguageException("Unknown .NET language: " + language); | ||
694 | |||
695 | ToolInfo toolInfo = (ToolInfo)tools[language]; | ||
696 | |||
697 | string path = Helper.MakePathRelativeTo(solution.FullPath, projectFullPath); | ||
698 | |||
699 | path = Helper.MakeFilePath(path, name, toolInfo.FileExtension); | ||
700 | |||
701 | WriteProject(ss, language, guid, name, path); | ||
702 | } | ||
703 | |||
704 | private void WriteProject(StreamWriter writer, string language, Guid projectGuid, string name, string location) | ||
705 | { | ||
706 | WriteProject(writer, language, projectGuid, name, location, null); | ||
707 | } | ||
708 | |||
709 | private void WriteProject(StreamWriter writer, string language, Guid projectGuid, string name, string location, FilesNode files) | ||
710 | { | ||
711 | if (!tools.ContainsKey(language)) | ||
712 | throw new UnknownLanguageException("Unknown .NET language: " + language); | ||
713 | |||
714 | ToolInfo toolInfo = (ToolInfo)tools[language]; | ||
715 | |||
716 | writer.WriteLine(ProjectDeclarationBeginFormat, | ||
717 | toolInfo.Guid, | ||
718 | name, | ||
719 | location, | ||
720 | projectGuid.ToString("B").ToUpper()); | ||
721 | |||
722 | if (files != null) | ||
723 | { | ||
724 | writer.WriteLine("\tProjectSection(SolutionItems) = preProject"); | ||
725 | |||
726 | foreach (string file in files) | ||
727 | writer.WriteLine("\t\t{0} = {0}", file); | ||
728 | |||
729 | writer.WriteLine("\tEndProjectSection"); | ||
730 | } | ||
731 | |||
732 | writer.WriteLine(ProjectDeclarationEndFormat); | ||
733 | } | ||
734 | |||
735 | private void WriteDatabaseProject(SolutionNode solution, DatabaseProjectNode project) | ||
736 | { | ||
737 | string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, "dbp"); | ||
738 | IndentedTextWriter ps = new IndentedTextWriter(new StreamWriter(projectFile), " "); | ||
739 | |||
740 | kernel.CurrentWorkingDirectory.Push(); | ||
741 | |||
742 | Helper.SetCurrentDir(Path.GetDirectoryName(projectFile)); | ||
743 | |||
744 | using (ps) | ||
745 | { | ||
746 | ps.WriteLine("# Microsoft Developer Studio Project File - Database Project"); | ||
747 | ps.WriteLine("Begin DataProject = \"{0}\"", project.Name); | ||
748 | ps.Indent++; | ||
749 | ps.WriteLine("MSDTVersion = \"80\""); | ||
750 | // TODO: Use the project.Files property | ||
751 | if (ContainsSqlFiles(Path.GetDirectoryName(projectFile))) | ||
752 | WriteDatabaseFoldersAndFiles(ps, Path.GetDirectoryName(projectFile)); | ||
753 | |||
754 | ps.WriteLine("Begin DBRefFolder = \"Database References\""); | ||
755 | ps.Indent++; | ||
756 | foreach (DatabaseReferenceNode reference in project.References) | ||
757 | { | ||
758 | ps.WriteLine("Begin DBRefNode = \"{0}\"", reference.Name); | ||
759 | ps.Indent++; | ||
760 | ps.WriteLine("ConnectStr = \"{0}\"", reference.ConnectionString); | ||
761 | ps.WriteLine("Provider = \"{0}\"", reference.ProviderId.ToString("B").ToUpper()); | ||
762 | //ps.WriteLine("Colorizer = 5"); | ||
763 | ps.Indent--; | ||
764 | ps.WriteLine("End"); | ||
765 | } | ||
766 | ps.Indent--; | ||
767 | ps.WriteLine("End"); | ||
768 | ps.Indent--; | ||
769 | ps.WriteLine("End"); | ||
770 | |||
771 | ps.Flush(); | ||
772 | } | ||
773 | |||
774 | kernel.CurrentWorkingDirectory.Pop(); | ||
775 | } | ||
776 | |||
777 | private bool ContainsSqlFiles(string folder) | ||
778 | { | ||
779 | foreach (string file in Directory.GetFiles(folder, "*.sql")) | ||
780 | { | ||
781 | return true; // if the folder contains 1 .sql file, that's good enough | ||
782 | } | ||
783 | |||
784 | foreach (string child in Directory.GetDirectories(folder)) | ||
785 | { | ||
786 | if (ContainsSqlFiles(child)) | ||
787 | return true; // if 1 child folder contains a .sql file, still good enough | ||
788 | } | ||
789 | |||
790 | return false; | ||
791 | } | ||
792 | |||
793 | private void WriteDatabaseFoldersAndFiles(IndentedTextWriter writer, string folder) | ||
794 | { | ||
795 | foreach (string child in Directory.GetDirectories(folder)) | ||
796 | { | ||
797 | if (ContainsSqlFiles(child)) | ||
798 | { | ||
799 | writer.WriteLine("Begin Folder = \"{0}\"", Path.GetFileName(child)); | ||
800 | writer.Indent++; | ||
801 | WriteDatabaseFoldersAndFiles(writer, child); | ||
802 | writer.Indent--; | ||
803 | writer.WriteLine("End"); | ||
804 | } | ||
805 | } | ||
806 | foreach (string file in Directory.GetFiles(folder, "*.sql")) | ||
807 | { | ||
808 | writer.WriteLine("Script = \"{0}\"", Path.GetFileName(file)); | ||
809 | } | ||
810 | } | ||
811 | |||
812 | private void CleanProject(ProjectNode project) | ||
813 | { | ||
814 | kernel.Log.Write("...Cleaning project: {0}", project.Name); | ||
815 | |||
816 | ToolInfo toolInfo = (ToolInfo)tools[project.Language]; | ||
817 | string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); | ||
818 | string userFile = projectFile + ".user"; | ||
819 | |||
820 | Helper.DeleteIfExists(projectFile); | ||
821 | Helper.DeleteIfExists(userFile); | ||
822 | } | ||
823 | |||
824 | private void CleanSolution(SolutionNode solution) | ||
825 | { | ||
826 | kernel.Log.Write("Cleaning {0} solution and project files", this.VersionName, solution.Name); | ||
827 | |||
828 | string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln"); | ||
829 | string suoFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "suo"); | ||
830 | |||
831 | Helper.DeleteIfExists(slnFile); | ||
832 | Helper.DeleteIfExists(suoFile); | ||
833 | |||
834 | foreach (ProjectNode project in solution.Projects) | ||
835 | { | ||
836 | CleanProject(project); | ||
837 | } | ||
838 | |||
839 | kernel.Log.Write(""); | ||
840 | } | ||
841 | |||
842 | #endregion | ||
843 | |||
844 | #region ITarget Members | ||
845 | |||
846 | /// <summary> | ||
847 | /// Writes the specified kern. | ||
848 | /// </summary> | ||
849 | /// <param name="kern">The kern.</param> | ||
850 | public virtual void Write(Kernel kern) | ||
851 | { | ||
852 | if (kern == null) | ||
853 | { | ||
854 | throw new ArgumentNullException("kern"); | ||
855 | } | ||
856 | kernel = kern; | ||
857 | foreach (SolutionNode sol in kernel.Solutions) | ||
858 | { | ||
859 | WriteSolution(sol, true); | ||
860 | } | ||
861 | kernel = null; | ||
862 | } | ||
863 | |||
864 | /// <summary> | ||
865 | /// Cleans the specified kern. | ||
866 | /// </summary> | ||
867 | /// <param name="kern">The kern.</param> | ||
868 | public virtual void Clean(Kernel kern) | ||
869 | { | ||
870 | if (kern == null) | ||
871 | { | ||
872 | throw new ArgumentNullException("kern"); | ||
873 | } | ||
874 | kernel = kern; | ||
875 | foreach (SolutionNode sol in kernel.Solutions) | ||
876 | { | ||
877 | CleanSolution(sol); | ||
878 | } | ||
879 | kernel = null; | ||
880 | } | ||
881 | |||
882 | #endregion | ||
883 | } | ||
884 | } | ||
diff --git a/Prebuild/src/Core/Targets/VSVersion.cs b/Prebuild/src/Core/Targets/VSVersion.cs new file mode 100644 index 0000000..f477086 --- /dev/null +++ b/Prebuild/src/Core/Targets/VSVersion.cs | |||
@@ -0,0 +1,50 @@ | |||
1 | #region BSD License | ||
2 | /* | ||
3 | Copyright (c) 2008-2009 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com), John Anderson (sontek@gmail.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 | namespace Prebuild.Core.Targets | ||
27 | { | ||
28 | /// <summary> | ||
29 | /// | ||
30 | /// </summary> | ||
31 | public enum VSVersion | ||
32 | { | ||
33 | /// <summary> | ||
34 | /// Visual Studio 2002 | ||
35 | /// </summary> | ||
36 | VS70, | ||
37 | /// <summary> | ||
38 | /// Visual Studio 2003 | ||
39 | /// </summary> | ||
40 | VS71, | ||
41 | /// <summary> | ||
42 | /// Visual Studio 2005 | ||
43 | /// </summary> | ||
44 | VS80, | ||
45 | /// <summary> | ||
46 | /// Visual Studio 2008 | ||
47 | /// </summary> | ||
48 | VS90 | ||
49 | } | ||
50 | } | ||
diff --git a/Prebuild/src/Core/Targets/XcodeTarget.cs b/Prebuild/src/Core/Targets/XcodeTarget.cs index ee3b241..d96f65b 100644 --- a/Prebuild/src/Core/Targets/XcodeTarget.cs +++ b/Prebuild/src/Core/Targets/XcodeTarget.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: jendave $ | ||
30 | * $Date: 2007-02-13 12:58:03 -0800 (Tue, 13 Feb 2007) $ | ||
31 | * $Revision: 205 $ | ||
32 | */ | ||
33 | #endregion | ||
34 | |||
35 | using System; | 26 | using System; |
36 | using System.Collections; | 27 | using System.Collections; |
37 | using System.Collections.Specialized; | 28 | using System.Collections.Specialized; |