aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Prebuild/src/Core
diff options
context:
space:
mode:
Diffstat (limited to 'Prebuild/src/Core')
-rw-r--r--Prebuild/src/Core/Nodes/.svn/text-base/CleanFilesNode.cs.svn-base158
-rw-r--r--Prebuild/src/Core/Nodes/.svn/text-base/CleanupNode.cs.svn-base168
-rw-r--r--Prebuild/src/Core/Nodes/.svn/text-base/ConfigurationNodeCollection.cs.svn-base142
-rw-r--r--Prebuild/src/Core/Nodes/.svn/text-base/DatabaseProjectNode.cs.svn-base186
-rw-r--r--Prebuild/src/Core/Nodes/.svn/text-base/DatabaseReferenceNode.cs.svn-base126
-rw-r--r--Prebuild/src/Core/Nodes/CleanFilesNode.cs158
-rw-r--r--Prebuild/src/Core/Nodes/CleanupNode.cs168
-rw-r--r--Prebuild/src/Core/Nodes/ConfigurationNodeCollection.cs142
-rw-r--r--Prebuild/src/Core/Nodes/DatabaseProjectNode.cs186
-rw-r--r--Prebuild/src/Core/Nodes/DatabaseReferenceNode.cs126
-rw-r--r--Prebuild/src/Core/Targets/.svn/text-base/AutotoolsTarget.cs.svn-base2140
-rw-r--r--Prebuild/src/Core/Targets/.svn/text-base/VS2010Target.cs.svn-base276
-rw-r--r--Prebuild/src/Core/Targets/.svn/text-base/VSGenericTarget.cs.svn-base1844
-rw-r--r--Prebuild/src/Core/Targets/AutotoolsTarget.cs2140
-rw-r--r--Prebuild/src/Core/Targets/VS2010Target.cs276
-rw-r--r--Prebuild/src/Core/Targets/VSGenericTarget.cs1844
16 files changed, 5040 insertions, 5040 deletions
diff --git a/Prebuild/src/Core/Nodes/.svn/text-base/CleanFilesNode.cs.svn-base b/Prebuild/src/Core/Nodes/.svn/text-base/CleanFilesNode.cs.svn-base
index dc2da9a..71405f9 100644
--- a/Prebuild/src/Core/Nodes/.svn/text-base/CleanFilesNode.cs.svn-base
+++ b/Prebuild/src/Core/Nodes/.svn/text-base/CleanFilesNode.cs.svn-base
@@ -1,80 +1,80 @@
1#region BSD License 1#region BSD License
2/* 2/*
3Copyright (c) 2007 C.J. Adams-Collier (cjac@colliertech.org) 3Copyright (c) 2007 C.J. Adams-Collier (cjac@colliertech.org)
4 4
5Redistribution and use in source and binary forms, with or without modification, are permitted 5Redistribution and use in source and binary forms, with or without modification, are permitted
6provided that the following conditions are met: 6provided that the following conditions are met:
7 7
8* Redistributions of source code must retain the above copyright notice, this list of conditions 8* Redistributions of source code must retain the above copyright notice, this list of conditions
9 and the following disclaimer. 9 and the following disclaimer.
10* Redistributions in binary form must reproduce the above copyright notice, this list of conditions 10* Redistributions in binary form must reproduce the above copyright notice, this list of conditions
11 and the following disclaimer in the documentation and/or other materials provided with the 11 and the following disclaimer in the documentation and/or other materials provided with the
12 distribution. 12 distribution.
13* The name of the author may not be used to endorse or promote products derived from this software 13* The name of the author may not be used to endorse or promote products derived from this software
14 without specific prior written permission. 14 without specific prior written permission.
15 15
16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
17BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 21OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
22IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23*/ 23*/
24#endregion 24#endregion
25 25
26using System; 26using System;
27using System.Collections.Generic; 27using System.Collections.Generic;
28using System.Xml; 28using System.Xml;
29 29
30using Prebuild.Core.Attributes; 30using Prebuild.Core.Attributes;
31using Prebuild.Core.Interfaces; 31using Prebuild.Core.Interfaces;
32using Prebuild.Core.Utilities; 32using Prebuild.Core.Utilities;
33 33
34namespace Prebuild.Core.Nodes 34namespace Prebuild.Core.Nodes
35{ 35{
36 [DataNode("CleanFiles")] 36 [DataNode("CleanFiles")]
37 public class CleanFilesNode : DataNode 37 public class CleanFilesNode : DataNode
38 { 38 {
39 #region Fields 39 #region Fields
40 40
41 private string m_Pattern; 41 private string m_Pattern;
42 42
43 #endregion 43 #endregion
44 44
45 #region Properties 45 #region Properties
46 46
47 /// <summary> 47 /// <summary>
48 /// Gets the signature. 48 /// Gets the signature.
49 /// </summary> 49 /// </summary>
50 /// <value>The signature.</value> 50 /// <value>The signature.</value>
51 public string Pattern 51 public string Pattern
52 { 52 {
53 get 53 get
54 { 54 {
55 return m_Pattern; 55 return m_Pattern;
56 } 56 }
57 } 57 }
58 58
59 #endregion 59 #endregion
60 60
61 #region Public Methods 61 #region Public Methods
62 62
63 /// <summary> 63 /// <summary>
64 /// Parses the specified node. 64 /// Parses the specified node.
65 /// </summary> 65 /// </summary>
66 /// <param name="node">The node.</param> 66 /// <param name="node">The node.</param>
67 public override void Parse(XmlNode node) 67 public override void Parse(XmlNode node)
68 { 68 {
69 if (node == null) 69 if (node == null)
70 { 70 {
71 throw new ArgumentNullException("node"); 71 throw new ArgumentNullException("node");
72 } 72 }
73 73
74 m_Pattern = Helper.AttributeValue(node, "pattern", String.Empty); ; 74 m_Pattern = Helper.AttributeValue(node, "pattern", String.Empty); ;
75 m_Pattern = m_Pattern.Trim(); 75 m_Pattern = m_Pattern.Trim();
76 } 76 }
77 77
78 #endregion 78 #endregion
79 } 79 }
80} \ No newline at end of file 80} \ No newline at end of file
diff --git a/Prebuild/src/Core/Nodes/.svn/text-base/CleanupNode.cs.svn-base b/Prebuild/src/Core/Nodes/.svn/text-base/CleanupNode.cs.svn-base
index a9b77eb..b8131b0 100644
--- a/Prebuild/src/Core/Nodes/.svn/text-base/CleanupNode.cs.svn-base
+++ b/Prebuild/src/Core/Nodes/.svn/text-base/CleanupNode.cs.svn-base
@@ -1,85 +1,85 @@
1#region BSD License 1#region BSD License
2/* 2/*
3Copyright (c) 2007 C.J. Adams-Collier (cjac@colliertech.org) 3Copyright (c) 2007 C.J. Adams-Collier (cjac@colliertech.org)
4 4
5Redistribution and use in source and binary forms, with or without modification, are permitted 5Redistribution and use in source and binary forms, with or without modification, are permitted
6provided that the following conditions are met: 6provided that the following conditions are met:
7 7
8* Redistributions of source code must retain the above copyright notice, this list of conditions 8* Redistributions of source code must retain the above copyright notice, this list of conditions
9 and the following disclaimer. 9 and the following disclaimer.
10* Redistributions in binary form must reproduce the above copyright notice, this list of conditions 10* Redistributions in binary form must reproduce the above copyright notice, this list of conditions
11 and the following disclaimer in the documentation and/or other materials provided with the 11 and the following disclaimer in the documentation and/or other materials provided with the
12 distribution. 12 distribution.
13* The name of the author may not be used to endorse or promote products derived from this software 13* The name of the author may not be used to endorse or promote products derived from this software
14 without specific prior written permission. 14 without specific prior written permission.
15 15
16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
17BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 21OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
22IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23*/ 23*/
24#endregion 24#endregion
25 25
26using System; 26using System;
27using System.Collections.Generic; 27using System.Collections.Generic;
28using System.Xml; 28using System.Xml;
29 29
30using Prebuild.Core.Attributes; 30using Prebuild.Core.Attributes;
31using Prebuild.Core.Interfaces; 31using Prebuild.Core.Interfaces;
32 32
33namespace Prebuild.Core.Nodes 33namespace Prebuild.Core.Nodes
34{ 34{
35 [DataNode("Cleanup")] 35 [DataNode("Cleanup")]
36 public class CleanupNode : DataNode 36 public class CleanupNode : DataNode
37 { 37 {
38 #region Fields 38 #region Fields
39 39
40 private List<CleanFilesNode> m_CleanFiles = new List<CleanFilesNode>(); 40 private List<CleanFilesNode> m_CleanFiles = new List<CleanFilesNode>();
41 41
42 #endregion 42 #endregion
43 43
44 #region Properties 44 #region Properties
45 45
46 /// <summary> 46 /// <summary>
47 /// Gets the signature. 47 /// Gets the signature.
48 /// </summary> 48 /// </summary>
49 /// <value>The signature.</value> 49 /// <value>The signature.</value>
50 public List<CleanFilesNode> CleanFiles 50 public List<CleanFilesNode> CleanFiles
51 { 51 {
52 get 52 get
53 { 53 {
54 return m_CleanFiles; 54 return m_CleanFiles;
55 } 55 }
56 } 56 }
57 57
58 #endregion 58 #endregion
59 59
60 #region Public Methods 60 #region Public Methods
61 61
62 /// <summary> 62 /// <summary>
63 /// Parses the specified node. 63 /// Parses the specified node.
64 /// </summary> 64 /// </summary>
65 /// <param name="node">The node.</param> 65 /// <param name="node">The node.</param>
66 public override void Parse(XmlNode node) 66 public override void Parse(XmlNode node)
67 { 67 {
68 if( node == null ) 68 if( node == null )
69 { 69 {
70 throw new ArgumentNullException("node"); 70 throw new ArgumentNullException("node");
71 } 71 }
72 72
73 foreach (XmlNode child in node.ChildNodes) 73 foreach (XmlNode child in node.ChildNodes)
74 { 74 {
75 IDataNode dataNode = Kernel.Instance.ParseNode(child, this); 75 IDataNode dataNode = Kernel.Instance.ParseNode(child, this);
76 if (dataNode is CleanFilesNode) 76 if (dataNode is CleanFilesNode)
77 { 77 {
78 m_CleanFiles.Add((CleanFilesNode)dataNode); 78 m_CleanFiles.Add((CleanFilesNode)dataNode);
79 } 79 }
80 } 80 }
81 } 81 }
82 82
83 #endregion 83 #endregion
84 } 84 }
85} \ No newline at end of file 85} \ No newline at end of file
diff --git a/Prebuild/src/Core/Nodes/.svn/text-base/ConfigurationNodeCollection.cs.svn-base b/Prebuild/src/Core/Nodes/.svn/text-base/ConfigurationNodeCollection.cs.svn-base
index 7c59ac5..1c38d9e 100644
--- a/Prebuild/src/Core/Nodes/.svn/text-base/ConfigurationNodeCollection.cs.svn-base
+++ b/Prebuild/src/Core/Nodes/.svn/text-base/ConfigurationNodeCollection.cs.svn-base
@@ -1,71 +1,71 @@
1#region BSD License 1#region BSD License
2/* 2/*
3Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) 3Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com)
4 4
5Redistribution and use in source and binary forms, with or without modification, are permitted 5Redistribution and use in source and binary forms, with or without modification, are permitted
6provided that the following conditions are met: 6provided that the following conditions are met:
7 7
8* Redistributions of source code must retain the above copyright notice, this list of conditions 8* Redistributions of source code must retain the above copyright notice, this list of conditions
9 and the following disclaimer. 9 and the following disclaimer.
10* Redistributions in binary form must reproduce the above copyright notice, this list of conditions 10* Redistributions in binary form must reproduce the above copyright notice, this list of conditions
11 and the following disclaimer in the documentation and/or other materials provided with the 11 and the following disclaimer in the documentation and/or other materials provided with the
12 distribution. 12 distribution.
13* The name of the author may not be used to endorse or promote products derived from this software 13* The name of the author may not be used to endorse or promote products derived from this software
14 without specific prior written permission. 14 without specific prior written permission.
15 15
16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
17BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 21OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
22IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23*/ 23*/
24#endregion 24#endregion
25 25
26using System.Collections.Generic; 26using System.Collections.Generic;
27 27
28namespace Prebuild.Core.Nodes 28namespace Prebuild.Core.Nodes
29{ 29{
30 /// <summary> 30 /// <summary>
31 /// Implements a specialized list of configuration nodes which allows for lookup via 31 /// Implements a specialized list of configuration nodes which allows for lookup via
32 /// configuration name and platform. 32 /// configuration name and platform.
33 /// </summary> 33 /// </summary>
34 public class ConfigurationNodeCollection : List<ConfigurationNode> 34 public class ConfigurationNodeCollection : List<ConfigurationNode>
35 { 35 {
36 #region Properties 36 #region Properties
37 37
38 public ConfigurationNode this[string nameAndPlatform] 38 public ConfigurationNode this[string nameAndPlatform]
39 { 39 {
40 get 40 get
41 { 41 {
42 foreach (ConfigurationNode configurationNode in this) 42 foreach (ConfigurationNode configurationNode in this)
43 { 43 {
44 if (configurationNode.NameAndPlatform == nameAndPlatform) 44 if (configurationNode.NameAndPlatform == nameAndPlatform)
45 { 45 {
46 return configurationNode; 46 return configurationNode;
47 } 47 }
48 } 48 }
49 49
50 return null; 50 return null;
51 } 51 }
52 52
53 set 53 set
54 { 54 {
55 // See if the node 55 // See if the node
56 ConfigurationNode configurationNode = this[nameAndPlatform]; 56 ConfigurationNode configurationNode = this[nameAndPlatform];
57 57
58 if (configurationNode != null) 58 if (configurationNode != null)
59 { 59 {
60 this[IndexOf(configurationNode)] = value; 60 this[IndexOf(configurationNode)] = value;
61 } 61 }
62 else 62 else
63 { 63 {
64 Add(value); 64 Add(value);
65 } 65 }
66 } 66 }
67 } 67 }
68 68
69 #endregion 69 #endregion
70 } 70 }
71} 71}
diff --git a/Prebuild/src/Core/Nodes/.svn/text-base/DatabaseProjectNode.cs.svn-base b/Prebuild/src/Core/Nodes/.svn/text-base/DatabaseProjectNode.cs.svn-base
index 20095c3..278ecd8 100644
--- a/Prebuild/src/Core/Nodes/.svn/text-base/DatabaseProjectNode.cs.svn-base
+++ b/Prebuild/src/Core/Nodes/.svn/text-base/DatabaseProjectNode.cs.svn-base
@@ -1,93 +1,93 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4using System.Xml; 4using System.Xml;
5 5
6using Prebuild.Core.Attributes; 6using Prebuild.Core.Attributes;
7using Prebuild.Core.Interfaces; 7using Prebuild.Core.Interfaces;
8using Prebuild.Core.Utilities; 8using Prebuild.Core.Utilities;
9 9
10namespace Prebuild.Core.Nodes 10namespace Prebuild.Core.Nodes
11{ 11{
12 [DataNode("DatabaseProject")] 12 [DataNode("DatabaseProject")]
13 public class DatabaseProjectNode : DataNode 13 public class DatabaseProjectNode : DataNode
14 { 14 {
15 string name; 15 string name;
16 string path; 16 string path;
17 string fullpath; 17 string fullpath;
18 Guid guid = Guid.NewGuid(); 18 Guid guid = Guid.NewGuid();
19 readonly List<AuthorNode> authors = new List<AuthorNode>(); 19 readonly List<AuthorNode> authors = new List<AuthorNode>();
20 readonly List<DatabaseReferenceNode> references = new List<DatabaseReferenceNode>(); 20 readonly List<DatabaseReferenceNode> references = new List<DatabaseReferenceNode>();
21 21
22 public Guid Guid 22 public Guid Guid
23 { 23 {
24 get { return guid; } 24 get { return guid; }
25 } 25 }
26 26
27 public string Name 27 public string Name
28 { 28 {
29 get { return name; } 29 get { return name; }
30 } 30 }
31 31
32 public string Path 32 public string Path
33 { 33 {
34 get { return path; } 34 get { return path; }
35 } 35 }
36 36
37 public string FullPath 37 public string FullPath
38 { 38 {
39 get { return fullpath; } 39 get { return fullpath; }
40 } 40 }
41 41
42 public IEnumerable<DatabaseReferenceNode> References 42 public IEnumerable<DatabaseReferenceNode> References
43 { 43 {
44 get { return references; } 44 get { return references; }
45 } 45 }
46 46
47 public override void Parse(XmlNode node) 47 public override void Parse(XmlNode node)
48 { 48 {
49 name = Helper.AttributeValue(node, "name", name); 49 name = Helper.AttributeValue(node, "name", name);
50 path = Helper.AttributeValue(node, "path", name); 50 path = Helper.AttributeValue(node, "path", name);
51 51
52 try 52 try
53 { 53 {
54 fullpath = Helper.ResolvePath(path); 54 fullpath = Helper.ResolvePath(path);
55 } 55 }
56 catch 56 catch
57 { 57 {
58 throw new WarningException("Could not resolve Solution path: {0}", path); 58 throw new WarningException("Could not resolve Solution path: {0}", path);
59 } 59 }
60 60
61 Kernel.Instance.CurrentWorkingDirectory.Push(); 61 Kernel.Instance.CurrentWorkingDirectory.Push();
62 62
63 try 63 try
64 { 64 {
65 Helper.SetCurrentDir(fullpath); 65 Helper.SetCurrentDir(fullpath);
66 66
67 if (node == null) 67 if (node == null)
68 { 68 {
69 throw new ArgumentNullException("node"); 69 throw new ArgumentNullException("node");
70 } 70 }
71 71
72 foreach (XmlNode child in node.ChildNodes) 72 foreach (XmlNode child in node.ChildNodes)
73 { 73 {
74 IDataNode dataNode = Kernel.Instance.ParseNode(child, this); 74 IDataNode dataNode = Kernel.Instance.ParseNode(child, this);
75 75
76 if (dataNode == null) 76 if (dataNode == null)
77 continue; 77 continue;
78 78
79 if (dataNode is AuthorNode) 79 if (dataNode is AuthorNode)
80 authors.Add((AuthorNode)dataNode); 80 authors.Add((AuthorNode)dataNode);
81 else if (dataNode is DatabaseReferenceNode) 81 else if (dataNode is DatabaseReferenceNode)
82 references.Add((DatabaseReferenceNode)dataNode); 82 references.Add((DatabaseReferenceNode)dataNode);
83 } 83 }
84 } 84 }
85 finally 85 finally
86 { 86 {
87 Kernel.Instance.CurrentWorkingDirectory.Pop(); 87 Kernel.Instance.CurrentWorkingDirectory.Pop();
88 } 88 }
89 89
90 base.Parse(node); 90 base.Parse(node);
91 } 91 }
92 } 92 }
93} 93}
diff --git a/Prebuild/src/Core/Nodes/.svn/text-base/DatabaseReferenceNode.cs.svn-base b/Prebuild/src/Core/Nodes/.svn/text-base/DatabaseReferenceNode.cs.svn-base
index 97c3964..845db24 100644
--- a/Prebuild/src/Core/Nodes/.svn/text-base/DatabaseReferenceNode.cs.svn-base
+++ b/Prebuild/src/Core/Nodes/.svn/text-base/DatabaseReferenceNode.cs.svn-base
@@ -1,63 +1,63 @@
1using System; 1using System;
2using Prebuild.Core.Attributes; 2using Prebuild.Core.Attributes;
3using Prebuild.Core.Utilities; 3using Prebuild.Core.Utilities;
4 4
5namespace Prebuild.Core.Nodes 5namespace Prebuild.Core.Nodes
6{ 6{
7 [DataNode("DatabaseReference")] 7 [DataNode("DatabaseReference")]
8 public class DatabaseReferenceNode : DataNode 8 public class DatabaseReferenceNode : DataNode
9 { 9 {
10 string name; 10 string name;
11 Guid providerId; 11 Guid providerId;
12 string connectionString; 12 string connectionString;
13 13
14 public string Name 14 public string Name
15 { 15 {
16 get { return name; } 16 get { return name; }
17 } 17 }
18 18
19 public Guid ProviderId 19 public Guid ProviderId
20 { 20 {
21 get { return providerId; } 21 get { return providerId; }
22 } 22 }
23 23
24 public string ConnectionString 24 public string ConnectionString
25 { 25 {
26 get { return connectionString; } 26 get { return connectionString; }
27 } 27 }
28 28
29 public override void Parse(System.Xml.XmlNode node) 29 public override void Parse(System.Xml.XmlNode node)
30 { 30 {
31 name = Helper.AttributeValue(node, "name", name); 31 name = Helper.AttributeValue(node, "name", name);
32 32
33 string providerName = Helper.AttributeValue(node, "providerName", string.Empty); 33 string providerName = Helper.AttributeValue(node, "providerName", string.Empty);
34 if (providerName != null) 34 if (providerName != null)
35 { 35 {
36 switch (providerName) 36 switch (providerName)
37 { 37 {
38 // digitaljeebus: pulled from HKLM\SOFTWARE\Microsoft\VisualStudio\9.0\DataProviders\* 38 // digitaljeebus: pulled from HKLM\SOFTWARE\Microsoft\VisualStudio\9.0\DataProviders\*
39 // Not sure if these will help other operating systems, or if there's a better way. 39 // Not sure if these will help other operating systems, or if there's a better way.
40 case "Microsoft.SqlServerCe.Client.3.5": 40 case "Microsoft.SqlServerCe.Client.3.5":
41 providerId = new Guid("7C602B5B-ACCB-4acd-9DC0-CA66388C1533"); break; 41 providerId = new Guid("7C602B5B-ACCB-4acd-9DC0-CA66388C1533"); break;
42 case "System.Data.OleDb": 42 case "System.Data.OleDb":
43 providerId = new Guid("7F041D59-D76A-44ed-9AA2-FBF6B0548B80"); break; 43 providerId = new Guid("7F041D59-D76A-44ed-9AA2-FBF6B0548B80"); break;
44 case "System.Data.OracleClient": 44 case "System.Data.OracleClient":
45 providerId = new Guid("8F5C5018-AE09-42cf-B2CC-2CCCC7CFC2BB"); break; 45 providerId = new Guid("8F5C5018-AE09-42cf-B2CC-2CCCC7CFC2BB"); break;
46 case "System.Data.SqlClient": 46 case "System.Data.SqlClient":
47 providerId = new Guid("91510608-8809-4020-8897-FBA057E22D54"); break; 47 providerId = new Guid("91510608-8809-4020-8897-FBA057E22D54"); break;
48 case "System.Data.Odbc": 48 case "System.Data.Odbc":
49 providerId = new Guid("C3D4F4CE-2C48-4381-B4D6-34FA50C51C86"); break; 49 providerId = new Guid("C3D4F4CE-2C48-4381-B4D6-34FA50C51C86"); break;
50 50
51 default: 51 default:
52 throw new ArgumentOutOfRangeException("providerName", providerName, "Could not provider name to an id."); 52 throw new ArgumentOutOfRangeException("providerName", providerName, "Could not provider name to an id.");
53 } 53 }
54 } 54 }
55 else 55 else
56 providerId = new Guid(Helper.AttributeValue(node, "providerId", Guid.Empty.ToString("B"))); 56 providerId = new Guid(Helper.AttributeValue(node, "providerId", Guid.Empty.ToString("B")));
57 57
58 connectionString = Helper.AttributeValue(node, "connectionString", connectionString); 58 connectionString = Helper.AttributeValue(node, "connectionString", connectionString);
59 59
60 base.Parse(node); 60 base.Parse(node);
61 } 61 }
62 } 62 }
63} 63}
diff --git a/Prebuild/src/Core/Nodes/CleanFilesNode.cs b/Prebuild/src/Core/Nodes/CleanFilesNode.cs
index dc2da9a..71405f9 100644
--- a/Prebuild/src/Core/Nodes/CleanFilesNode.cs
+++ b/Prebuild/src/Core/Nodes/CleanFilesNode.cs
@@ -1,80 +1,80 @@
1#region BSD License 1#region BSD License
2/* 2/*
3Copyright (c) 2007 C.J. Adams-Collier (cjac@colliertech.org) 3Copyright (c) 2007 C.J. Adams-Collier (cjac@colliertech.org)
4 4
5Redistribution and use in source and binary forms, with or without modification, are permitted 5Redistribution and use in source and binary forms, with or without modification, are permitted
6provided that the following conditions are met: 6provided that the following conditions are met:
7 7
8* Redistributions of source code must retain the above copyright notice, this list of conditions 8* Redistributions of source code must retain the above copyright notice, this list of conditions
9 and the following disclaimer. 9 and the following disclaimer.
10* Redistributions in binary form must reproduce the above copyright notice, this list of conditions 10* Redistributions in binary form must reproduce the above copyright notice, this list of conditions
11 and the following disclaimer in the documentation and/or other materials provided with the 11 and the following disclaimer in the documentation and/or other materials provided with the
12 distribution. 12 distribution.
13* The name of the author may not be used to endorse or promote products derived from this software 13* The name of the author may not be used to endorse or promote products derived from this software
14 without specific prior written permission. 14 without specific prior written permission.
15 15
16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
17BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 21OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
22IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23*/ 23*/
24#endregion 24#endregion
25 25
26using System; 26using System;
27using System.Collections.Generic; 27using System.Collections.Generic;
28using System.Xml; 28using System.Xml;
29 29
30using Prebuild.Core.Attributes; 30using Prebuild.Core.Attributes;
31using Prebuild.Core.Interfaces; 31using Prebuild.Core.Interfaces;
32using Prebuild.Core.Utilities; 32using Prebuild.Core.Utilities;
33 33
34namespace Prebuild.Core.Nodes 34namespace Prebuild.Core.Nodes
35{ 35{
36 [DataNode("CleanFiles")] 36 [DataNode("CleanFiles")]
37 public class CleanFilesNode : DataNode 37 public class CleanFilesNode : DataNode
38 { 38 {
39 #region Fields 39 #region Fields
40 40
41 private string m_Pattern; 41 private string m_Pattern;
42 42
43 #endregion 43 #endregion
44 44
45 #region Properties 45 #region Properties
46 46
47 /// <summary> 47 /// <summary>
48 /// Gets the signature. 48 /// Gets the signature.
49 /// </summary> 49 /// </summary>
50 /// <value>The signature.</value> 50 /// <value>The signature.</value>
51 public string Pattern 51 public string Pattern
52 { 52 {
53 get 53 get
54 { 54 {
55 return m_Pattern; 55 return m_Pattern;
56 } 56 }
57 } 57 }
58 58
59 #endregion 59 #endregion
60 60
61 #region Public Methods 61 #region Public Methods
62 62
63 /// <summary> 63 /// <summary>
64 /// Parses the specified node. 64 /// Parses the specified node.
65 /// </summary> 65 /// </summary>
66 /// <param name="node">The node.</param> 66 /// <param name="node">The node.</param>
67 public override void Parse(XmlNode node) 67 public override void Parse(XmlNode node)
68 { 68 {
69 if (node == null) 69 if (node == null)
70 { 70 {
71 throw new ArgumentNullException("node"); 71 throw new ArgumentNullException("node");
72 } 72 }
73 73
74 m_Pattern = Helper.AttributeValue(node, "pattern", String.Empty); ; 74 m_Pattern = Helper.AttributeValue(node, "pattern", String.Empty); ;
75 m_Pattern = m_Pattern.Trim(); 75 m_Pattern = m_Pattern.Trim();
76 } 76 }
77 77
78 #endregion 78 #endregion
79 } 79 }
80} \ No newline at end of file 80} \ No newline at end of file
diff --git a/Prebuild/src/Core/Nodes/CleanupNode.cs b/Prebuild/src/Core/Nodes/CleanupNode.cs
index a9b77eb..b8131b0 100644
--- a/Prebuild/src/Core/Nodes/CleanupNode.cs
+++ b/Prebuild/src/Core/Nodes/CleanupNode.cs
@@ -1,85 +1,85 @@
1#region BSD License 1#region BSD License
2/* 2/*
3Copyright (c) 2007 C.J. Adams-Collier (cjac@colliertech.org) 3Copyright (c) 2007 C.J. Adams-Collier (cjac@colliertech.org)
4 4
5Redistribution and use in source and binary forms, with or without modification, are permitted 5Redistribution and use in source and binary forms, with or without modification, are permitted
6provided that the following conditions are met: 6provided that the following conditions are met:
7 7
8* Redistributions of source code must retain the above copyright notice, this list of conditions 8* Redistributions of source code must retain the above copyright notice, this list of conditions
9 and the following disclaimer. 9 and the following disclaimer.
10* Redistributions in binary form must reproduce the above copyright notice, this list of conditions 10* Redistributions in binary form must reproduce the above copyright notice, this list of conditions
11 and the following disclaimer in the documentation and/or other materials provided with the 11 and the following disclaimer in the documentation and/or other materials provided with the
12 distribution. 12 distribution.
13* The name of the author may not be used to endorse or promote products derived from this software 13* The name of the author may not be used to endorse or promote products derived from this software
14 without specific prior written permission. 14 without specific prior written permission.
15 15
16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
17BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 21OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
22IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23*/ 23*/
24#endregion 24#endregion
25 25
26using System; 26using System;
27using System.Collections.Generic; 27using System.Collections.Generic;
28using System.Xml; 28using System.Xml;
29 29
30using Prebuild.Core.Attributes; 30using Prebuild.Core.Attributes;
31using Prebuild.Core.Interfaces; 31using Prebuild.Core.Interfaces;
32 32
33namespace Prebuild.Core.Nodes 33namespace Prebuild.Core.Nodes
34{ 34{
35 [DataNode("Cleanup")] 35 [DataNode("Cleanup")]
36 public class CleanupNode : DataNode 36 public class CleanupNode : DataNode
37 { 37 {
38 #region Fields 38 #region Fields
39 39
40 private List<CleanFilesNode> m_CleanFiles = new List<CleanFilesNode>(); 40 private List<CleanFilesNode> m_CleanFiles = new List<CleanFilesNode>();
41 41
42 #endregion 42 #endregion
43 43
44 #region Properties 44 #region Properties
45 45
46 /// <summary> 46 /// <summary>
47 /// Gets the signature. 47 /// Gets the signature.
48 /// </summary> 48 /// </summary>
49 /// <value>The signature.</value> 49 /// <value>The signature.</value>
50 public List<CleanFilesNode> CleanFiles 50 public List<CleanFilesNode> CleanFiles
51 { 51 {
52 get 52 get
53 { 53 {
54 return m_CleanFiles; 54 return m_CleanFiles;
55 } 55 }
56 } 56 }
57 57
58 #endregion 58 #endregion
59 59
60 #region Public Methods 60 #region Public Methods
61 61
62 /// <summary> 62 /// <summary>
63 /// Parses the specified node. 63 /// Parses the specified node.
64 /// </summary> 64 /// </summary>
65 /// <param name="node">The node.</param> 65 /// <param name="node">The node.</param>
66 public override void Parse(XmlNode node) 66 public override void Parse(XmlNode node)
67 { 67 {
68 if( node == null ) 68 if( node == null )
69 { 69 {
70 throw new ArgumentNullException("node"); 70 throw new ArgumentNullException("node");
71 } 71 }
72 72
73 foreach (XmlNode child in node.ChildNodes) 73 foreach (XmlNode child in node.ChildNodes)
74 { 74 {
75 IDataNode dataNode = Kernel.Instance.ParseNode(child, this); 75 IDataNode dataNode = Kernel.Instance.ParseNode(child, this);
76 if (dataNode is CleanFilesNode) 76 if (dataNode is CleanFilesNode)
77 { 77 {
78 m_CleanFiles.Add((CleanFilesNode)dataNode); 78 m_CleanFiles.Add((CleanFilesNode)dataNode);
79 } 79 }
80 } 80 }
81 } 81 }
82 82
83 #endregion 83 #endregion
84 } 84 }
85} \ No newline at end of file 85} \ No newline at end of file
diff --git a/Prebuild/src/Core/Nodes/ConfigurationNodeCollection.cs b/Prebuild/src/Core/Nodes/ConfigurationNodeCollection.cs
index 7c59ac5..1c38d9e 100644
--- a/Prebuild/src/Core/Nodes/ConfigurationNodeCollection.cs
+++ b/Prebuild/src/Core/Nodes/ConfigurationNodeCollection.cs
@@ -1,71 +1,71 @@
1#region BSD License 1#region BSD License
2/* 2/*
3Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) 3Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com)
4 4
5Redistribution and use in source and binary forms, with or without modification, are permitted 5Redistribution and use in source and binary forms, with or without modification, are permitted
6provided that the following conditions are met: 6provided that the following conditions are met:
7 7
8* Redistributions of source code must retain the above copyright notice, this list of conditions 8* Redistributions of source code must retain the above copyright notice, this list of conditions
9 and the following disclaimer. 9 and the following disclaimer.
10* Redistributions in binary form must reproduce the above copyright notice, this list of conditions 10* Redistributions in binary form must reproduce the above copyright notice, this list of conditions
11 and the following disclaimer in the documentation and/or other materials provided with the 11 and the following disclaimer in the documentation and/or other materials provided with the
12 distribution. 12 distribution.
13* The name of the author may not be used to endorse or promote products derived from this software 13* The name of the author may not be used to endorse or promote products derived from this software
14 without specific prior written permission. 14 without specific prior written permission.
15 15
16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
17BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 21OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
22IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23*/ 23*/
24#endregion 24#endregion
25 25
26using System.Collections.Generic; 26using System.Collections.Generic;
27 27
28namespace Prebuild.Core.Nodes 28namespace Prebuild.Core.Nodes
29{ 29{
30 /// <summary> 30 /// <summary>
31 /// Implements a specialized list of configuration nodes which allows for lookup via 31 /// Implements a specialized list of configuration nodes which allows for lookup via
32 /// configuration name and platform. 32 /// configuration name and platform.
33 /// </summary> 33 /// </summary>
34 public class ConfigurationNodeCollection : List<ConfigurationNode> 34 public class ConfigurationNodeCollection : List<ConfigurationNode>
35 { 35 {
36 #region Properties 36 #region Properties
37 37
38 public ConfigurationNode this[string nameAndPlatform] 38 public ConfigurationNode this[string nameAndPlatform]
39 { 39 {
40 get 40 get
41 { 41 {
42 foreach (ConfigurationNode configurationNode in this) 42 foreach (ConfigurationNode configurationNode in this)
43 { 43 {
44 if (configurationNode.NameAndPlatform == nameAndPlatform) 44 if (configurationNode.NameAndPlatform == nameAndPlatform)
45 { 45 {
46 return configurationNode; 46 return configurationNode;
47 } 47 }
48 } 48 }
49 49
50 return null; 50 return null;
51 } 51 }
52 52
53 set 53 set
54 { 54 {
55 // See if the node 55 // See if the node
56 ConfigurationNode configurationNode = this[nameAndPlatform]; 56 ConfigurationNode configurationNode = this[nameAndPlatform];
57 57
58 if (configurationNode != null) 58 if (configurationNode != null)
59 { 59 {
60 this[IndexOf(configurationNode)] = value; 60 this[IndexOf(configurationNode)] = value;
61 } 61 }
62 else 62 else
63 { 63 {
64 Add(value); 64 Add(value);
65 } 65 }
66 } 66 }
67 } 67 }
68 68
69 #endregion 69 #endregion
70 } 70 }
71} 71}
diff --git a/Prebuild/src/Core/Nodes/DatabaseProjectNode.cs b/Prebuild/src/Core/Nodes/DatabaseProjectNode.cs
index 20095c3..278ecd8 100644
--- a/Prebuild/src/Core/Nodes/DatabaseProjectNode.cs
+++ b/Prebuild/src/Core/Nodes/DatabaseProjectNode.cs
@@ -1,93 +1,93 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4using System.Xml; 4using System.Xml;
5 5
6using Prebuild.Core.Attributes; 6using Prebuild.Core.Attributes;
7using Prebuild.Core.Interfaces; 7using Prebuild.Core.Interfaces;
8using Prebuild.Core.Utilities; 8using Prebuild.Core.Utilities;
9 9
10namespace Prebuild.Core.Nodes 10namespace Prebuild.Core.Nodes
11{ 11{
12 [DataNode("DatabaseProject")] 12 [DataNode("DatabaseProject")]
13 public class DatabaseProjectNode : DataNode 13 public class DatabaseProjectNode : DataNode
14 { 14 {
15 string name; 15 string name;
16 string path; 16 string path;
17 string fullpath; 17 string fullpath;
18 Guid guid = Guid.NewGuid(); 18 Guid guid = Guid.NewGuid();
19 readonly List<AuthorNode> authors = new List<AuthorNode>(); 19 readonly List<AuthorNode> authors = new List<AuthorNode>();
20 readonly List<DatabaseReferenceNode> references = new List<DatabaseReferenceNode>(); 20 readonly List<DatabaseReferenceNode> references = new List<DatabaseReferenceNode>();
21 21
22 public Guid Guid 22 public Guid Guid
23 { 23 {
24 get { return guid; } 24 get { return guid; }
25 } 25 }
26 26
27 public string Name 27 public string Name
28 { 28 {
29 get { return name; } 29 get { return name; }
30 } 30 }
31 31
32 public string Path 32 public string Path
33 { 33 {
34 get { return path; } 34 get { return path; }
35 } 35 }
36 36
37 public string FullPath 37 public string FullPath
38 { 38 {
39 get { return fullpath; } 39 get { return fullpath; }
40 } 40 }
41 41
42 public IEnumerable<DatabaseReferenceNode> References 42 public IEnumerable<DatabaseReferenceNode> References
43 { 43 {
44 get { return references; } 44 get { return references; }
45 } 45 }
46 46
47 public override void Parse(XmlNode node) 47 public override void Parse(XmlNode node)
48 { 48 {
49 name = Helper.AttributeValue(node, "name", name); 49 name = Helper.AttributeValue(node, "name", name);
50 path = Helper.AttributeValue(node, "path", name); 50 path = Helper.AttributeValue(node, "path", name);
51 51
52 try 52 try
53 { 53 {
54 fullpath = Helper.ResolvePath(path); 54 fullpath = Helper.ResolvePath(path);
55 } 55 }
56 catch 56 catch
57 { 57 {
58 throw new WarningException("Could not resolve Solution path: {0}", path); 58 throw new WarningException("Could not resolve Solution path: {0}", path);
59 } 59 }
60 60
61 Kernel.Instance.CurrentWorkingDirectory.Push(); 61 Kernel.Instance.CurrentWorkingDirectory.Push();
62 62
63 try 63 try
64 { 64 {
65 Helper.SetCurrentDir(fullpath); 65 Helper.SetCurrentDir(fullpath);
66 66
67 if (node == null) 67 if (node == null)
68 { 68 {
69 throw new ArgumentNullException("node"); 69 throw new ArgumentNullException("node");
70 } 70 }
71 71
72 foreach (XmlNode child in node.ChildNodes) 72 foreach (XmlNode child in node.ChildNodes)
73 { 73 {
74 IDataNode dataNode = Kernel.Instance.ParseNode(child, this); 74 IDataNode dataNode = Kernel.Instance.ParseNode(child, this);
75 75
76 if (dataNode == null) 76 if (dataNode == null)
77 continue; 77 continue;
78 78
79 if (dataNode is AuthorNode) 79 if (dataNode is AuthorNode)
80 authors.Add((AuthorNode)dataNode); 80 authors.Add((AuthorNode)dataNode);
81 else if (dataNode is DatabaseReferenceNode) 81 else if (dataNode is DatabaseReferenceNode)
82 references.Add((DatabaseReferenceNode)dataNode); 82 references.Add((DatabaseReferenceNode)dataNode);
83 } 83 }
84 } 84 }
85 finally 85 finally
86 { 86 {
87 Kernel.Instance.CurrentWorkingDirectory.Pop(); 87 Kernel.Instance.CurrentWorkingDirectory.Pop();
88 } 88 }
89 89
90 base.Parse(node); 90 base.Parse(node);
91 } 91 }
92 } 92 }
93} 93}
diff --git a/Prebuild/src/Core/Nodes/DatabaseReferenceNode.cs b/Prebuild/src/Core/Nodes/DatabaseReferenceNode.cs
index 97c3964..845db24 100644
--- a/Prebuild/src/Core/Nodes/DatabaseReferenceNode.cs
+++ b/Prebuild/src/Core/Nodes/DatabaseReferenceNode.cs
@@ -1,63 +1,63 @@
1using System; 1using System;
2using Prebuild.Core.Attributes; 2using Prebuild.Core.Attributes;
3using Prebuild.Core.Utilities; 3using Prebuild.Core.Utilities;
4 4
5namespace Prebuild.Core.Nodes 5namespace Prebuild.Core.Nodes
6{ 6{
7 [DataNode("DatabaseReference")] 7 [DataNode("DatabaseReference")]
8 public class DatabaseReferenceNode : DataNode 8 public class DatabaseReferenceNode : DataNode
9 { 9 {
10 string name; 10 string name;
11 Guid providerId; 11 Guid providerId;
12 string connectionString; 12 string connectionString;
13 13
14 public string Name 14 public string Name
15 { 15 {
16 get { return name; } 16 get { return name; }
17 } 17 }
18 18
19 public Guid ProviderId 19 public Guid ProviderId
20 { 20 {
21 get { return providerId; } 21 get { return providerId; }
22 } 22 }
23 23
24 public string ConnectionString 24 public string ConnectionString
25 { 25 {
26 get { return connectionString; } 26 get { return connectionString; }
27 } 27 }
28 28
29 public override void Parse(System.Xml.XmlNode node) 29 public override void Parse(System.Xml.XmlNode node)
30 { 30 {
31 name = Helper.AttributeValue(node, "name", name); 31 name = Helper.AttributeValue(node, "name", name);
32 32
33 string providerName = Helper.AttributeValue(node, "providerName", string.Empty); 33 string providerName = Helper.AttributeValue(node, "providerName", string.Empty);
34 if (providerName != null) 34 if (providerName != null)
35 { 35 {
36 switch (providerName) 36 switch (providerName)
37 { 37 {
38 // digitaljeebus: pulled from HKLM\SOFTWARE\Microsoft\VisualStudio\9.0\DataProviders\* 38 // digitaljeebus: pulled from HKLM\SOFTWARE\Microsoft\VisualStudio\9.0\DataProviders\*
39 // Not sure if these will help other operating systems, or if there's a better way. 39 // Not sure if these will help other operating systems, or if there's a better way.
40 case "Microsoft.SqlServerCe.Client.3.5": 40 case "Microsoft.SqlServerCe.Client.3.5":
41 providerId = new Guid("7C602B5B-ACCB-4acd-9DC0-CA66388C1533"); break; 41 providerId = new Guid("7C602B5B-ACCB-4acd-9DC0-CA66388C1533"); break;
42 case "System.Data.OleDb": 42 case "System.Data.OleDb":
43 providerId = new Guid("7F041D59-D76A-44ed-9AA2-FBF6B0548B80"); break; 43 providerId = new Guid("7F041D59-D76A-44ed-9AA2-FBF6B0548B80"); break;
44 case "System.Data.OracleClient": 44 case "System.Data.OracleClient":
45 providerId = new Guid("8F5C5018-AE09-42cf-B2CC-2CCCC7CFC2BB"); break; 45 providerId = new Guid("8F5C5018-AE09-42cf-B2CC-2CCCC7CFC2BB"); break;
46 case "System.Data.SqlClient": 46 case "System.Data.SqlClient":
47 providerId = new Guid("91510608-8809-4020-8897-FBA057E22D54"); break; 47 providerId = new Guid("91510608-8809-4020-8897-FBA057E22D54"); break;
48 case "System.Data.Odbc": 48 case "System.Data.Odbc":
49 providerId = new Guid("C3D4F4CE-2C48-4381-B4D6-34FA50C51C86"); break; 49 providerId = new Guid("C3D4F4CE-2C48-4381-B4D6-34FA50C51C86"); break;
50 50
51 default: 51 default:
52 throw new ArgumentOutOfRangeException("providerName", providerName, "Could not provider name to an id."); 52 throw new ArgumentOutOfRangeException("providerName", providerName, "Could not provider name to an id.");
53 } 53 }
54 } 54 }
55 else 55 else
56 providerId = new Guid(Helper.AttributeValue(node, "providerId", Guid.Empty.ToString("B"))); 56 providerId = new Guid(Helper.AttributeValue(node, "providerId", Guid.Empty.ToString("B")));
57 57
58 connectionString = Helper.AttributeValue(node, "connectionString", connectionString); 58 connectionString = Helper.AttributeValue(node, "connectionString", connectionString);
59 59
60 base.Parse(node); 60 base.Parse(node);
61 } 61 }
62 } 62 }
63} 63}
diff --git a/Prebuild/src/Core/Targets/.svn/text-base/AutotoolsTarget.cs.svn-base b/Prebuild/src/Core/Targets/.svn/text-base/AutotoolsTarget.cs.svn-base
index e46b5a5..485e4dd 100644
--- a/Prebuild/src/Core/Targets/.svn/text-base/AutotoolsTarget.cs.svn-base
+++ b/Prebuild/src/Core/Targets/.svn/text-base/AutotoolsTarget.cs.svn-base
@@ -1,1070 +1,1070 @@
1#region BSD License 1#region BSD License
2/* 2/*
3 3
4Copyright (c) 2004 - 2008 4Copyright (c) 2004 - 2008
5Matthew Holmes (matthew@wildfiregames.com), 5Matthew Holmes (matthew@wildfiregames.com),
6Dan Moorehead (dan05a@gmail.com), 6Dan Moorehead (dan05a@gmail.com),
7Dave Hudson (jendave@yahoo.com), 7Dave Hudson (jendave@yahoo.com),
8C.J. Adams-Collier (cjac@colliertech.org), 8C.J. Adams-Collier (cjac@colliertech.org),
9 9
10Redistribution and use in source and binary forms, with or without 10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are 11modification, are permitted provided that the following conditions are
12met: 12met:
13 13
14* Redistributions of source code must retain the above copyright 14* Redistributions of source code must retain the above copyright
15notice, this list of conditions and the following disclaimer. 15notice, this list of conditions and the following disclaimer.
16 16
17* Redistributions in binary form must reproduce the above copyright 17* Redistributions in binary form must reproduce the above copyright
18notice, this list of conditions and the following disclaimer in the 18notice, this list of conditions and the following disclaimer in the
19documentation and/or other materials provided with the distribution. 19documentation and/or other materials provided with the distribution.
20 20
21* The name of the author may not be used to endorse or promote 21* The name of the author may not be used to endorse or promote
22products derived from this software without specific prior written 22products derived from this software without specific prior written
23permission. 23permission.
24 24
25THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 25THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
26IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 26IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
27WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 28DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
29INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
33STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 33STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
34IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35POSSIBILITY OF SUCH DAMAGE. 35POSSIBILITY OF SUCH DAMAGE.
36 36
37*/ 37*/
38#endregion 38#endregion
39 39
40#region MIT X11 license 40#region MIT X11 license
41 41
42/* 42/*
43 Portions of this file authored by Lluis Sanchez Gual 43 Portions of this file authored by Lluis Sanchez Gual
44 44
45 Copyright (C) 2006 Novell, Inc (http://www.novell.com) 45 Copyright (C) 2006 Novell, Inc (http://www.novell.com)
46 46
47 Permission is hereby granted, free of charge, to any person obtaining 47 Permission is hereby granted, free of charge, to any person obtaining
48 a copy of this software and associated documentation files (the 48 a copy of this software and associated documentation files (the
49 "Software"), to deal in the Software without restriction, including 49 "Software"), to deal in the Software without restriction, including
50 without limitation the rights to use, copy, modify, merge, publish, 50 without limitation the rights to use, copy, modify, merge, publish,
51 distribute, sublicense, and/or sell copies of the Software, and to 51 distribute, sublicense, and/or sell copies of the Software, and to
52 permit persons to whom the Software is furnished to do so, subject to 52 permit persons to whom the Software is furnished to do so, subject to
53 the following conditions: 53 the following conditions:
54 54
55 The above copyright notice and this permission notice shall be 55 The above copyright notice and this permission notice shall be
56 included in all copies or substantial portions of the Software. 56 included in all copies or substantial portions of the Software.
57 57
58 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 58 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
59 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 59 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
60 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 60 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
61 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 61 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
62 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 62 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
63 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 63 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
64 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 64 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
65 */ 65 */
66 66
67#endregion 67#endregion
68using System; 68using System;
69using System.Collections.Generic; 69using System.Collections.Generic;
70using System.IO; 70using System.IO;
71using System.Reflection; 71using System.Reflection;
72using System.Text; 72using System.Text;
73using System.Text.RegularExpressions; 73using System.Text.RegularExpressions;
74using System.Xml; 74using System.Xml;
75using System.Xml.Xsl; 75using System.Xml.Xsl;
76using System.Net; 76using System.Net;
77using System.Diagnostics; 77using System.Diagnostics;
78 78
79using Prebuild.Core.Attributes; 79using Prebuild.Core.Attributes;
80using Prebuild.Core.Interfaces; 80using Prebuild.Core.Interfaces;
81using Prebuild.Core.Nodes; 81using Prebuild.Core.Nodes;
82using Prebuild.Core.Utilities; 82using Prebuild.Core.Utilities;
83 83
84namespace Prebuild.Core.Targets 84namespace Prebuild.Core.Targets
85{ 85{
86 public enum ClrVersion 86 public enum ClrVersion
87 { 87 {
88 Default, 88 Default,
89 Net_1_1, 89 Net_1_1,
90 Net_2_0 90 Net_2_0
91 } 91 }
92 92
93 public class SystemPackage 93 public class SystemPackage
94 { 94 {
95 string name; 95 string name;
96 string version; 96 string version;
97 string description; 97 string description;
98 string[] assemblies; 98 string[] assemblies;
99 bool isInternal; 99 bool isInternal;
100 ClrVersion targetVersion; 100 ClrVersion targetVersion;
101 101
102 public void Initialize(string name, 102 public void Initialize(string name,
103 string version, 103 string version,
104 string description, 104 string description,
105 string[] assemblies, 105 string[] assemblies,
106 ClrVersion targetVersion, 106 ClrVersion targetVersion,
107 bool isInternal) 107 bool isInternal)
108 { 108 {
109 this.isInternal = isInternal; 109 this.isInternal = isInternal;
110 this.name = name; 110 this.name = name;
111 this.version = version; 111 this.version = version;
112 this.assemblies = assemblies; 112 this.assemblies = assemblies;
113 this.description = description; 113 this.description = description;
114 this.targetVersion = targetVersion; 114 this.targetVersion = targetVersion;
115 } 115 }
116 116
117 public string Name 117 public string Name
118 { 118 {
119 get { return name; } 119 get { return name; }
120 } 120 }
121 121
122 public string Version 122 public string Version
123 { 123 {
124 get { return version; } 124 get { return version; }
125 } 125 }
126 126
127 public string Description 127 public string Description
128 { 128 {
129 get { return description; } 129 get { return description; }
130 } 130 }
131 131
132 public ClrVersion TargetVersion 132 public ClrVersion TargetVersion
133 { 133 {
134 get { return targetVersion; } 134 get { return targetVersion; }
135 } 135 }
136 136
137 // The package is part of the mono SDK 137 // The package is part of the mono SDK
138 public bool IsCorePackage 138 public bool IsCorePackage
139 { 139 {
140 get { return name == "mono"; } 140 get { return name == "mono"; }
141 } 141 }
142 142
143 // The package has been registered by an add-in, and is not installed 143 // The package has been registered by an add-in, and is not installed
144 // in the system. 144 // in the system.
145 public bool IsInternalPackage 145 public bool IsInternalPackage
146 { 146 {
147 get { return isInternal; } 147 get { return isInternal; }
148 } 148 }
149 149
150 public string[] Assemblies 150 public string[] Assemblies
151 { 151 {
152 get { return assemblies; } 152 get { return assemblies; }
153 } 153 }
154 154
155 } 155 }
156 156
157 157
158 /// <summary> 158 /// <summary>
159 /// 159 ///
160 /// </summary> 160 /// </summary>
161 [Target("autotools")] 161 [Target("autotools")]
162 public class AutotoolsTarget : ITarget 162 public class AutotoolsTarget : ITarget
163 { 163 {
164 #region Fields 164 #region Fields
165 165
166 Kernel m_Kernel; 166 Kernel m_Kernel;
167 XmlDocument autotoolsDoc; 167 XmlDocument autotoolsDoc;
168 XmlUrlResolver xr; 168 XmlUrlResolver xr;
169 System.Security.Policy.Evidence e; 169 System.Security.Policy.Evidence e;
170 readonly Dictionary<string, SystemPackage> assemblyPathToPackage = new Dictionary<string, SystemPackage>(); 170 readonly Dictionary<string, SystemPackage> assemblyPathToPackage = new Dictionary<string, SystemPackage>();
171 readonly Dictionary<string, string> assemblyFullNameToPath = new Dictionary<string, string>(); 171 readonly Dictionary<string, string> assemblyFullNameToPath = new Dictionary<string, string>();
172 readonly Dictionary<string, SystemPackage> packagesHash = new Dictionary<string, SystemPackage>(); 172 readonly Dictionary<string, SystemPackage> packagesHash = new Dictionary<string, SystemPackage>();
173 readonly List<SystemPackage> packages = new List<SystemPackage>(); 173 readonly List<SystemPackage> packages = new List<SystemPackage>();
174 174
175 #endregion 175 #endregion
176 176
177 #region Private Methods 177 #region Private Methods
178 178
179 private static void mkdirDashP(string dirName) 179 private static void mkdirDashP(string dirName)
180 { 180 {
181 DirectoryInfo di = new DirectoryInfo(dirName); 181 DirectoryInfo di = new DirectoryInfo(dirName);
182 if (di.Exists) 182 if (di.Exists)
183 return; 183 return;
184 184
185 string parentDirName = System.IO.Path.GetDirectoryName(dirName); 185 string parentDirName = System.IO.Path.GetDirectoryName(dirName);
186 DirectoryInfo parentDi = new DirectoryInfo(parentDirName); 186 DirectoryInfo parentDi = new DirectoryInfo(parentDirName);
187 if (!parentDi.Exists) 187 if (!parentDi.Exists)
188 mkdirDashP(parentDirName); 188 mkdirDashP(parentDirName);
189 189
190 di.Create(); 190 di.Create();
191 } 191 }
192 192
193 private static void chkMkDir(string dirName) 193 private static void chkMkDir(string dirName)
194 { 194 {
195 System.IO.DirectoryInfo di = 195 System.IO.DirectoryInfo di =
196 new System.IO.DirectoryInfo(dirName); 196 new System.IO.DirectoryInfo(dirName);
197 197
198 if (!di.Exists) 198 if (!di.Exists)
199 di.Create(); 199 di.Create();
200 } 200 }
201 201
202 private void transformToFile(string filename, XsltArgumentList argList, string nodeName) 202 private void transformToFile(string filename, XsltArgumentList argList, string nodeName)
203 { 203 {
204 // Create an XslTransform for this file 204 // Create an XslTransform for this file
205 XslTransform templateTransformer = 205 XslTransform templateTransformer =
206 new XslTransform(); 206 new XslTransform();
207 207
208 // Load up the template 208 // Load up the template
209 XmlNode templateNode = 209 XmlNode templateNode =
210 autotoolsDoc.SelectSingleNode(nodeName + "/*"); 210 autotoolsDoc.SelectSingleNode(nodeName + "/*");
211 templateTransformer.Load(templateNode.CreateNavigator(), xr, e); 211 templateTransformer.Load(templateNode.CreateNavigator(), xr, e);
212 212
213 // Create a writer for the transformed template 213 // Create a writer for the transformed template
214 XmlTextWriter templateWriter = 214 XmlTextWriter templateWriter =
215 new XmlTextWriter(filename, null); 215 new XmlTextWriter(filename, null);
216 216
217 // Perform transformation, writing the file 217 // Perform transformation, writing the file
218 templateTransformer.Transform 218 templateTransformer.Transform
219 (m_Kernel.CurrentDoc, argList, templateWriter, xr); 219 (m_Kernel.CurrentDoc, argList, templateWriter, xr);
220 } 220 }
221 221
222 static string NormalizeAsmName(string name) 222 static string NormalizeAsmName(string name)
223 { 223 {
224 int i = name.IndexOf(", PublicKeyToken=null"); 224 int i = name.IndexOf(", PublicKeyToken=null");
225 if (i != -1) 225 if (i != -1)
226 return name.Substring(0, i).Trim(); 226 return name.Substring(0, i).Trim();
227 return name; 227 return name;
228 } 228 }
229 229
230 private void AddAssembly(string assemblyfile, SystemPackage package) 230 private void AddAssembly(string assemblyfile, SystemPackage package)
231 { 231 {
232 if (!File.Exists(assemblyfile)) 232 if (!File.Exists(assemblyfile))
233 return; 233 return;
234 234
235 try 235 try
236 { 236 {
237 System.Reflection.AssemblyName an = System.Reflection.AssemblyName.GetAssemblyName(assemblyfile); 237 System.Reflection.AssemblyName an = System.Reflection.AssemblyName.GetAssemblyName(assemblyfile);
238 assemblyFullNameToPath[NormalizeAsmName(an.FullName)] = assemblyfile; 238 assemblyFullNameToPath[NormalizeAsmName(an.FullName)] = assemblyfile;
239 assemblyPathToPackage[assemblyfile] = package; 239 assemblyPathToPackage[assemblyfile] = package;
240 } 240 }
241 catch 241 catch
242 { 242 {
243 } 243 }
244 } 244 }
245 245
246 private static List<string> GetAssembliesWithLibInfo(string line, string file) 246 private static List<string> GetAssembliesWithLibInfo(string line, string file)
247 { 247 {
248 List<string> references = new List<string>(); 248 List<string> references = new List<string>();
249 List<string> libdirs = new List<string>(); 249 List<string> libdirs = new List<string>();
250 List<string> retval = new List<string>(); 250 List<string> retval = new List<string>();
251 foreach (string piece in line.Split(' ')) 251 foreach (string piece in line.Split(' '))
252 { 252 {
253 if (piece.ToLower().Trim().StartsWith("/r:") || piece.ToLower().Trim().StartsWith("-r:")) 253 if (piece.ToLower().Trim().StartsWith("/r:") || piece.ToLower().Trim().StartsWith("-r:"))
254 { 254 {
255 references.Add(ProcessPiece(piece.Substring(3).Trim(), file)); 255 references.Add(ProcessPiece(piece.Substring(3).Trim(), file));
256 } 256 }
257 else if (piece.ToLower().Trim().StartsWith("/lib:") || piece.ToLower().Trim().StartsWith("-lib:")) 257 else if (piece.ToLower().Trim().StartsWith("/lib:") || piece.ToLower().Trim().StartsWith("-lib:"))
258 { 258 {
259 libdirs.Add(ProcessPiece(piece.Substring(5).Trim(), file)); 259 libdirs.Add(ProcessPiece(piece.Substring(5).Trim(), file));
260 } 260 }
261 } 261 }
262 262
263 foreach (string refrnc in references) 263 foreach (string refrnc in references)
264 { 264 {
265 foreach (string libdir in libdirs) 265 foreach (string libdir in libdirs)
266 { 266 {
267 if (File.Exists(libdir + Path.DirectorySeparatorChar + refrnc)) 267 if (File.Exists(libdir + Path.DirectorySeparatorChar + refrnc))
268 { 268 {
269 retval.Add(libdir + Path.DirectorySeparatorChar + refrnc); 269 retval.Add(libdir + Path.DirectorySeparatorChar + refrnc);
270 } 270 }
271 } 271 }
272 } 272 }
273 273
274 return retval; 274 return retval;
275 } 275 }
276 276
277 private static List<string> GetAssembliesWithoutLibInfo(string line, string file) 277 private static List<string> GetAssembliesWithoutLibInfo(string line, string file)
278 { 278 {
279 List<string> references = new List<string>(); 279 List<string> references = new List<string>();
280 foreach (string reference in line.Split(' ')) 280 foreach (string reference in line.Split(' '))
281 { 281 {
282 if (reference.ToLower().Trim().StartsWith("/r:") || reference.ToLower().Trim().StartsWith("-r:")) 282 if (reference.ToLower().Trim().StartsWith("/r:") || reference.ToLower().Trim().StartsWith("-r:"))
283 { 283 {
284 string final_ref = reference.Substring(3).Trim(); 284 string final_ref = reference.Substring(3).Trim();
285 references.Add(ProcessPiece(final_ref, file)); 285 references.Add(ProcessPiece(final_ref, file));
286 } 286 }
287 } 287 }
288 return references; 288 return references;
289 } 289 }
290 290
291 private static string ProcessPiece(string piece, string pcfile) 291 private static string ProcessPiece(string piece, string pcfile)
292 { 292 {
293 int start = piece.IndexOf("${"); 293 int start = piece.IndexOf("${");
294 if (start == -1) 294 if (start == -1)
295 return piece; 295 return piece;
296 296
297 int end = piece.IndexOf("}"); 297 int end = piece.IndexOf("}");
298 if (end == -1) 298 if (end == -1)
299 return piece; 299 return piece;
300 300
301 string variable = piece.Substring(start + 2, end - start - 2); 301 string variable = piece.Substring(start + 2, end - start - 2);
302 string interp = GetVariableFromPkgConfig(variable, Path.GetFileNameWithoutExtension(pcfile)); 302 string interp = GetVariableFromPkgConfig(variable, Path.GetFileNameWithoutExtension(pcfile));
303 return ProcessPiece(piece.Replace("${" + variable + "}", interp), pcfile); 303 return ProcessPiece(piece.Replace("${" + variable + "}", interp), pcfile);
304 } 304 }
305 305
306 private static string GetVariableFromPkgConfig(string var, string pcfile) 306 private static string GetVariableFromPkgConfig(string var, string pcfile)
307 { 307 {
308 ProcessStartInfo psi = new ProcessStartInfo("pkg-config"); 308 ProcessStartInfo psi = new ProcessStartInfo("pkg-config");
309 psi.RedirectStandardOutput = true; 309 psi.RedirectStandardOutput = true;
310 psi.UseShellExecute = false; 310 psi.UseShellExecute = false;
311 psi.Arguments = String.Format("--variable={0} {1}", var, pcfile); 311 psi.Arguments = String.Format("--variable={0} {1}", var, pcfile);
312 Process p = new Process(); 312 Process p = new Process();
313 p.StartInfo = psi; 313 p.StartInfo = psi;
314 p.Start(); 314 p.Start();
315 string ret = p.StandardOutput.ReadToEnd().Trim(); 315 string ret = p.StandardOutput.ReadToEnd().Trim();
316 p.WaitForExit(); 316 p.WaitForExit();
317 if (String.IsNullOrEmpty(ret)) 317 if (String.IsNullOrEmpty(ret))
318 return String.Empty; 318 return String.Empty;
319 return ret; 319 return ret;
320 } 320 }
321 321
322 private void ParsePCFile(string pcfile) 322 private void ParsePCFile(string pcfile)
323 { 323 {
324 // Don't register the package twice 324 // Don't register the package twice
325 string pname = Path.GetFileNameWithoutExtension(pcfile); 325 string pname = Path.GetFileNameWithoutExtension(pcfile);
326 if (packagesHash.ContainsKey(pname)) 326 if (packagesHash.ContainsKey(pname))
327 return; 327 return;
328 328
329 List<string> fullassemblies = null; 329 List<string> fullassemblies = null;
330 string version = ""; 330 string version = "";
331 string desc = ""; 331 string desc = "";
332 332
333 SystemPackage package = new SystemPackage(); 333 SystemPackage package = new SystemPackage();
334 334
335 using (StreamReader reader = new StreamReader(pcfile)) 335 using (StreamReader reader = new StreamReader(pcfile))
336 { 336 {
337 string line; 337 string line;
338 while ((line = reader.ReadLine()) != null) 338 while ((line = reader.ReadLine()) != null)
339 { 339 {
340 string lowerLine = line.ToLower(); 340 string lowerLine = line.ToLower();
341 if (lowerLine.StartsWith("libs:") && lowerLine.IndexOf(".dll") != -1) 341 if (lowerLine.StartsWith("libs:") && lowerLine.IndexOf(".dll") != -1)
342 { 342 {
343 string choppedLine = line.Substring(5).Trim(); 343 string choppedLine = line.Substring(5).Trim();
344 if (choppedLine.IndexOf("-lib:") != -1 || choppedLine.IndexOf("/lib:") != -1) 344 if (choppedLine.IndexOf("-lib:") != -1 || choppedLine.IndexOf("/lib:") != -1)
345 { 345 {
346 fullassemblies = GetAssembliesWithLibInfo(choppedLine, pcfile); 346 fullassemblies = GetAssembliesWithLibInfo(choppedLine, pcfile);
347 } 347 }
348 else 348 else
349 { 349 {
350 fullassemblies = GetAssembliesWithoutLibInfo(choppedLine, pcfile); 350 fullassemblies = GetAssembliesWithoutLibInfo(choppedLine, pcfile);
351 } 351 }
352 } 352 }
353 else if (lowerLine.StartsWith("version:")) 353 else if (lowerLine.StartsWith("version:"))
354 { 354 {
355 // "version:".Length == 8 355 // "version:".Length == 8
356 version = line.Substring(8).Trim(); 356 version = line.Substring(8).Trim();
357 } 357 }
358 else if (lowerLine.StartsWith("description:")) 358 else if (lowerLine.StartsWith("description:"))
359 { 359 {
360 // "description:".Length == 12 360 // "description:".Length == 12
361 desc = line.Substring(12).Trim(); 361 desc = line.Substring(12).Trim();
362 } 362 }
363 } 363 }
364 } 364 }
365 365
366 if (fullassemblies == null) 366 if (fullassemblies == null)
367 return; 367 return;
368 368
369 foreach (string assembly in fullassemblies) 369 foreach (string assembly in fullassemblies)
370 { 370 {
371 AddAssembly(assembly, package); 371 AddAssembly(assembly, package);
372 } 372 }
373 373
374 package.Initialize(pname, 374 package.Initialize(pname,
375 version, 375 version,
376 desc, 376 desc,
377 fullassemblies.ToArray(), 377 fullassemblies.ToArray(),
378 ClrVersion.Default, 378 ClrVersion.Default,
379 false); 379 false);
380 packages.Add(package); 380 packages.Add(package);
381 packagesHash[pname] = package; 381 packagesHash[pname] = package;
382 } 382 }
383 383
384 void RegisterSystemAssemblies(string prefix, string version, ClrVersion ver) 384 void RegisterSystemAssemblies(string prefix, string version, ClrVersion ver)
385 { 385 {
386 SystemPackage package = new SystemPackage(); 386 SystemPackage package = new SystemPackage();
387 List<string> list = new List<string>(); 387 List<string> list = new List<string>();
388 388
389 string dir = Path.Combine(prefix, version); 389 string dir = Path.Combine(prefix, version);
390 if (!Directory.Exists(dir)) 390 if (!Directory.Exists(dir))
391 { 391 {
392 return; 392 return;
393 } 393 }
394 394
395 foreach (string assembly in Directory.GetFiles(dir, "*.dll")) 395 foreach (string assembly in Directory.GetFiles(dir, "*.dll"))
396 { 396 {
397 AddAssembly(assembly, package); 397 AddAssembly(assembly, package);
398 list.Add(assembly); 398 list.Add(assembly);
399 } 399 }
400 400
401 package.Initialize("mono", 401 package.Initialize("mono",
402 version, 402 version,
403 "The Mono runtime", 403 "The Mono runtime",
404 list.ToArray(), 404 list.ToArray(),
405 ver, 405 ver,
406 false); 406 false);
407 packages.Add(package); 407 packages.Add(package);
408 } 408 }
409 409
410 void RunInitialization() 410 void RunInitialization()
411 { 411 {
412 string versionDir; 412 string versionDir;
413 413
414 if (Environment.Version.Major == 1) 414 if (Environment.Version.Major == 1)
415 { 415 {
416 versionDir = "1.0"; 416 versionDir = "1.0";
417 } 417 }
418 else 418 else
419 { 419 {
420 versionDir = "2.0"; 420 versionDir = "2.0";
421 } 421 }
422 422
423 //Pull up assemblies from the installed mono system. 423 //Pull up assemblies from the installed mono system.
424 string prefix = Path.GetDirectoryName(typeof(int).Assembly.Location); 424 string prefix = Path.GetDirectoryName(typeof(int).Assembly.Location);
425 425
426 if (prefix.IndexOf(Path.Combine("mono", versionDir)) == -1) 426 if (prefix.IndexOf(Path.Combine("mono", versionDir)) == -1)
427 prefix = Path.Combine(prefix, "mono"); 427 prefix = Path.Combine(prefix, "mono");
428 else 428 else
429 prefix = Path.GetDirectoryName(prefix); 429 prefix = Path.GetDirectoryName(prefix);
430 430
431 RegisterSystemAssemblies(prefix, "1.0", ClrVersion.Net_1_1); 431 RegisterSystemAssemblies(prefix, "1.0", ClrVersion.Net_1_1);
432 RegisterSystemAssemblies(prefix, "2.0", ClrVersion.Net_2_0); 432 RegisterSystemAssemblies(prefix, "2.0", ClrVersion.Net_2_0);
433 433
434 string search_dirs = Environment.GetEnvironmentVariable("PKG_CONFIG_PATH"); 434 string search_dirs = Environment.GetEnvironmentVariable("PKG_CONFIG_PATH");
435 string libpath = Environment.GetEnvironmentVariable("PKG_CONFIG_LIBPATH"); 435 string libpath = Environment.GetEnvironmentVariable("PKG_CONFIG_LIBPATH");
436 436
437 if (String.IsNullOrEmpty(libpath)) 437 if (String.IsNullOrEmpty(libpath))
438 { 438 {
439 string path_dirs = Environment.GetEnvironmentVariable("PATH"); 439 string path_dirs = Environment.GetEnvironmentVariable("PATH");
440 foreach (string pathdir in path_dirs.Split(Path.PathSeparator)) 440 foreach (string pathdir in path_dirs.Split(Path.PathSeparator))
441 { 441 {
442 if (pathdir == null) 442 if (pathdir == null)
443 continue; 443 continue;
444 if (File.Exists(pathdir + Path.DirectorySeparatorChar + "pkg-config")) 444 if (File.Exists(pathdir + Path.DirectorySeparatorChar + "pkg-config"))
445 { 445 {
446 libpath = Path.Combine(pathdir, ".."); 446 libpath = Path.Combine(pathdir, "..");
447 libpath = Path.Combine(libpath, "lib"); 447 libpath = Path.Combine(libpath, "lib");
448 libpath = Path.Combine(libpath, "pkgconfig"); 448 libpath = Path.Combine(libpath, "pkgconfig");
449 break; 449 break;
450 } 450 }
451 } 451 }
452 } 452 }
453 search_dirs += Path.PathSeparator + libpath; 453 search_dirs += Path.PathSeparator + libpath;
454 if (!string.IsNullOrEmpty(search_dirs)) 454 if (!string.IsNullOrEmpty(search_dirs))
455 { 455 {
456 List<string> scanDirs = new List<string>(); 456 List<string> scanDirs = new List<string>();
457 foreach (string potentialDir in search_dirs.Split(Path.PathSeparator)) 457 foreach (string potentialDir in search_dirs.Split(Path.PathSeparator))
458 { 458 {
459 if (!scanDirs.Contains(potentialDir)) 459 if (!scanDirs.Contains(potentialDir))
460 scanDirs.Add(potentialDir); 460 scanDirs.Add(potentialDir);
461 } 461 }
462 foreach (string pcdir in scanDirs) 462 foreach (string pcdir in scanDirs)
463 { 463 {
464 if (pcdir == null) 464 if (pcdir == null)
465 continue; 465 continue;
466 466
467 if (Directory.Exists(pcdir)) 467 if (Directory.Exists(pcdir))
468 { 468 {
469 foreach (string pcfile in Directory.GetFiles(pcdir, "*.pc")) 469 foreach (string pcfile in Directory.GetFiles(pcdir, "*.pc"))
470 { 470 {
471 ParsePCFile(pcfile); 471 ParsePCFile(pcfile);
472 } 472 }
473 } 473 }
474 } 474 }
475 } 475 }
476 } 476 }
477 477
478 private void WriteCombine(SolutionNode solution) 478 private void WriteCombine(SolutionNode solution)
479 { 479 {
480 #region "Create Solution directory if it doesn't exist" 480 #region "Create Solution directory if it doesn't exist"
481 string solutionDir = Path.Combine(solution.FullPath, 481 string solutionDir = Path.Combine(solution.FullPath,
482 Path.Combine("autotools", 482 Path.Combine("autotools",
483 solution.Name)); 483 solution.Name));
484 chkMkDir(solutionDir); 484 chkMkDir(solutionDir);
485 #endregion 485 #endregion
486 486
487 #region "Write Solution-level files" 487 #region "Write Solution-level files"
488 XsltArgumentList argList = new XsltArgumentList(); 488 XsltArgumentList argList = new XsltArgumentList();
489 argList.AddParam("solutionName", "", solution.Name); 489 argList.AddParam("solutionName", "", solution.Name);
490 // $solutionDir is $rootDir/$solutionName/ 490 // $solutionDir is $rootDir/$solutionName/
491 transformToFile(Path.Combine(solutionDir, "configure.ac"), 491 transformToFile(Path.Combine(solutionDir, "configure.ac"),
492 argList, "/Autotools/SolutionConfigureAc"); 492 argList, "/Autotools/SolutionConfigureAc");
493 transformToFile(Path.Combine(solutionDir, "Makefile.am"), 493 transformToFile(Path.Combine(solutionDir, "Makefile.am"),
494 argList, "/Autotools/SolutionMakefileAm"); 494 argList, "/Autotools/SolutionMakefileAm");
495 transformToFile(Path.Combine(solutionDir, "autogen.sh"), 495 transformToFile(Path.Combine(solutionDir, "autogen.sh"),
496 argList, "/Autotools/SolutionAutogenSh"); 496 argList, "/Autotools/SolutionAutogenSh");
497 #endregion 497 #endregion
498 498
499 foreach (ProjectNode project in solution.ProjectsTableOrder) 499 foreach (ProjectNode project in solution.ProjectsTableOrder)
500 { 500 {
501 m_Kernel.Log.Write(String.Format("Writing project: {0}", 501 m_Kernel.Log.Write(String.Format("Writing project: {0}",
502 project.Name)); 502 project.Name));
503 WriteProject(solution, project); 503 WriteProject(solution, project);
504 } 504 }
505 } 505 }
506 506
507 private static string FindFileReference(string refName, 507 private static string FindFileReference(string refName,
508 ProjectNode project) 508 ProjectNode project)
509 { 509 {
510 foreach (ReferencePathNode refPath in project.ReferencePaths) 510 foreach (ReferencePathNode refPath in project.ReferencePaths)
511 { 511 {
512 string fullPath = 512 string fullPath =
513 Helper.MakeFilePath(refPath.Path, refName, "dll"); 513 Helper.MakeFilePath(refPath.Path, refName, "dll");
514 514
515 if (File.Exists(fullPath)) { 515 if (File.Exists(fullPath)) {
516 return fullPath; 516 return fullPath;
517 } 517 }
518 } 518 }
519 519
520 return null; 520 return null;
521 } 521 }
522 522
523 /// <summary> 523 /// <summary>
524 /// Gets the XML doc file. 524 /// Gets the XML doc file.
525 /// </summary> 525 /// </summary>
526 /// <param name="project">The project.</param> 526 /// <param name="project">The project.</param>
527 /// <param name="conf">The conf.</param> 527 /// <param name="conf">The conf.</param>
528 /// <returns></returns> 528 /// <returns></returns>
529 public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf) 529 public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf)
530 { 530 {
531 if (conf == null) 531 if (conf == null)
532 { 532 {
533 throw new ArgumentNullException("conf"); 533 throw new ArgumentNullException("conf");
534 } 534 }
535 if (project == null) 535 if (project == null)
536 { 536 {
537 throw new ArgumentNullException("project"); 537 throw new ArgumentNullException("project");
538 } 538 }
539 string docFile = (string)conf.Options["XmlDocFile"]; 539 string docFile = (string)conf.Options["XmlDocFile"];
540 // if(docFile != null && docFile.Length == 0)//default to assembly name if not specified 540 // if(docFile != null && docFile.Length == 0)//default to assembly name if not specified
541 // { 541 // {
542 // return Path.GetFileNameWithoutExtension(project.AssemblyName) + ".xml"; 542 // return Path.GetFileNameWithoutExtension(project.AssemblyName) + ".xml";
543 // } 543 // }
544 return docFile; 544 return docFile;
545 } 545 }
546 546
547 /// <summary> 547 /// <summary>
548 /// Normalizes the path. 548 /// Normalizes the path.
549 /// </summary> 549 /// </summary>
550 /// <param name="path">The path.</param> 550 /// <param name="path">The path.</param>
551 /// <returns></returns> 551 /// <returns></returns>
552 public static string NormalizePath(string path) 552 public static string NormalizePath(string path)
553 { 553 {
554 if (path == null) 554 if (path == null)
555 { 555 {
556 return ""; 556 return "";
557 } 557 }
558 558
559 StringBuilder tmpPath; 559 StringBuilder tmpPath;
560 560
561 if (Core.Parse.Preprocessor.GetOS() == "Win32") 561 if (Core.Parse.Preprocessor.GetOS() == "Win32")
562 { 562 {
563 tmpPath = new StringBuilder(path.Replace('\\', '/')); 563 tmpPath = new StringBuilder(path.Replace('\\', '/'));
564 tmpPath.Replace("/", @"\\"); 564 tmpPath.Replace("/", @"\\");
565 } 565 }
566 else 566 else
567 { 567 {
568 tmpPath = new StringBuilder(path.Replace('\\', '/')); 568 tmpPath = new StringBuilder(path.Replace('\\', '/'));
569 tmpPath = tmpPath.Replace('/', Path.DirectorySeparatorChar); 569 tmpPath = tmpPath.Replace('/', Path.DirectorySeparatorChar);
570 } 570 }
571 return tmpPath.ToString(); 571 return tmpPath.ToString();
572 } 572 }
573 573
574 private void WriteProject(SolutionNode solution, ProjectNode project) 574 private void WriteProject(SolutionNode solution, ProjectNode project)
575 { 575 {
576 string solutionDir = Path.Combine(solution.FullPath, Path.Combine("autotools", solution.Name)); 576 string solutionDir = Path.Combine(solution.FullPath, Path.Combine("autotools", solution.Name));
577 string projectDir = Path.Combine(solutionDir, project.Name); 577 string projectDir = Path.Combine(solutionDir, project.Name);
578 string projectVersion = project.Version; 578 string projectVersion = project.Version;
579 bool hasAssemblyConfig = false; 579 bool hasAssemblyConfig = false;
580 chkMkDir(projectDir); 580 chkMkDir(projectDir);
581 581
582 List<string> 582 List<string>
583 compiledFiles = new List<string>(), 583 compiledFiles = new List<string>(),
584 contentFiles = new List<string>(), 584 contentFiles = new List<string>(),
585 embeddedFiles = new List<string>(), 585 embeddedFiles = new List<string>(),
586 586
587 binaryLibs = new List<string>(), 587 binaryLibs = new List<string>(),
588 pkgLibs = new List<string>(), 588 pkgLibs = new List<string>(),
589 systemLibs = new List<string>(), 589 systemLibs = new List<string>(),
590 runtimeLibs = new List<string>(), 590 runtimeLibs = new List<string>(),
591 591
592 extraDistFiles = new List<string>(), 592 extraDistFiles = new List<string>(),
593 localCopyTargets = new List<string>(); 593 localCopyTargets = new List<string>();
594 594
595 // If there exists a .config file for this assembly, copy 595 // If there exists a .config file for this assembly, copy
596 // it to the project folder 596 // it to the project folder
597 597
598 // TODO: Support copying .config.osx files 598 // TODO: Support copying .config.osx files
599 // TODO: support processing the .config file for native library deps 599 // TODO: support processing the .config file for native library deps
600 string projectAssemblyName = project.Name; 600 string projectAssemblyName = project.Name;
601 if (project.AssemblyName != null) 601 if (project.AssemblyName != null)
602 projectAssemblyName = project.AssemblyName; 602 projectAssemblyName = project.AssemblyName;
603 603
604 if (File.Exists(Path.Combine(project.FullPath, projectAssemblyName) + ".dll.config")) 604 if (File.Exists(Path.Combine(project.FullPath, projectAssemblyName) + ".dll.config"))
605 { 605 {
606 hasAssemblyConfig = true; 606 hasAssemblyConfig = true;
607 System.IO.File.Copy(Path.Combine(project.FullPath, projectAssemblyName + ".dll.config"), Path.Combine(projectDir, projectAssemblyName + ".dll.config"), true); 607 System.IO.File.Copy(Path.Combine(project.FullPath, projectAssemblyName + ".dll.config"), Path.Combine(projectDir, projectAssemblyName + ".dll.config"), true);
608 extraDistFiles.Add(project.AssemblyName + ".dll.config"); 608 extraDistFiles.Add(project.AssemblyName + ".dll.config");
609 } 609 }
610 610
611 foreach (ConfigurationNode conf in project.Configurations) 611 foreach (ConfigurationNode conf in project.Configurations)
612 { 612 {
613 if (conf.Options.KeyFile != string.Empty) 613 if (conf.Options.KeyFile != string.Empty)
614 { 614 {
615 // Copy snk file into the project's directory 615 // Copy snk file into the project's directory
616 // Use the snk from the project directory directly 616 // Use the snk from the project directory directly
617 string source = Path.Combine(project.FullPath, conf.Options.KeyFile); 617 string source = Path.Combine(project.FullPath, conf.Options.KeyFile);
618 string keyFile = conf.Options.KeyFile; 618 string keyFile = conf.Options.KeyFile;
619 Regex re = new Regex(".*/"); 619 Regex re = new Regex(".*/");
620 keyFile = re.Replace(keyFile, ""); 620 keyFile = re.Replace(keyFile, "");
621 621
622 string dest = Path.Combine(projectDir, keyFile); 622 string dest = Path.Combine(projectDir, keyFile);
623 // Tell the user if there's a problem copying the file 623 // Tell the user if there's a problem copying the file
624 try 624 try
625 { 625 {
626 mkdirDashP(System.IO.Path.GetDirectoryName(dest)); 626 mkdirDashP(System.IO.Path.GetDirectoryName(dest));
627 System.IO.File.Copy(source, dest, true); 627 System.IO.File.Copy(source, dest, true);
628 } 628 }
629 catch (System.IO.IOException e) 629 catch (System.IO.IOException e)
630 { 630 {
631 Console.WriteLine(e.Message); 631 Console.WriteLine(e.Message);
632 } 632 }
633 } 633 }
634 } 634 }
635 635
636 // Copy compiled, embedded and content files into the project's directory 636 // Copy compiled, embedded and content files into the project's directory
637 foreach (string filename in project.Files) 637 foreach (string filename in project.Files)
638 { 638 {
639 string source = Path.Combine(project.FullPath, filename); 639 string source = Path.Combine(project.FullPath, filename);
640 string dest = Path.Combine(projectDir, filename); 640 string dest = Path.Combine(projectDir, filename);
641 641
642 if (filename.Contains("AssemblyInfo.cs")) 642 if (filename.Contains("AssemblyInfo.cs"))
643 { 643 {
644 // If we've got an AssemblyInfo.cs, pull the version number from it 644 // If we've got an AssemblyInfo.cs, pull the version number from it
645 string[] sources = { source }; 645 string[] sources = { source };
646 string[] args = { "" }; 646 string[] args = { "" };
647 Microsoft.CSharp.CSharpCodeProvider cscp = 647 Microsoft.CSharp.CSharpCodeProvider cscp =
648 new Microsoft.CSharp.CSharpCodeProvider(); 648 new Microsoft.CSharp.CSharpCodeProvider();
649 649
650 string tempAssemblyFile = Path.Combine(Path.GetTempPath(), project.Name + "-temp.dll"); 650 string tempAssemblyFile = Path.Combine(Path.GetTempPath(), project.Name + "-temp.dll");
651 System.CodeDom.Compiler.CompilerParameters cparam = 651 System.CodeDom.Compiler.CompilerParameters cparam =
652 new System.CodeDom.Compiler.CompilerParameters(args, tempAssemblyFile); 652 new System.CodeDom.Compiler.CompilerParameters(args, tempAssemblyFile);
653 653
654 System.CodeDom.Compiler.CompilerResults cr = 654 System.CodeDom.Compiler.CompilerResults cr =
655 cscp.CompileAssemblyFromFile(cparam, sources); 655 cscp.CompileAssemblyFromFile(cparam, sources);
656 656
657 foreach (System.CodeDom.Compiler.CompilerError error in cr.Errors) 657 foreach (System.CodeDom.Compiler.CompilerError error in cr.Errors)
658 Console.WriteLine("Error! '{0}'", error.ErrorText); 658 Console.WriteLine("Error! '{0}'", error.ErrorText);
659 659
660 try { 660 try {
661 string projectFullName = cr.CompiledAssembly.FullName; 661 string projectFullName = cr.CompiledAssembly.FullName;
662 Regex verRegex = new Regex("Version=([\\d\\.]+)"); 662 Regex verRegex = new Regex("Version=([\\d\\.]+)");
663 Match verMatch = verRegex.Match(projectFullName); 663 Match verMatch = verRegex.Match(projectFullName);
664 if (verMatch.Success) 664 if (verMatch.Success)
665 projectVersion = verMatch.Groups[1].Value; 665 projectVersion = verMatch.Groups[1].Value;
666 }catch{ 666 }catch{
667 Console.WriteLine("Couldn't compile AssemblyInfo.cs"); 667 Console.WriteLine("Couldn't compile AssemblyInfo.cs");
668 } 668 }
669 669
670 // Clean up the temp file 670 // Clean up the temp file
671 try 671 try
672 { 672 {
673 if (File.Exists(tempAssemblyFile)) 673 if (File.Exists(tempAssemblyFile))
674 File.Delete(tempAssemblyFile); 674 File.Delete(tempAssemblyFile);
675 } 675 }
676 catch 676 catch
677 { 677 {
678 Console.WriteLine("Error! '{0}'", e); 678 Console.WriteLine("Error! '{0}'", e);
679 } 679 }
680 680
681 } 681 }
682 682
683 // Tell the user if there's a problem copying the file 683 // Tell the user if there's a problem copying the file
684 try 684 try
685 { 685 {
686 mkdirDashP(System.IO.Path.GetDirectoryName(dest)); 686 mkdirDashP(System.IO.Path.GetDirectoryName(dest));
687 System.IO.File.Copy(source, dest, true); 687 System.IO.File.Copy(source, dest, true);
688 } 688 }
689 catch (System.IO.IOException e) 689 catch (System.IO.IOException e)
690 { 690 {
691 Console.WriteLine(e.Message); 691 Console.WriteLine(e.Message);
692 } 692 }
693 693
694 switch (project.Files.GetBuildAction(filename)) 694 switch (project.Files.GetBuildAction(filename))
695 { 695 {
696 case BuildAction.Compile: 696 case BuildAction.Compile:
697 compiledFiles.Add(filename); 697 compiledFiles.Add(filename);
698 break; 698 break;
699 case BuildAction.Content: 699 case BuildAction.Content:
700 contentFiles.Add(filename); 700 contentFiles.Add(filename);
701 extraDistFiles.Add(filename); 701 extraDistFiles.Add(filename);
702 break; 702 break;
703 case BuildAction.EmbeddedResource: 703 case BuildAction.EmbeddedResource:
704 embeddedFiles.Add(filename); 704 embeddedFiles.Add(filename);
705 break; 705 break;
706 } 706 }
707 } 707 }
708 708
709 // Set up references 709 // Set up references
710 for (int refNum = 0; refNum < project.References.Count; refNum++) 710 for (int refNum = 0; refNum < project.References.Count; refNum++)
711 { 711 {
712 ReferenceNode refr = project.References[refNum]; 712 ReferenceNode refr = project.References[refNum];
713 Assembly refAssembly = Assembly.LoadWithPartialName(refr.Name); 713 Assembly refAssembly = Assembly.LoadWithPartialName(refr.Name);
714 714
715 /* Determine which pkg-config (.pc) file refers to 715 /* Determine which pkg-config (.pc) file refers to
716 this assembly */ 716 this assembly */
717 717
718 SystemPackage package = null; 718 SystemPackage package = null;
719 719
720 if (packagesHash.ContainsKey(refr.Name)) 720 if (packagesHash.ContainsKey(refr.Name))
721 { 721 {
722 package = packagesHash[refr.Name]; 722 package = packagesHash[refr.Name];
723 723
724 } 724 }
725 else 725 else
726 { 726 {
727 string assemblyFullName = string.Empty; 727 string assemblyFullName = string.Empty;
728 if (refAssembly != null) 728 if (refAssembly != null)
729 assemblyFullName = refAssembly.FullName; 729 assemblyFullName = refAssembly.FullName;
730 730
731 string assemblyFileName = string.Empty; 731 string assemblyFileName = string.Empty;
732 if (assemblyFullName != string.Empty && 732 if (assemblyFullName != string.Empty &&
733 assemblyFullNameToPath.ContainsKey(assemblyFullName) 733 assemblyFullNameToPath.ContainsKey(assemblyFullName)
734 ) 734 )
735 assemblyFileName = 735 assemblyFileName =
736 assemblyFullNameToPath[assemblyFullName]; 736 assemblyFullNameToPath[assemblyFullName];
737 737
738 if (assemblyFileName != string.Empty && 738 if (assemblyFileName != string.Empty &&
739 assemblyPathToPackage.ContainsKey(assemblyFileName) 739 assemblyPathToPackage.ContainsKey(assemblyFileName)
740 ) 740 )
741 package = assemblyPathToPackage[assemblyFileName]; 741 package = assemblyPathToPackage[assemblyFileName];
742 742
743 } 743 }
744 744
745 /* If we know the .pc file and it is not "mono" 745 /* If we know the .pc file and it is not "mono"
746 (already in the path), add a -pkg: argument */ 746 (already in the path), add a -pkg: argument */
747 747
748 if (package != null && 748 if (package != null &&
749 package.Name != "mono" && 749 package.Name != "mono" &&
750 !pkgLibs.Contains(package.Name) 750 !pkgLibs.Contains(package.Name)
751 ) 751 )
752 pkgLibs.Add(package.Name); 752 pkgLibs.Add(package.Name);
753 753
754 string fileRef = 754 string fileRef =
755 FindFileReference(refr.Name, (ProjectNode)refr.Parent); 755 FindFileReference(refr.Name, (ProjectNode)refr.Parent);
756 756
757 if (refr.LocalCopy || 757 if (refr.LocalCopy ||
758 solution.ProjectsTable.ContainsKey(refr.Name) || 758 solution.ProjectsTable.ContainsKey(refr.Name) ||
759 fileRef != null || 759 fileRef != null ||
760 refr.Path != null 760 refr.Path != null
761 ) 761 )
762 { 762 {
763 763
764 /* Attempt to copy the referenced lib to the 764 /* Attempt to copy the referenced lib to the
765 project's directory */ 765 project's directory */
766 766
767 string filename = refr.Name + ".dll"; 767 string filename = refr.Name + ".dll";
768 string source = filename; 768 string source = filename;
769 if (refr.Path != null) 769 if (refr.Path != null)
770 source = Path.Combine(refr.Path, source); 770 source = Path.Combine(refr.Path, source);
771 source = Path.Combine(project.FullPath, source); 771 source = Path.Combine(project.FullPath, source);
772 string dest = Path.Combine(projectDir, filename); 772 string dest = Path.Combine(projectDir, filename);
773 773
774 /* Since we depend on this binary dll to build, we 774 /* Since we depend on this binary dll to build, we
775 * will add a compile- time dependency on the 775 * will add a compile- time dependency on the
776 * copied dll, and add the dll to the list of 776 * copied dll, and add the dll to the list of
777 * files distributed with this package 777 * files distributed with this package
778 */ 778 */
779 779
780 binaryLibs.Add(refr.Name + ".dll"); 780 binaryLibs.Add(refr.Name + ".dll");
781 extraDistFiles.Add(refr.Name + ".dll"); 781 extraDistFiles.Add(refr.Name + ".dll");
782 782
783 // TODO: Support copying .config.osx files 783 // TODO: Support copying .config.osx files
784 // TODO: Support for determining native dependencies 784 // TODO: Support for determining native dependencies
785 if (File.Exists(source + ".config")) 785 if (File.Exists(source + ".config"))
786 { 786 {
787 System.IO.File.Copy(source + ".config", Path.GetDirectoryName(dest), true); 787 System.IO.File.Copy(source + ".config", Path.GetDirectoryName(dest), true);
788 extraDistFiles.Add(refr.Name + ".dll.config"); 788 extraDistFiles.Add(refr.Name + ".dll.config");
789 } 789 }
790 790
791 try 791 try
792 { 792 {
793 System.IO.File.Copy(source, dest, true); 793 System.IO.File.Copy(source, dest, true);
794 } 794 }
795 catch (System.IO.IOException) 795 catch (System.IO.IOException)
796 { 796 {
797 if (solution.ProjectsTable.ContainsKey(refr.Name)){ 797 if (solution.ProjectsTable.ContainsKey(refr.Name)){
798 798
799 /* If an assembly is referenced, marked for 799 /* If an assembly is referenced, marked for
800 * local copy, in the list of projects for 800 * local copy, in the list of projects for
801 * this solution, but does not exist, put a 801 * this solution, but does not exist, put a
802 * target into the Makefile.am to build the 802 * target into the Makefile.am to build the
803 * assembly and copy it to this project's 803 * assembly and copy it to this project's
804 * directory 804 * directory
805 */ 805 */
806 806
807 ProjectNode sourcePrj = 807 ProjectNode sourcePrj =
808 ((solution.ProjectsTable[refr.Name])); 808 ((solution.ProjectsTable[refr.Name]));
809 809
810 string target = 810 string target =
811 String.Format("{0}:\n" + 811 String.Format("{0}:\n" +
812 "\t$(MAKE) -C ../{1}\n" + 812 "\t$(MAKE) -C ../{1}\n" +
813 "\tln ../{2}/$@ $@\n", 813 "\tln ../{2}/$@ $@\n",
814 filename, 814 filename,
815 sourcePrj.Name, 815 sourcePrj.Name,
816 sourcePrj.Name ); 816 sourcePrj.Name );
817 817
818 localCopyTargets.Add(target); 818 localCopyTargets.Add(target);
819 } 819 }
820 } 820 }
821 } 821 }
822 else if( !pkgLibs.Contains(refr.Name) ) 822 else if( !pkgLibs.Contains(refr.Name) )
823 { 823 {
824 // Else, let's assume it's in the GAC or the lib path 824 // Else, let's assume it's in the GAC or the lib path
825 string assemName = string.Empty; 825 string assemName = string.Empty;
826 int index = refr.Name.IndexOf(","); 826 int index = refr.Name.IndexOf(",");
827 827
828 if (index > 0) 828 if (index > 0)
829 assemName = refr.Name.Substring(0, index); 829 assemName = refr.Name.Substring(0, index);
830 else 830 else
831 assemName = refr.Name; 831 assemName = refr.Name;
832 832
833 m_Kernel.Log.Write(String.Format( 833 m_Kernel.Log.Write(String.Format(
834 "Warning: Couldn't find an appropriate assembly " + 834 "Warning: Couldn't find an appropriate assembly " +
835 "for reference:\n'{0}'", refr.Name 835 "for reference:\n'{0}'", refr.Name
836 )); 836 ));
837 systemLibs.Add(assemName); 837 systemLibs.Add(assemName);
838 } 838 }
839 } 839 }
840 840
841 const string lineSep = " \\\n\t"; 841 const string lineSep = " \\\n\t";
842 string compiledFilesString = string.Empty; 842 string compiledFilesString = string.Empty;
843 if (compiledFiles.Count > 0) 843 if (compiledFiles.Count > 0)
844 compiledFilesString = 844 compiledFilesString =
845 lineSep + string.Join(lineSep, compiledFiles.ToArray()); 845 lineSep + string.Join(lineSep, compiledFiles.ToArray());
846 846
847 string embeddedFilesString = ""; 847 string embeddedFilesString = "";
848 if (embeddedFiles.Count > 0) 848 if (embeddedFiles.Count > 0)
849 embeddedFilesString = 849 embeddedFilesString =
850 lineSep + string.Join(lineSep, embeddedFiles.ToArray()); 850 lineSep + string.Join(lineSep, embeddedFiles.ToArray());
851 851
852 string contentFilesString = ""; 852 string contentFilesString = "";
853 if (contentFiles.Count > 0) 853 if (contentFiles.Count > 0)
854 contentFilesString = 854 contentFilesString =
855 lineSep + string.Join(lineSep, contentFiles.ToArray()); 855 lineSep + string.Join(lineSep, contentFiles.ToArray());
856 856
857 string extraDistFilesString = ""; 857 string extraDistFilesString = "";
858 if (extraDistFiles.Count > 0) 858 if (extraDistFiles.Count > 0)
859 extraDistFilesString = 859 extraDistFilesString =
860 lineSep + string.Join(lineSep, extraDistFiles.ToArray()); 860 lineSep + string.Join(lineSep, extraDistFiles.ToArray());
861 861
862 string pkgLibsString = ""; 862 string pkgLibsString = "";
863 if (pkgLibs.Count > 0) 863 if (pkgLibs.Count > 0)
864 pkgLibsString = 864 pkgLibsString =
865 lineSep + string.Join(lineSep, pkgLibs.ToArray()); 865 lineSep + string.Join(lineSep, pkgLibs.ToArray());
866 866
867 string binaryLibsString = ""; 867 string binaryLibsString = "";
868 if (binaryLibs.Count > 0) 868 if (binaryLibs.Count > 0)
869 binaryLibsString = 869 binaryLibsString =
870 lineSep + string.Join(lineSep, binaryLibs.ToArray()); 870 lineSep + string.Join(lineSep, binaryLibs.ToArray());
871 871
872 string systemLibsString = ""; 872 string systemLibsString = "";
873 if (systemLibs.Count > 0) 873 if (systemLibs.Count > 0)
874 systemLibsString = 874 systemLibsString =
875 lineSep + string.Join(lineSep, systemLibs.ToArray()); 875 lineSep + string.Join(lineSep, systemLibs.ToArray());
876 876
877 string localCopyTargetsString = ""; 877 string localCopyTargetsString = "";
878 if (localCopyTargets.Count > 0) 878 if (localCopyTargets.Count > 0)
879 localCopyTargetsString = 879 localCopyTargetsString =
880 string.Join("\n", localCopyTargets.ToArray()); 880 string.Join("\n", localCopyTargets.ToArray());
881 881
882 string monoPath = ""; 882 string monoPath = "";
883 foreach (string runtimeLib in runtimeLibs) 883 foreach (string runtimeLib in runtimeLibs)
884 { 884 {
885 monoPath += ":`pkg-config --variable=libdir " + runtimeLib + "`"; 885 monoPath += ":`pkg-config --variable=libdir " + runtimeLib + "`";
886 } 886 }
887 887
888 // Add the project name to the list of transformation 888 // Add the project name to the list of transformation
889 // parameters 889 // parameters
890 XsltArgumentList argList = new XsltArgumentList(); 890 XsltArgumentList argList = new XsltArgumentList();
891 argList.AddParam("projectName", "", project.Name); 891 argList.AddParam("projectName", "", project.Name);
892 argList.AddParam("solutionName", "", solution.Name); 892 argList.AddParam("solutionName", "", solution.Name);
893 argList.AddParam("assemblyName", "", projectAssemblyName); 893 argList.AddParam("assemblyName", "", projectAssemblyName);
894 argList.AddParam("compiledFiles", "", compiledFilesString); 894 argList.AddParam("compiledFiles", "", compiledFilesString);
895 argList.AddParam("embeddedFiles", "", embeddedFilesString); 895 argList.AddParam("embeddedFiles", "", embeddedFilesString);
896 argList.AddParam("contentFiles", "", contentFilesString); 896 argList.AddParam("contentFiles", "", contentFilesString);
897 argList.AddParam("extraDistFiles", "", extraDistFilesString); 897 argList.AddParam("extraDistFiles", "", extraDistFilesString);
898 argList.AddParam("pkgLibs", "", pkgLibsString); 898 argList.AddParam("pkgLibs", "", pkgLibsString);
899 argList.AddParam("binaryLibs", "", binaryLibsString); 899 argList.AddParam("binaryLibs", "", binaryLibsString);
900 argList.AddParam("systemLibs", "", systemLibsString); 900 argList.AddParam("systemLibs", "", systemLibsString);
901 argList.AddParam("monoPath", "", monoPath); 901 argList.AddParam("monoPath", "", monoPath);
902 argList.AddParam("localCopyTargets", "", localCopyTargetsString); 902 argList.AddParam("localCopyTargets", "", localCopyTargetsString);
903 argList.AddParam("projectVersion", "", projectVersion); 903 argList.AddParam("projectVersion", "", projectVersion);
904 argList.AddParam("hasAssemblyConfig", "", hasAssemblyConfig ? "true" : ""); 904 argList.AddParam("hasAssemblyConfig", "", hasAssemblyConfig ? "true" : "");
905 905
906 // Transform the templates 906 // Transform the templates
907 transformToFile(Path.Combine(projectDir, "configure.ac"), argList, "/Autotools/ProjectConfigureAc"); 907 transformToFile(Path.Combine(projectDir, "configure.ac"), argList, "/Autotools/ProjectConfigureAc");
908 transformToFile(Path.Combine(projectDir, "Makefile.am"), argList, "/Autotools/ProjectMakefileAm"); 908 transformToFile(Path.Combine(projectDir, "Makefile.am"), argList, "/Autotools/ProjectMakefileAm");
909 transformToFile(Path.Combine(projectDir, "autogen.sh"), argList, "/Autotools/ProjectAutogenSh"); 909 transformToFile(Path.Combine(projectDir, "autogen.sh"), argList, "/Autotools/ProjectAutogenSh");
910 910
911 if (project.Type == Core.Nodes.ProjectType.Library) 911 if (project.Type == Core.Nodes.ProjectType.Library)
912 transformToFile(Path.Combine(projectDir, project.Name + ".pc.in"), argList, "/Autotools/ProjectPcIn"); 912 transformToFile(Path.Combine(projectDir, project.Name + ".pc.in"), argList, "/Autotools/ProjectPcIn");
913 if (project.Type == Core.Nodes.ProjectType.Exe || project.Type == Core.Nodes.ProjectType.WinExe) 913 if (project.Type == Core.Nodes.ProjectType.Exe || project.Type == Core.Nodes.ProjectType.WinExe)
914 transformToFile(Path.Combine(projectDir, project.Name.ToLower() + ".in"), argList, "/Autotools/ProjectWrapperScriptIn"); 914 transformToFile(Path.Combine(projectDir, project.Name.ToLower() + ".in"), argList, "/Autotools/ProjectWrapperScriptIn");
915 } 915 }
916 916
917 private void CleanProject(ProjectNode project) 917 private void CleanProject(ProjectNode project)
918 { 918 {
919 m_Kernel.Log.Write("...Cleaning project: {0}", project.Name); 919 m_Kernel.Log.Write("...Cleaning project: {0}", project.Name);
920 string projectFile = Helper.MakeFilePath(project.FullPath, "Include", "am"); 920 string projectFile = Helper.MakeFilePath(project.FullPath, "Include", "am");
921 Helper.DeleteIfExists(projectFile); 921 Helper.DeleteIfExists(projectFile);
922 } 922 }
923 923
924 private void CleanSolution(SolutionNode solution) 924 private void CleanSolution(SolutionNode solution)
925 { 925 {
926 m_Kernel.Log.Write("Cleaning Autotools make files for", solution.Name); 926 m_Kernel.Log.Write("Cleaning Autotools make files for", solution.Name);
927 927
928 string slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile", "am"); 928 string slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile", "am");
929 Helper.DeleteIfExists(slnFile); 929 Helper.DeleteIfExists(slnFile);
930 930
931 slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile", "in"); 931 slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile", "in");
932 Helper.DeleteIfExists(slnFile); 932 Helper.DeleteIfExists(slnFile);
933 933
934 slnFile = Helper.MakeFilePath(solution.FullPath, "configure", "ac"); 934 slnFile = Helper.MakeFilePath(solution.FullPath, "configure", "ac");
935 Helper.DeleteIfExists(slnFile); 935 Helper.DeleteIfExists(slnFile);
936 936
937 slnFile = Helper.MakeFilePath(solution.FullPath, "configure"); 937 slnFile = Helper.MakeFilePath(solution.FullPath, "configure");
938 Helper.DeleteIfExists(slnFile); 938 Helper.DeleteIfExists(slnFile);
939 939
940 slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile"); 940 slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile");
941 Helper.DeleteIfExists(slnFile); 941 Helper.DeleteIfExists(slnFile);
942 942
943 foreach (ProjectNode project in solution.Projects) 943 foreach (ProjectNode project in solution.Projects)
944 { 944 {
945 CleanProject(project); 945 CleanProject(project);
946 } 946 }
947 947
948 m_Kernel.Log.Write(""); 948 m_Kernel.Log.Write("");
949 } 949 }
950 950
951 #endregion 951 #endregion
952 952
953 #region ITarget Members 953 #region ITarget Members
954 954
955 /// <summary> 955 /// <summary>
956 /// Writes the specified kern. 956 /// Writes the specified kern.
957 /// </summary> 957 /// </summary>
958 /// <param name="kern">The kern.</param> 958 /// <param name="kern">The kern.</param>
959 public void Write(Kernel kern) 959 public void Write(Kernel kern)
960 { 960 {
961 if (kern == null) 961 if (kern == null)
962 { 962 {
963 throw new ArgumentNullException("kern"); 963 throw new ArgumentNullException("kern");
964 } 964 }
965 m_Kernel = kern; 965 m_Kernel = kern;
966 m_Kernel.Log.Write("Parsing system pkg-config files"); 966 m_Kernel.Log.Write("Parsing system pkg-config files");
967 RunInitialization(); 967 RunInitialization();
968 968
969 const string streamName = "autotools.xml"; 969 const string streamName = "autotools.xml";
970 string fqStreamName = String.Format("Prebuild.data.{0}", 970 string fqStreamName = String.Format("Prebuild.data.{0}",
971 streamName 971 streamName
972 ); 972 );
973 973
974 // Retrieve stream for the autotools template XML 974 // Retrieve stream for the autotools template XML
975 Stream autotoolsStream = Assembly.GetExecutingAssembly() 975 Stream autotoolsStream = Assembly.GetExecutingAssembly()
976 .GetManifestResourceStream(fqStreamName); 976 .GetManifestResourceStream(fqStreamName);
977 977
978 if(autotoolsStream == null) { 978 if(autotoolsStream == null) {
979 979
980 /* 980 /*
981 * try without the default namespace prepended, in 981 * try without the default namespace prepended, in
982 * case prebuild.exe assembly was compiled with 982 * case prebuild.exe assembly was compiled with
983 * something other than Visual Studio .NET 983 * something other than Visual Studio .NET
984 */ 984 */
985 985
986 autotoolsStream = Assembly.GetExecutingAssembly() 986 autotoolsStream = Assembly.GetExecutingAssembly()
987 .GetManifestResourceStream(streamName); 987 .GetManifestResourceStream(streamName);
988 if(autotoolsStream == null){ 988 if(autotoolsStream == null){
989 string errStr = 989 string errStr =
990 String.Format("Could not find embedded resource file:\n" + 990 String.Format("Could not find embedded resource file:\n" +
991 "'{0}' or '{1}'", 991 "'{0}' or '{1}'",
992 streamName, fqStreamName 992 streamName, fqStreamName
993 ); 993 );
994 994
995 m_Kernel.Log.Write(errStr); 995 m_Kernel.Log.Write(errStr);
996 996
997 throw new System.Reflection.TargetException(errStr); 997 throw new System.Reflection.TargetException(errStr);
998 } 998 }
999 } 999 }
1000 1000
1001 // Create an XML URL Resolver with default credentials 1001 // Create an XML URL Resolver with default credentials
1002 xr = new System.Xml.XmlUrlResolver(); 1002 xr = new System.Xml.XmlUrlResolver();
1003 xr.Credentials = CredentialCache.DefaultCredentials; 1003 xr.Credentials = CredentialCache.DefaultCredentials;
1004 1004
1005 // Create a default evidence - no need to limit access 1005 // Create a default evidence - no need to limit access
1006 e = new System.Security.Policy.Evidence(); 1006 e = new System.Security.Policy.Evidence();
1007 1007
1008 // Load the autotools XML 1008 // Load the autotools XML
1009 autotoolsDoc = new XmlDocument(); 1009 autotoolsDoc = new XmlDocument();
1010 autotoolsDoc.Load(autotoolsStream); 1010 autotoolsDoc.Load(autotoolsStream);
1011 1011
1012 /* rootDir is the filesystem location where the Autotools 1012 /* rootDir is the filesystem location where the Autotools
1013 * build tree will be created - for now we'll make it 1013 * build tree will be created - for now we'll make it
1014 * $PWD/autotools 1014 * $PWD/autotools
1015 */ 1015 */
1016 1016
1017 string pwd = Directory.GetCurrentDirectory(); 1017 string pwd = Directory.GetCurrentDirectory();
1018 //string pwd = System.Environment.GetEnvironmentVariable("PWD"); 1018 //string pwd = System.Environment.GetEnvironmentVariable("PWD");
1019 //if (pwd.Length != 0) 1019 //if (pwd.Length != 0)
1020 //{ 1020 //{
1021 string rootDir = Path.Combine(pwd, "autotools"); 1021 string rootDir = Path.Combine(pwd, "autotools");
1022 //} 1022 //}
1023 //else 1023 //else
1024 //{ 1024 //{
1025 // pwd = Assembly.GetExecutingAssembly() 1025 // pwd = Assembly.GetExecutingAssembly()
1026 //} 1026 //}
1027 chkMkDir(rootDir); 1027 chkMkDir(rootDir);
1028 1028
1029 foreach (SolutionNode solution in kern.Solutions) 1029 foreach (SolutionNode solution in kern.Solutions)
1030 { 1030 {
1031 m_Kernel.Log.Write(String.Format("Writing solution: {0}", 1031 m_Kernel.Log.Write(String.Format("Writing solution: {0}",
1032 solution.Name)); 1032 solution.Name));
1033 WriteCombine(solution); 1033 WriteCombine(solution);
1034 } 1034 }
1035 m_Kernel = null; 1035 m_Kernel = null;
1036 } 1036 }
1037 1037
1038 /// <summary> 1038 /// <summary>
1039 /// Cleans the specified kern. 1039 /// Cleans the specified kern.
1040 /// </summary> 1040 /// </summary>
1041 /// <param name="kern">The kern.</param> 1041 /// <param name="kern">The kern.</param>
1042 public virtual void Clean(Kernel kern) 1042 public virtual void Clean(Kernel kern)
1043 { 1043 {
1044 if (kern == null) 1044 if (kern == null)
1045 { 1045 {
1046 throw new ArgumentNullException("kern"); 1046 throw new ArgumentNullException("kern");
1047 } 1047 }
1048 m_Kernel = kern; 1048 m_Kernel = kern;
1049 foreach (SolutionNode sol in kern.Solutions) 1049 foreach (SolutionNode sol in kern.Solutions)
1050 { 1050 {
1051 CleanSolution(sol); 1051 CleanSolution(sol);
1052 } 1052 }
1053 m_Kernel = null; 1053 m_Kernel = null;
1054 } 1054 }
1055 1055
1056 /// <summary> 1056 /// <summary>
1057 /// Gets the name. 1057 /// Gets the name.
1058 /// </summary> 1058 /// </summary>
1059 /// <value>The name.</value> 1059 /// <value>The name.</value>
1060 public string Name 1060 public string Name
1061 { 1061 {
1062 get 1062 get
1063 { 1063 {
1064 return "autotools"; 1064 return "autotools";
1065 } 1065 }
1066 } 1066 }
1067 1067
1068 #endregion 1068 #endregion
1069 } 1069 }
1070} 1070}
diff --git a/Prebuild/src/Core/Targets/.svn/text-base/VS2010Target.cs.svn-base b/Prebuild/src/Core/Targets/.svn/text-base/VS2010Target.cs.svn-base
index ea9f736..b16120c 100644
--- a/Prebuild/src/Core/Targets/.svn/text-base/VS2010Target.cs.svn-base
+++ b/Prebuild/src/Core/Targets/.svn/text-base/VS2010Target.cs.svn-base
@@ -1,138 +1,138 @@
1using System; 1using System;
2using System.IO; 2using System.IO;
3using System.Text; 3using System.Text;
4 4
5using Prebuild.Core.Attributes; 5using Prebuild.Core.Attributes;
6using Prebuild.Core.Interfaces; 6using Prebuild.Core.Interfaces;
7using Prebuild.Core.Nodes; 7using Prebuild.Core.Nodes;
8using Prebuild.Core.Utilities; 8using Prebuild.Core.Utilities;
9using System.CodeDom.Compiler; 9using System.CodeDom.Compiler;
10 10
11namespace Prebuild.Core.Targets 11namespace Prebuild.Core.Targets
12{ 12{
13 13
14 /// <summary> 14 /// <summary>
15 /// 15 ///
16 /// </summary> 16 /// </summary>
17 [Target("vs2010")] 17 [Target("vs2010")]
18 public class VS2010Target : VSGenericTarget 18 public class VS2010Target : VSGenericTarget
19 { 19 {
20 #region Fields 20 #region Fields
21 21
22 string solutionVersion = "11.00"; 22 string solutionVersion = "11.00";
23 string productVersion = "9.0.30729"; 23 string productVersion = "9.0.30729";
24 string schemaVersion = "2.0"; 24 string schemaVersion = "2.0";
25 string versionName = "Visual Studio 2010"; 25 string versionName = "Visual Studio 2010";
26 string name = "vs2010"; 26 string name = "vs2010";
27 VSVersion version = VSVersion.VS10; 27 VSVersion version = VSVersion.VS10;
28 28
29 #endregion 29 #endregion
30 30
31 #region Properties 31 #region Properties
32 32
33 /// <summary> 33 /// <summary>
34 /// Gets or sets the solution version. 34 /// Gets or sets the solution version.
35 /// </summary> 35 /// </summary>
36 /// <value>The solution version.</value> 36 /// <value>The solution version.</value>
37 public override string SolutionVersion 37 public override string SolutionVersion
38 { 38 {
39 get 39 get
40 { 40 {
41 return solutionVersion; 41 return solutionVersion;
42 } 42 }
43 } 43 }
44 44
45 /// <summary> 45 /// <summary>
46 /// Gets or sets the product version. 46 /// Gets or sets the product version.
47 /// </summary> 47 /// </summary>
48 /// <value>The product version.</value> 48 /// <value>The product version.</value>
49 public override string ProductVersion 49 public override string ProductVersion
50 { 50 {
51 get 51 get
52 { 52 {
53 return productVersion; 53 return productVersion;
54 } 54 }
55 } 55 }
56 56
57 /// <summary> 57 /// <summary>
58 /// Gets or sets the schema version. 58 /// Gets or sets the schema version.
59 /// </summary> 59 /// </summary>
60 /// <value>The schema version.</value> 60 /// <value>The schema version.</value>
61 public override string SchemaVersion 61 public override string SchemaVersion
62 { 62 {
63 get 63 get
64 { 64 {
65 return schemaVersion; 65 return schemaVersion;
66 } 66 }
67 } 67 }
68 68
69 /// <summary> 69 /// <summary>
70 /// Gets or sets the name of the version. 70 /// Gets or sets the name of the version.
71 /// </summary> 71 /// </summary>
72 /// <value>The name of the version.</value> 72 /// <value>The name of the version.</value>
73 public override string VersionName 73 public override string VersionName
74 { 74 {
75 get 75 get
76 { 76 {
77 return versionName; 77 return versionName;
78 } 78 }
79 } 79 }
80 80
81 /// <summary> 81 /// <summary>
82 /// Gets or sets the version. 82 /// Gets or sets the version.
83 /// </summary> 83 /// </summary>
84 /// <value>The version.</value> 84 /// <value>The version.</value>
85 public override VSVersion Version 85 public override VSVersion Version
86 { 86 {
87 get 87 get
88 { 88 {
89 return version; 89 return version;
90 } 90 }
91 } 91 }
92 92
93 /// <summary> 93 /// <summary>
94 /// Gets the name. 94 /// Gets the name.
95 /// </summary> 95 /// </summary>
96 /// <value>The name.</value> 96 /// <value>The name.</value>
97 public override string Name 97 public override string Name
98 { 98 {
99 get 99 get
100 { 100 {
101 return name; 101 return name;
102 } 102 }
103 } 103 }
104 104
105 protected override string GetToolsVersionXml(FrameworkVersion frameworkVersion) 105 protected override string GetToolsVersionXml(FrameworkVersion frameworkVersion)
106 { 106 {
107 switch (frameworkVersion) 107 switch (frameworkVersion)
108 { 108 {
109 case FrameworkVersion.v4_0: 109 case FrameworkVersion.v4_0:
110 case FrameworkVersion.v3_5: 110 case FrameworkVersion.v3_5:
111 return "ToolsVersion=\"4.0\""; 111 return "ToolsVersion=\"4.0\"";
112 case FrameworkVersion.v3_0: 112 case FrameworkVersion.v3_0:
113 return "ToolsVersion=\"3.0\""; 113 return "ToolsVersion=\"3.0\"";
114 default: 114 default:
115 return "ToolsVersion=\"2.0\""; 115 return "ToolsVersion=\"2.0\"";
116 } 116 }
117 } 117 }
118 118
119 public override string SolutionTag 119 public override string SolutionTag
120 { 120 {
121 get { return "# Visual Studio 2010"; } 121 get { return "# Visual Studio 2010"; }
122 } 122 }
123 123
124 #endregion 124 #endregion
125 125
126 #region Constructors 126 #region Constructors
127 127
128 /// <summary> 128 /// <summary>
129 /// Initializes a new instance of the <see cref="VS2005Target"/> class. 129 /// Initializes a new instance of the <see cref="VS2005Target"/> class.
130 /// </summary> 130 /// </summary>
131 public VS2010Target() 131 public VS2010Target()
132 : base() 132 : base()
133 { 133 {
134 } 134 }
135 135
136 #endregion 136 #endregion
137 } 137 }
138} 138}
diff --git a/Prebuild/src/Core/Targets/.svn/text-base/VSGenericTarget.cs.svn-base b/Prebuild/src/Core/Targets/.svn/text-base/VSGenericTarget.cs.svn-base
index 6969dd7..cd3f5bb 100644
--- a/Prebuild/src/Core/Targets/.svn/text-base/VSGenericTarget.cs.svn-base
+++ b/Prebuild/src/Core/Targets/.svn/text-base/VSGenericTarget.cs.svn-base
@@ -1,922 +1,922 @@
1#region BSD License 1#region BSD License
2/* 2/*
3Copyright (c) 2008 Matthew Holmes (matthew@wildfiregames.com), John Anderson (sontek@gmail.com) 3Copyright (c) 2008 Matthew Holmes (matthew@wildfiregames.com), John Anderson (sontek@gmail.com)
4 4
5Redistribution and use in source and binary forms, with or without modification, are permitted 5Redistribution and use in source and binary forms, with or without modification, are permitted
6provided that the following conditions are met: 6provided that the following conditions are met:
7 7
8 * Redistributions of source code must retain the above copyright notice, this list of conditions 8 * Redistributions of source code must retain the above copyright notice, this list of conditions
9 and the following disclaimer. 9 and the following disclaimer.
10 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions 10 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions
11 and the following disclaimer in the documentation and/or other materials provided with the 11 and the following disclaimer in the documentation and/or other materials provided with the
12 distribution. 12 distribution.
13 * The name of the author may not be used to endorse or promote products derived from this software 13 * The name of the author may not be used to endorse or promote products derived from this software
14 without specific prior written permission. 14 without specific prior written permission.
15 15
16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
17BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 21OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
22IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */ 23 */
24#endregion 24#endregion
25 25
26using System; 26using System;
27using System.Collections.Generic; 27using System.Collections.Generic;
28using System.IO; 28using System.IO;
29using Prebuild.Core.Interfaces; 29using Prebuild.Core.Interfaces;
30using Prebuild.Core.Nodes; 30using Prebuild.Core.Nodes;
31using Prebuild.Core.Utilities; 31using Prebuild.Core.Utilities;
32using System.CodeDom.Compiler; 32using System.CodeDom.Compiler;
33 33
34namespace Prebuild.Core.Targets 34namespace Prebuild.Core.Targets
35{ 35{
36 36
37 /// <summary> 37 /// <summary>
38 /// 38 ///
39 /// </summary> 39 /// </summary>
40 public abstract class VSGenericTarget : ITarget 40 public abstract class VSGenericTarget : ITarget
41 { 41 {
42 #region Fields 42 #region Fields
43 43
44 readonly Dictionary<string, ToolInfo> tools = new Dictionary<string, ToolInfo>(); 44 readonly Dictionary<string, ToolInfo> tools = new Dictionary<string, ToolInfo>();
45 Kernel kernel; 45 Kernel kernel;
46 #endregion 46 #endregion
47 47
48 #region Properties 48 #region Properties
49 /// <summary> 49 /// <summary>
50 /// Gets or sets the solution version. 50 /// Gets or sets the solution version.
51 /// </summary> 51 /// </summary>
52 /// <value>The solution version.</value> 52 /// <value>The solution version.</value>
53 public abstract string SolutionVersion { get; } 53 public abstract string SolutionVersion { get; }
54 /// <summary> 54 /// <summary>
55 /// Gets or sets the product version. 55 /// Gets or sets the product version.
56 /// </summary> 56 /// </summary>
57 /// <value>The product version.</value> 57 /// <value>The product version.</value>
58 public abstract string ProductVersion { get; } 58 public abstract string ProductVersion { get; }
59 /// <summary> 59 /// <summary>
60 /// Gets or sets the schema version. 60 /// Gets or sets the schema version.
61 /// </summary> 61 /// </summary>
62 /// <value>The schema version.</value> 62 /// <value>The schema version.</value>
63 public abstract string SchemaVersion { get; } 63 public abstract string SchemaVersion { get; }
64 /// <summary> 64 /// <summary>
65 /// Gets or sets the name of the version. 65 /// Gets or sets the name of the version.
66 /// </summary> 66 /// </summary>
67 /// <value>The name of the version.</value> 67 /// <value>The name of the version.</value>
68 public abstract string VersionName { get; } 68 public abstract string VersionName { get; }
69 /// <summary> 69 /// <summary>
70 /// Gets or sets the version. 70 /// Gets or sets the version.
71 /// </summary> 71 /// </summary>
72 /// <value>The version.</value> 72 /// <value>The version.</value>
73 public abstract VSVersion Version { get; } 73 public abstract VSVersion Version { get; }
74 /// <summary> 74 /// <summary>
75 /// Gets the name. 75 /// Gets the name.
76 /// </summary> 76 /// </summary>
77 /// <value>The name.</value> 77 /// <value>The name.</value>
78 public abstract string Name { get; } 78 public abstract string Name { get; }
79 79
80 protected abstract string GetToolsVersionXml(FrameworkVersion version); 80 protected abstract string GetToolsVersionXml(FrameworkVersion version);
81 public abstract string SolutionTag { get; } 81 public abstract string SolutionTag { get; }
82 82
83 #endregion 83 #endregion
84 84
85 #region Constructors 85 #region Constructors
86 86
87 /// <summary> 87 /// <summary>
88 /// Initializes a new instance of the <see cref="VSGenericTarget"/> class. 88 /// Initializes a new instance of the <see cref="VSGenericTarget"/> class.
89 /// </summary> 89 /// </summary>
90 protected VSGenericTarget() 90 protected VSGenericTarget()
91 { 91 {
92 tools["C#"] = new ToolInfo("C#", "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}", "csproj", "CSHARP", "$(MSBuildBinPath)\\Microsoft.CSHARP.Targets"); 92 tools["C#"] = new ToolInfo("C#", "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}", "csproj", "CSHARP", "$(MSBuildBinPath)\\Microsoft.CSHARP.Targets");
93 tools["Database"] = new ToolInfo("Database", "{4F174C21-8C12-11D0-8340-0000F80270F8}", "dbp", "UNKNOWN"); 93 tools["Database"] = new ToolInfo("Database", "{4F174C21-8C12-11D0-8340-0000F80270F8}", "dbp", "UNKNOWN");
94 tools["Boo"] = new ToolInfo("Boo", "{45CEA7DC-C2ED-48A6-ACE0-E16144C02365}", "booproj", "Boo", "$(BooBinPath)\\Boo.Microsoft.Build.targets"); 94 tools["Boo"] = new ToolInfo("Boo", "{45CEA7DC-C2ED-48A6-ACE0-E16144C02365}", "booproj", "Boo", "$(BooBinPath)\\Boo.Microsoft.Build.targets");
95 tools["VisualBasic"] = new ToolInfo("VisualBasic", "{F184B08F-C81C-45F6-A57F-5ABD9991F28F}", "vbproj", "VisualBasic", "$(MSBuildBinPath)\\Microsoft.VisualBasic.Targets"); 95 tools["VisualBasic"] = new ToolInfo("VisualBasic", "{F184B08F-C81C-45F6-A57F-5ABD9991F28F}", "vbproj", "VisualBasic", "$(MSBuildBinPath)\\Microsoft.VisualBasic.Targets");
96 tools["Folder"] = new ToolInfo("Folder", "{2150E333-8FDC-42A3-9474-1A3956D46DE8}", null, null); 96 tools["Folder"] = new ToolInfo("Folder", "{2150E333-8FDC-42A3-9474-1A3956D46DE8}", null, null);
97 } 97 }
98 98
99 #endregion 99 #endregion
100 100
101 #region Private Methods 101 #region Private Methods
102 102
103 private string MakeRefPath(ProjectNode project) 103 private string MakeRefPath(ProjectNode project)
104 { 104 {
105 string ret = ""; 105 string ret = "";
106 foreach (ReferencePathNode node in project.ReferencePaths) 106 foreach (ReferencePathNode node in project.ReferencePaths)
107 { 107 {
108 try 108 try
109 { 109 {
110 string fullPath = Helper.ResolvePath(node.Path); 110 string fullPath = Helper.ResolvePath(node.Path);
111 if (ret.Length < 1) 111 if (ret.Length < 1)
112 { 112 {
113 ret = fullPath; 113 ret = fullPath;
114 } 114 }
115 else 115 else
116 { 116 {
117 ret += ";" + fullPath; 117 ret += ";" + fullPath;
118 } 118 }
119 } 119 }
120 catch (ArgumentException) 120 catch (ArgumentException)
121 { 121 {
122 kernel.Log.Write(LogType.Warning, "Could not resolve reference path: {0}", node.Path); 122 kernel.Log.Write(LogType.Warning, "Could not resolve reference path: {0}", node.Path);
123 } 123 }
124 } 124 }
125 125
126 return ret; 126 return ret;
127 } 127 }
128 128
129 private static ProjectNode FindProjectInSolution(string name, SolutionNode solution) 129 private static ProjectNode FindProjectInSolution(string name, SolutionNode solution)
130 { 130 {
131 SolutionNode node = solution; 131 SolutionNode node = solution;
132 132
133 while (node.Parent is SolutionNode) 133 while (node.Parent is SolutionNode)
134 node = node.Parent as SolutionNode; 134 node = node.Parent as SolutionNode;
135 135
136 return FindProjectInSolutionRecursively(name, node); 136 return FindProjectInSolutionRecursively(name, node);
137 } 137 }
138 138
139 private static ProjectNode FindProjectInSolutionRecursively(string name, SolutionNode solution) 139 private static ProjectNode FindProjectInSolutionRecursively(string name, SolutionNode solution)
140 { 140 {
141 if (solution.ProjectsTable.ContainsKey(name)) 141 if (solution.ProjectsTable.ContainsKey(name))
142 return solution.ProjectsTable[name]; 142 return solution.ProjectsTable[name];
143 143
144 foreach (SolutionNode child in solution.Solutions) 144 foreach (SolutionNode child in solution.Solutions)
145 { 145 {
146 ProjectNode node = FindProjectInSolutionRecursively(name, child); 146 ProjectNode node = FindProjectInSolutionRecursively(name, child);
147 if (node != null) 147 if (node != null)
148 return node; 148 return node;
149 } 149 }
150 150
151 return null; 151 return null;
152 } 152 }
153 153
154 private void WriteProject(SolutionNode solution, ProjectNode project) 154 private void WriteProject(SolutionNode solution, ProjectNode project)
155 { 155 {
156 if (!tools.ContainsKey(project.Language)) 156 if (!tools.ContainsKey(project.Language))
157 { 157 {
158 throw new UnknownLanguageException("Unknown .NET language: " + project.Language); 158 throw new UnknownLanguageException("Unknown .NET language: " + project.Language);
159 } 159 }
160 160
161 ToolInfo toolInfo = tools[project.Language]; 161 ToolInfo toolInfo = tools[project.Language];
162 string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); 162 string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension);
163 StreamWriter ps = new StreamWriter(projectFile); 163 StreamWriter ps = new StreamWriter(projectFile);
164 164
165 kernel.CurrentWorkingDirectory.Push(); 165 kernel.CurrentWorkingDirectory.Push();
166 Helper.SetCurrentDir(Path.GetDirectoryName(projectFile)); 166 Helper.SetCurrentDir(Path.GetDirectoryName(projectFile));
167 167
168 #region Project File 168 #region Project File
169 using (ps) 169 using (ps)
170 { 170 {
171 ps.WriteLine("<Project DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\" {0}>", GetToolsVersionXml(project.FrameworkVersion)); 171 ps.WriteLine("<Project DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\" {0}>", GetToolsVersionXml(project.FrameworkVersion));
172 ps.WriteLine(" <PropertyGroup>"); 172 ps.WriteLine(" <PropertyGroup>");
173 ps.WriteLine(" <ProjectType>Local</ProjectType>"); 173 ps.WriteLine(" <ProjectType>Local</ProjectType>");
174 ps.WriteLine(" <ProductVersion>{0}</ProductVersion>", ProductVersion); 174 ps.WriteLine(" <ProductVersion>{0}</ProductVersion>", ProductVersion);
175 ps.WriteLine(" <SchemaVersion>{0}</SchemaVersion>", SchemaVersion); 175 ps.WriteLine(" <SchemaVersion>{0}</SchemaVersion>", SchemaVersion);
176 ps.WriteLine(" <ProjectGuid>{{{0}}}</ProjectGuid>", project.Guid.ToString().ToUpper()); 176 ps.WriteLine(" <ProjectGuid>{{{0}}}</ProjectGuid>", project.Guid.ToString().ToUpper());
177 177
178 // Visual Studio has a hard coded guid for the project type 178 // Visual Studio has a hard coded guid for the project type
179 if (project.Type == ProjectType.Web) 179 if (project.Type == ProjectType.Web)
180 ps.WriteLine(" <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>"); 180 ps.WriteLine(" <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>");
181 ps.WriteLine(" <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>"); 181 ps.WriteLine(" <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>");
182 ps.WriteLine(" <ApplicationIcon>{0}</ApplicationIcon>", project.AppIcon); 182 ps.WriteLine(" <ApplicationIcon>{0}</ApplicationIcon>", project.AppIcon);
183 ps.WriteLine(" <AssemblyKeyContainerName>"); 183 ps.WriteLine(" <AssemblyKeyContainerName>");
184 ps.WriteLine(" </AssemblyKeyContainerName>"); 184 ps.WriteLine(" </AssemblyKeyContainerName>");
185 ps.WriteLine(" <AssemblyName>{0}</AssemblyName>", project.AssemblyName); 185 ps.WriteLine(" <AssemblyName>{0}</AssemblyName>", project.AssemblyName);
186 foreach (ConfigurationNode conf in project.Configurations) 186 foreach (ConfigurationNode conf in project.Configurations)
187 { 187 {
188 if (conf.Options.KeyFile != "") 188 if (conf.Options.KeyFile != "")
189 { 189 {
190 ps.WriteLine(" <AssemblyOriginatorKeyFile>{0}</AssemblyOriginatorKeyFile>", conf.Options.KeyFile); 190 ps.WriteLine(" <AssemblyOriginatorKeyFile>{0}</AssemblyOriginatorKeyFile>", conf.Options.KeyFile);
191 ps.WriteLine(" <SignAssembly>true</SignAssembly>"); 191 ps.WriteLine(" <SignAssembly>true</SignAssembly>");
192 break; 192 break;
193 } 193 }
194 } 194 }
195 ps.WriteLine(" <DefaultClientScript>JScript</DefaultClientScript>"); 195 ps.WriteLine(" <DefaultClientScript>JScript</DefaultClientScript>");
196 ps.WriteLine(" <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>"); 196 ps.WriteLine(" <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>");
197 ps.WriteLine(" <DefaultTargetSchema>IE50</DefaultTargetSchema>"); 197 ps.WriteLine(" <DefaultTargetSchema>IE50</DefaultTargetSchema>");
198 ps.WriteLine(" <DelaySign>false</DelaySign>"); 198 ps.WriteLine(" <DelaySign>false</DelaySign>");
199 ps.WriteLine(" <TargetFrameworkVersion>{0}</TargetFrameworkVersion>", project.FrameworkVersion.ToString().Replace("_", ".")); 199 ps.WriteLine(" <TargetFrameworkVersion>{0}</TargetFrameworkVersion>", project.FrameworkVersion.ToString().Replace("_", "."));
200 200
201 ps.WriteLine(" <OutputType>{0}</OutputType>", project.Type == ProjectType.Web ? ProjectType.Library.ToString() : project.Type.ToString()); 201 ps.WriteLine(" <OutputType>{0}</OutputType>", project.Type == ProjectType.Web ? ProjectType.Library.ToString() : project.Type.ToString());
202 ps.WriteLine(" <AppDesignerFolder>{0}</AppDesignerFolder>", project.DesignerFolder); 202 ps.WriteLine(" <AppDesignerFolder>{0}</AppDesignerFolder>", project.DesignerFolder);
203 ps.WriteLine(" <RootNamespace>{0}</RootNamespace>", project.RootNamespace); 203 ps.WriteLine(" <RootNamespace>{0}</RootNamespace>", project.RootNamespace);
204 ps.WriteLine(" <StartupObject>{0}</StartupObject>", project.StartupObject); 204 ps.WriteLine(" <StartupObject>{0}</StartupObject>", project.StartupObject);
205 if (string.IsNullOrEmpty(project.DebugStartParameters)) 205 if (string.IsNullOrEmpty(project.DebugStartParameters))
206 { 206 {
207 ps.WriteLine(" <StartArguments>{0}</StartArguments>", project.DebugStartParameters); 207 ps.WriteLine(" <StartArguments>{0}</StartArguments>", project.DebugStartParameters);
208 } 208 }
209 ps.WriteLine(" <FileUpgradeFlags>"); 209 ps.WriteLine(" <FileUpgradeFlags>");
210 ps.WriteLine(" </FileUpgradeFlags>"); 210 ps.WriteLine(" </FileUpgradeFlags>");
211 211
212 ps.WriteLine(" </PropertyGroup>"); 212 ps.WriteLine(" </PropertyGroup>");
213 213
214 foreach (ConfigurationNode conf in project.Configurations) 214 foreach (ConfigurationNode conf in project.Configurations)
215 { 215 {
216 ps.Write(" <PropertyGroup "); 216 ps.Write(" <PropertyGroup ");
217 ps.WriteLine("Condition=\" '$(Configuration)|$(Platform)' == '{0}|{1}' \">", conf.Name, conf.Platform); 217 ps.WriteLine("Condition=\" '$(Configuration)|$(Platform)' == '{0}|{1}' \">", conf.Name, conf.Platform);
218 ps.WriteLine(" <AllowUnsafeBlocks>{0}</AllowUnsafeBlocks>", conf.Options["AllowUnsafe"]); 218 ps.WriteLine(" <AllowUnsafeBlocks>{0}</AllowUnsafeBlocks>", conf.Options["AllowUnsafe"]);
219 ps.WriteLine(" <BaseAddress>{0}</BaseAddress>", conf.Options["BaseAddress"]); 219 ps.WriteLine(" <BaseAddress>{0}</BaseAddress>", conf.Options["BaseAddress"]);
220 ps.WriteLine(" <CheckForOverflowUnderflow>{0}</CheckForOverflowUnderflow>", conf.Options["CheckUnderflowOverflow"]); 220 ps.WriteLine(" <CheckForOverflowUnderflow>{0}</CheckForOverflowUnderflow>", conf.Options["CheckUnderflowOverflow"]);
221 ps.WriteLine(" <ConfigurationOverrideFile>"); 221 ps.WriteLine(" <ConfigurationOverrideFile>");
222 ps.WriteLine(" </ConfigurationOverrideFile>"); 222 ps.WriteLine(" </ConfigurationOverrideFile>");
223 ps.WriteLine(" <DefineConstants>{0}</DefineConstants>", conf.Options["CompilerDefines"]); 223 ps.WriteLine(" <DefineConstants>{0}</DefineConstants>", conf.Options["CompilerDefines"]);
224 ps.WriteLine(" <DocumentationFile>{0}</DocumentationFile>", Helper.NormalizePath(conf.Options["XmlDocFile"].ToString())); 224 ps.WriteLine(" <DocumentationFile>{0}</DocumentationFile>", Helper.NormalizePath(conf.Options["XmlDocFile"].ToString()));
225 ps.WriteLine(" <DebugSymbols>{0}</DebugSymbols>", conf.Options["DebugInformation"]); 225 ps.WriteLine(" <DebugSymbols>{0}</DebugSymbols>", conf.Options["DebugInformation"]);
226 ps.WriteLine(" <FileAlignment>{0}</FileAlignment>", conf.Options["FileAlignment"]); 226 ps.WriteLine(" <FileAlignment>{0}</FileAlignment>", conf.Options["FileAlignment"]);
227 ps.WriteLine(" <Optimize>{0}</Optimize>", conf.Options["OptimizeCode"]); 227 ps.WriteLine(" <Optimize>{0}</Optimize>", conf.Options["OptimizeCode"]);
228 if (project.Type != ProjectType.Web) 228 if (project.Type != ProjectType.Web)
229 ps.WriteLine(" <OutputPath>{0}</OutputPath>", 229 ps.WriteLine(" <OutputPath>{0}</OutputPath>",
230 Helper.EndPath(Helper.NormalizePath(conf.Options["OutputPath"].ToString()))); 230 Helper.EndPath(Helper.NormalizePath(conf.Options["OutputPath"].ToString())));
231 else 231 else
232 ps.WriteLine(" <OutputPath>{0}</OutputPath>", 232 ps.WriteLine(" <OutputPath>{0}</OutputPath>",
233 Helper.EndPath(Helper.NormalizePath("bin\\"))); 233 Helper.EndPath(Helper.NormalizePath("bin\\")));
234 234
235 ps.WriteLine(" <RegisterForComInterop>{0}</RegisterForComInterop>", conf.Options["RegisterComInterop"]); 235 ps.WriteLine(" <RegisterForComInterop>{0}</RegisterForComInterop>", conf.Options["RegisterComInterop"]);
236 ps.WriteLine(" <RemoveIntegerChecks>{0}</RemoveIntegerChecks>", conf.Options["RemoveIntegerChecks"]); 236 ps.WriteLine(" <RemoveIntegerChecks>{0}</RemoveIntegerChecks>", conf.Options["RemoveIntegerChecks"]);
237 ps.WriteLine(" <TreatWarningsAsErrors>{0}</TreatWarningsAsErrors>", conf.Options["WarningsAsErrors"]); 237 ps.WriteLine(" <TreatWarningsAsErrors>{0}</TreatWarningsAsErrors>", conf.Options["WarningsAsErrors"]);
238 ps.WriteLine(" <WarningLevel>{0}</WarningLevel>", conf.Options["WarningLevel"]); 238 ps.WriteLine(" <WarningLevel>{0}</WarningLevel>", conf.Options["WarningLevel"]);
239 ps.WriteLine(" <NoStdLib>{0}</NoStdLib>", conf.Options["NoStdLib"]); 239 ps.WriteLine(" <NoStdLib>{0}</NoStdLib>", conf.Options["NoStdLib"]);
240 ps.WriteLine(" <NoWarn>{0}</NoWarn>", conf.Options["SuppressWarnings"]); 240 ps.WriteLine(" <NoWarn>{0}</NoWarn>", conf.Options["SuppressWarnings"]);
241 ps.WriteLine(" <PlatformTarget>{0}</PlatformTarget>", conf.Platform); 241 ps.WriteLine(" <PlatformTarget>{0}</PlatformTarget>", conf.Platform);
242 ps.WriteLine(" </PropertyGroup>"); 242 ps.WriteLine(" </PropertyGroup>");
243 } 243 }
244 244
245 //ps.WriteLine(" </Settings>"); 245 //ps.WriteLine(" </Settings>");
246 246
247 Dictionary<ReferenceNode, ProjectNode> projectReferences = new Dictionary<ReferenceNode, ProjectNode>(); 247 Dictionary<ReferenceNode, ProjectNode> projectReferences = new Dictionary<ReferenceNode, ProjectNode>();
248 List<ReferenceNode> otherReferences = new List<ReferenceNode>(); 248 List<ReferenceNode> otherReferences = new List<ReferenceNode>();
249 249
250 foreach (ReferenceNode refr in project.References) 250 foreach (ReferenceNode refr in project.References)
251 { 251 {
252 ProjectNode projectNode = FindProjectInSolution(refr.Name, solution); 252 ProjectNode projectNode = FindProjectInSolution(refr.Name, solution);
253 253
254 if (projectNode == null) 254 if (projectNode == null)
255 otherReferences.Add(refr); 255 otherReferences.Add(refr);
256 else 256 else
257 projectReferences.Add(refr, projectNode); 257 projectReferences.Add(refr, projectNode);
258 } 258 }
259 // Assembly References 259 // Assembly References
260 ps.WriteLine(" <ItemGroup>"); 260 ps.WriteLine(" <ItemGroup>");
261 261
262 foreach (ReferenceNode refr in otherReferences) 262 foreach (ReferenceNode refr in otherReferences)
263 { 263 {
264 ps.Write(" <Reference"); 264 ps.Write(" <Reference");
265 ps.Write(" Include=\""); 265 ps.Write(" Include=\"");
266 ps.Write(refr.Name); 266 ps.Write(refr.Name);
267 ps.WriteLine("\" >"); 267 ps.WriteLine("\" >");
268 ps.Write(" <Name>"); 268 ps.Write(" <Name>");
269 ps.Write(refr.Name); 269 ps.Write(refr.Name);
270 ps.WriteLine("</Name>"); 270 ps.WriteLine("</Name>");
271 271
272 if(!String.IsNullOrEmpty(refr.Path)) 272 if(!String.IsNullOrEmpty(refr.Path))
273 { 273 {
274 // Use absolute path to assembly (for determining assembly type) 274 // Use absolute path to assembly (for determining assembly type)
275 string absolutePath = Path.Combine(project.FullPath, refr.Path); 275 string absolutePath = Path.Combine(project.FullPath, refr.Path);
276 if(File.Exists(Helper.MakeFilePath(absolutePath, refr.Name, "exe"))) { 276 if(File.Exists(Helper.MakeFilePath(absolutePath, refr.Name, "exe"))) {
277 // Assembly is an executable (exe) 277 // Assembly is an executable (exe)
278 ps.WriteLine(" <HintPath>{0}</HintPath>", Helper.MakeFilePath(refr.Path, refr.Name, "exe")); 278 ps.WriteLine(" <HintPath>{0}</HintPath>", Helper.MakeFilePath(refr.Path, refr.Name, "exe"));
279 } else if(File.Exists(Helper.MakeFilePath(absolutePath, refr.Name, "dll"))) { 279 } else if(File.Exists(Helper.MakeFilePath(absolutePath, refr.Name, "dll"))) {
280 // Assembly is an library (dll) 280 // Assembly is an library (dll)
281 ps.WriteLine(" <HintPath>{0}</HintPath>", Helper.MakeFilePath(refr.Path, refr.Name, "dll")); 281 ps.WriteLine(" <HintPath>{0}</HintPath>", Helper.MakeFilePath(refr.Path, refr.Name, "dll"));
282 } else { 282 } else {
283 string referencePath = Helper.MakeFilePath(refr.Path, refr.Name, "dll"); 283 string referencePath = Helper.MakeFilePath(refr.Path, refr.Name, "dll");
284 kernel.Log.Write(LogType.Warning, "Reference \"{0}\": The specified file doesn't exist.", referencePath); 284 kernel.Log.Write(LogType.Warning, "Reference \"{0}\": The specified file doesn't exist.", referencePath);
285 ps.WriteLine(" <HintPath>{0}</HintPath>", Helper.MakeFilePath(refr.Path, refr.Name, "dll")); 285 ps.WriteLine(" <HintPath>{0}</HintPath>", Helper.MakeFilePath(refr.Path, refr.Name, "dll"));
286 } 286 }
287 } 287 }
288 288
289 ps.WriteLine(" <Private>{0}</Private>", refr.LocalCopy); 289 ps.WriteLine(" <Private>{0}</Private>", refr.LocalCopy);
290 ps.WriteLine(" </Reference>"); 290 ps.WriteLine(" </Reference>");
291 } 291 }
292 ps.WriteLine(" </ItemGroup>"); 292 ps.WriteLine(" </ItemGroup>");
293 293
294 //Project References 294 //Project References
295 ps.WriteLine(" <ItemGroup>"); 295 ps.WriteLine(" <ItemGroup>");
296 foreach (KeyValuePair<ReferenceNode, ProjectNode> pair in projectReferences) 296 foreach (KeyValuePair<ReferenceNode, ProjectNode> pair in projectReferences)
297 { 297 {
298 ToolInfo tool = tools[pair.Value.Language]; 298 ToolInfo tool = tools[pair.Value.Language];
299 if (tools == null) 299 if (tools == null)
300 throw new UnknownLanguageException(); 300 throw new UnknownLanguageException();
301 301
302 string path = 302 string path =
303 Helper.MakePathRelativeTo(project.FullPath, 303 Helper.MakePathRelativeTo(project.FullPath,
304 Helper.MakeFilePath(pair.Value.FullPath, pair.Value.Name, tool.FileExtension)); 304 Helper.MakeFilePath(pair.Value.FullPath, pair.Value.Name, tool.FileExtension));
305 ps.WriteLine(" <ProjectReference Include=\"{0}\">", path); 305 ps.WriteLine(" <ProjectReference Include=\"{0}\">", path);
306 306
307 // TODO: Allow reference to visual basic projects 307 // TODO: Allow reference to visual basic projects
308 ps.WriteLine(" <Name>{0}</Name>", pair.Value.Name); 308 ps.WriteLine(" <Name>{0}</Name>", pair.Value.Name);
309 ps.WriteLine(" <Project>{0}</Project>", pair.Value.Guid.ToString("B").ToUpper()); 309 ps.WriteLine(" <Project>{0}</Project>", pair.Value.Guid.ToString("B").ToUpper());
310 ps.WriteLine(" <Package>{0}</Package>", tool.Guid.ToUpper()); 310 ps.WriteLine(" <Package>{0}</Package>", tool.Guid.ToUpper());
311 311
312 //This is the Copy Local flag in VS 312 //This is the Copy Local flag in VS
313 ps.WriteLine(" <Private>{0}</Private>", pair.Key.LocalCopy); 313 ps.WriteLine(" <Private>{0}</Private>", pair.Key.LocalCopy);
314 314
315 ps.WriteLine(" </ProjectReference>"); 315 ps.WriteLine(" </ProjectReference>");
316 } 316 }
317 ps.WriteLine(" </ItemGroup>"); 317 ps.WriteLine(" </ItemGroup>");
318 318
319 // ps.WriteLine(" </Build>"); 319 // ps.WriteLine(" </Build>");
320 ps.WriteLine(" <ItemGroup>"); 320 ps.WriteLine(" <ItemGroup>");
321 321
322 // ps.WriteLine(" <Include>"); 322 // ps.WriteLine(" <Include>");
323 List<string> list = new List<string>(); 323 List<string> list = new List<string>();
324 324
325 foreach (string path in project.Files) 325 foreach (string path in project.Files)
326 { 326 {
327 string lower = path.ToLower(); 327 string lower = path.ToLower();
328 if (lower.EndsWith(".resx")) 328 if (lower.EndsWith(".resx"))
329 { 329 {
330 string codebehind = String.Format("{0}.Designer{1}", path.Substring(0, path.LastIndexOf('.')), toolInfo.LanguageExtension); 330 string codebehind = String.Format("{0}.Designer{1}", path.Substring(0, path.LastIndexOf('.')), toolInfo.LanguageExtension);
331 if (!list.Contains(codebehind)) 331 if (!list.Contains(codebehind))
332 list.Add(codebehind); 332 list.Add(codebehind);
333 } 333 }
334 334
335 } 335 }
336 336
337 foreach (string filePath in project.Files) 337 foreach (string filePath in project.Files)
338 { 338 {
339 // if (file == "Properties\\Bind.Designer.cs") 339 // if (file == "Properties\\Bind.Designer.cs")
340 // { 340 // {
341 // Console.WriteLine("Wait a minute!"); 341 // Console.WriteLine("Wait a minute!");
342 // Console.WriteLine(project.Files.GetSubType(file).ToString()); 342 // Console.WriteLine(project.Files.GetSubType(file).ToString());
343 // } 343 // }
344 SubType subType = project.Files.GetSubType(filePath); 344 SubType subType = project.Files.GetSubType(filePath);
345 345
346 // Visual Studio chokes on file names if forward slash is used as a path separator 346 // Visual Studio chokes on file names if forward slash is used as a path separator
347 // instead of backslash. So we must make sure that all file paths written to the 347 // instead of backslash. So we must make sure that all file paths written to the
348 // project file use \ as a path separator. 348 // project file use \ as a path separator.
349 string file = filePath.Replace(@"/", @"\"); 349 string file = filePath.Replace(@"/", @"\");
350 350
351 if (subType != SubType.Code && subType != SubType.Settings && subType != SubType.Designer 351 if (subType != SubType.Code && subType != SubType.Settings && subType != SubType.Designer
352 && subType != SubType.CodeBehind) 352 && subType != SubType.CodeBehind)
353 { 353 {
354 ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".resx"); 354 ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".resx");
355 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file)); 355 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file));
356 ps.WriteLine(" <SubType>Designer</SubType>"); 356 ps.WriteLine(" <SubType>Designer</SubType>");
357 ps.WriteLine(" </EmbeddedResource>"); 357 ps.WriteLine(" </EmbeddedResource>");
358 // 358 //
359 } 359 }
360 360
361 if (subType == SubType.Designer) 361 if (subType == SubType.Designer)
362 { 362 {
363 ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file); 363 ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file);
364 364
365 string autogen_name = file.Substring(0, file.LastIndexOf('.')) + ".Designer.cs"; 365 string autogen_name = file.Substring(0, file.LastIndexOf('.')) + ".Designer.cs";
366 string dependent_name = filePath.Substring(0, file.LastIndexOf('.')) + ".cs"; 366 string dependent_name = filePath.Substring(0, file.LastIndexOf('.')) + ".cs";
367 367
368 // Check for a parent .cs file with the same name as this designer file 368 // Check for a parent .cs file with the same name as this designer file
369 if (File.Exists(Helper.NormalizePath(dependent_name))) 369 if (File.Exists(Helper.NormalizePath(dependent_name)))
370 { 370 {
371 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(dependent_name)); 371 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(dependent_name));
372 } 372 }
373 else 373 else
374 { 374 {
375 ps.WriteLine(" <Generator>ResXFileCodeGenerator</Generator>"); 375 ps.WriteLine(" <Generator>ResXFileCodeGenerator</Generator>");
376 ps.WriteLine(" <LastGenOutput>{0}</LastGenOutput>", Path.GetFileName(autogen_name)); 376 ps.WriteLine(" <LastGenOutput>{0}</LastGenOutput>", Path.GetFileName(autogen_name));
377 ps.WriteLine(" <SubType>" + subType + "</SubType>"); 377 ps.WriteLine(" <SubType>" + subType + "</SubType>");
378 } 378 }
379 379
380 ps.WriteLine(" </EmbeddedResource>"); 380 ps.WriteLine(" </EmbeddedResource>");
381 if (File.Exists(Helper.NormalizePath(autogen_name))) 381 if (File.Exists(Helper.NormalizePath(autogen_name)))
382 { 382 {
383 ps.WriteLine(" <Compile Include=\"{0}\">", autogen_name); 383 ps.WriteLine(" <Compile Include=\"{0}\">", autogen_name);
384 //ps.WriteLine(" <DesignTime>True</DesignTime>"); 384 //ps.WriteLine(" <DesignTime>True</DesignTime>");
385 385
386 // If a parent .cs file exists, link this autogen file to it. Otherwise link 386 // If a parent .cs file exists, link this autogen file to it. Otherwise link
387 // to the designer file 387 // to the designer file
388 if (File.Exists(dependent_name)) 388 if (File.Exists(dependent_name))
389 { 389 {
390 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(dependent_name)); 390 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(dependent_name));
391 } 391 }
392 else 392 else
393 { 393 {
394 ps.WriteLine(" <AutoGen>True</AutoGen>"); 394 ps.WriteLine(" <AutoGen>True</AutoGen>");
395 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(filePath)); 395 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(filePath));
396 } 396 }
397 397
398 ps.WriteLine(" </Compile>"); 398 ps.WriteLine(" </Compile>");
399 } 399 }
400 list.Add(autogen_name); 400 list.Add(autogen_name);
401 } 401 }
402 if (subType == SubType.Settings) 402 if (subType == SubType.Settings)
403 { 403 {
404 ps.Write(" <{0} ", project.Files.GetBuildAction(filePath)); 404 ps.Write(" <{0} ", project.Files.GetBuildAction(filePath));
405 ps.WriteLine("Include=\"{0}\">", file); 405 ps.WriteLine("Include=\"{0}\">", file);
406 string fileName = Path.GetFileName(filePath); 406 string fileName = Path.GetFileName(filePath);
407 if (project.Files.GetBuildAction(filePath) == BuildAction.None) 407 if (project.Files.GetBuildAction(filePath) == BuildAction.None)
408 { 408 {
409 ps.WriteLine(" <Generator>SettingsSingleFileGenerator</Generator>"); 409 ps.WriteLine(" <Generator>SettingsSingleFileGenerator</Generator>");
410 ps.WriteLine(" <LastGenOutput>{0}</LastGenOutput>", fileName.Substring(0, fileName.LastIndexOf('.')) + ".Designer.cs"); 410 ps.WriteLine(" <LastGenOutput>{0}</LastGenOutput>", fileName.Substring(0, fileName.LastIndexOf('.')) + ".Designer.cs");
411 } 411 }
412 else 412 else
413 { 413 {
414 ps.WriteLine(" <SubType>Code</SubType>"); 414 ps.WriteLine(" <SubType>Code</SubType>");
415 ps.WriteLine(" <AutoGen>True</AutoGen>"); 415 ps.WriteLine(" <AutoGen>True</AutoGen>");
416 ps.WriteLine(" <DesignTimeSharedInput>True</DesignTimeSharedInput>"); 416 ps.WriteLine(" <DesignTimeSharedInput>True</DesignTimeSharedInput>");
417 string fileNameShort = fileName.Substring(0, fileName.LastIndexOf('.')); 417 string fileNameShort = fileName.Substring(0, fileName.LastIndexOf('.'));
418 string fileNameShorter = fileNameShort.Substring(0, fileNameShort.LastIndexOf('.')); 418 string fileNameShorter = fileNameShort.Substring(0, fileNameShort.LastIndexOf('.'));
419 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(fileNameShorter + ".settings")); 419 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(fileNameShorter + ".settings"));
420 } 420 }
421 ps.WriteLine(" </{0}>", project.Files.GetBuildAction(filePath)); 421 ps.WriteLine(" </{0}>", project.Files.GetBuildAction(filePath));
422 } 422 }
423 else if (subType != SubType.Designer) 423 else if (subType != SubType.Designer)
424 { 424 {
425 string path = Helper.NormalizePath(file); 425 string path = Helper.NormalizePath(file);
426 string path_lower = path.ToLower(); 426 string path_lower = path.ToLower();
427 427
428 if (!list.Contains(filePath)) 428 if (!list.Contains(filePath))
429 { 429 {
430 ps.Write(" <{0} ", project.Files.GetBuildAction(filePath)); 430 ps.Write(" <{0} ", project.Files.GetBuildAction(filePath));
431 431
432 int startPos = 0; 432 int startPos = 0;
433 if (project.Files.GetPreservePath(filePath)) 433 if (project.Files.GetPreservePath(filePath))
434 { 434 {
435 while ((@"./\").IndexOf(file.Substring(startPos, 1)) != -1) 435 while ((@"./\").IndexOf(file.Substring(startPos, 1)) != -1)
436 startPos++; 436 startPos++;
437 437
438 } 438 }
439 else 439 else
440 { 440 {
441 startPos = file.LastIndexOf(Path.GetFileName(path)); 441 startPos = file.LastIndexOf(Path.GetFileName(path));
442 } 442 }
443 443
444 // be sure to write out the path with backslashes so VS recognizes 444 // be sure to write out the path with backslashes so VS recognizes
445 // the file properly. 445 // the file properly.
446 ps.WriteLine("Include=\"{0}\">", file); 446 ps.WriteLine("Include=\"{0}\">", file);
447 447
448 int last_period_index = file.LastIndexOf('.'); 448 int last_period_index = file.LastIndexOf('.');
449 string short_file_name = file.Substring(0, last_period_index); 449 string short_file_name = file.Substring(0, last_period_index);
450 string extension = Path.GetExtension(path); 450 string extension = Path.GetExtension(path);
451 // make this upper case, so that when File.Exists tests for the 451 // make this upper case, so that when File.Exists tests for the
452 // existence of a designer file on a case-sensitive platform, 452 // existence of a designer file on a case-sensitive platform,
453 // it is correctly identified. 453 // it is correctly identified.
454 string designer_format = string.Format(".Designer{0}", extension); 454 string designer_format = string.Format(".Designer{0}", extension);
455 455
456 if (path_lower.EndsWith(designer_format.ToLowerInvariant())) 456 if (path_lower.EndsWith(designer_format.ToLowerInvariant()))
457 { 457 {
458 int designer_index = path.IndexOf(designer_format); 458 int designer_index = path.IndexOf(designer_format);
459 string file_name = path.Substring(0, designer_index); 459 string file_name = path.Substring(0, designer_index);
460 460
461 // There are two corrections to the next lines: 461 // There are two corrections to the next lines:
462 // 1. Fix the connection between a designer file and a form 462 // 1. Fix the connection between a designer file and a form
463 // or usercontrol that don't have an associated resx file. 463 // or usercontrol that don't have an associated resx file.
464 // 2. Connect settings files to associated designer files. 464 // 2. Connect settings files to associated designer files.
465 if (File.Exists(file_name + extension)) 465 if (File.Exists(file_name + extension))
466 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file_name + extension)); 466 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file_name + extension));
467 else if (File.Exists(file_name + ".resx")) 467 else if (File.Exists(file_name + ".resx"))
468 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file_name + ".resx")); 468 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file_name + ".resx"));
469 else if (File.Exists(file_name + ".settings")) 469 else if (File.Exists(file_name + ".settings"))
470 { 470 {
471 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file_name + ".settings")); 471 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file_name + ".settings"));
472 ps.WriteLine(" <AutoGen>True</AutoGen>"); 472 ps.WriteLine(" <AutoGen>True</AutoGen>");
473 ps.WriteLine(" <DesignTimeSharedInput>True</DesignTimeSharedInput>"); 473 ps.WriteLine(" <DesignTimeSharedInput>True</DesignTimeSharedInput>");
474 } 474 }
475 } 475 }
476 else if (subType == SubType.CodeBehind) 476 else if (subType == SubType.CodeBehind)
477 { 477 {
478 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(short_file_name)); 478 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(short_file_name));
479 } 479 }
480 if (project.Files.GetIsLink(filePath)) 480 if (project.Files.GetIsLink(filePath))
481 { 481 {
482 string alias = project.Files.GetLinkPath(filePath); 482 string alias = project.Files.GetLinkPath(filePath);
483 alias += file.Substring(startPos); 483 alias += file.Substring(startPos);
484 alias = Helper.NormalizePath(alias); 484 alias = Helper.NormalizePath(alias);
485 ps.WriteLine(" <Link>{0}</Link>", alias); 485 ps.WriteLine(" <Link>{0}</Link>", alias);
486 } 486 }
487 else if (project.Files.GetBuildAction(filePath) != BuildAction.None) 487 else if (project.Files.GetBuildAction(filePath) != BuildAction.None)
488 { 488 {
489 if (project.Files.GetBuildAction(filePath) != BuildAction.EmbeddedResource) 489 if (project.Files.GetBuildAction(filePath) != BuildAction.EmbeddedResource)
490 { 490 {
491 ps.WriteLine(" <SubType>{0}</SubType>", subType); 491 ps.WriteLine(" <SubType>{0}</SubType>", subType);
492 } 492 }
493 } 493 }
494 494
495 if (project.Files.GetCopyToOutput(filePath) != CopyToOutput.Never) 495 if (project.Files.GetCopyToOutput(filePath) != CopyToOutput.Never)
496 { 496 {
497 ps.WriteLine(" <CopyToOutputDirectory>{0}</CopyToOutputDirectory>", project.Files.GetCopyToOutput(filePath)); 497 ps.WriteLine(" <CopyToOutputDirectory>{0}</CopyToOutputDirectory>", project.Files.GetCopyToOutput(filePath));
498 } 498 }
499 499
500 ps.WriteLine(" </{0}>", project.Files.GetBuildAction(filePath)); 500 ps.WriteLine(" </{0}>", project.Files.GetBuildAction(filePath));
501 } 501 }
502 } 502 }
503 } 503 }
504 504
505 ps.WriteLine(" </ItemGroup>"); 505 ps.WriteLine(" </ItemGroup>");
506 ps.WriteLine(" <Import Project=\"" + toolInfo.ImportProject + "\" />"); 506 ps.WriteLine(" <Import Project=\"" + toolInfo.ImportProject + "\" />");
507 ps.WriteLine(" <PropertyGroup>"); 507 ps.WriteLine(" <PropertyGroup>");
508 ps.WriteLine(" <PreBuildEvent>"); 508 ps.WriteLine(" <PreBuildEvent>");
509 ps.WriteLine(" </PreBuildEvent>"); 509 ps.WriteLine(" </PreBuildEvent>");
510 ps.WriteLine(" <PostBuildEvent>"); 510 ps.WriteLine(" <PostBuildEvent>");
511 ps.WriteLine(" </PostBuildEvent>"); 511 ps.WriteLine(" </PostBuildEvent>");
512 ps.WriteLine(" </PropertyGroup>"); 512 ps.WriteLine(" </PropertyGroup>");
513 ps.WriteLine("</Project>"); 513 ps.WriteLine("</Project>");
514 } 514 }
515 #endregion 515 #endregion
516 516
517 #region User File 517 #region User File
518 518
519 ps = new StreamWriter(projectFile + ".user"); 519 ps = new StreamWriter(projectFile + ".user");
520 using (ps) 520 using (ps)
521 { 521 {
522 // Get the first configuration from the project. 522 // Get the first configuration from the project.
523 ConfigurationNode firstConfiguration = null; 523 ConfigurationNode firstConfiguration = null;
524 524
525 if (project.Configurations.Count > 0) 525 if (project.Configurations.Count > 0)
526 { 526 {
527 firstConfiguration = project.Configurations[0]; 527 firstConfiguration = project.Configurations[0];
528 } 528 }
529 529
530 ps.WriteLine("<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">"); 530 ps.WriteLine("<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">");
531 //ps.WriteLine( "<VisualStudioProject>" ); 531 //ps.WriteLine( "<VisualStudioProject>" );
532 //ps.WriteLine(" <{0}>", toolInfo.XMLTag); 532 //ps.WriteLine(" <{0}>", toolInfo.XMLTag);
533 //ps.WriteLine(" <Build>"); 533 //ps.WriteLine(" <Build>");
534 ps.WriteLine(" <PropertyGroup>"); 534 ps.WriteLine(" <PropertyGroup>");
535 //ps.WriteLine(" <Settings ReferencePath=\"{0}\">", MakeRefPath(project)); 535 //ps.WriteLine(" <Settings ReferencePath=\"{0}\">", MakeRefPath(project));
536 536
537 if (firstConfiguration != null) 537 if (firstConfiguration != null)
538 { 538 {
539 ps.WriteLine(" <Configuration Condition=\" '$(Configuration)' == '' \">{0}</Configuration>", firstConfiguration.Name); 539 ps.WriteLine(" <Configuration Condition=\" '$(Configuration)' == '' \">{0}</Configuration>", firstConfiguration.Name);
540 ps.WriteLine(" <Platform Condition=\" '$(Platform)' == '' \">{0}</Platform>", firstConfiguration.Platform); 540 ps.WriteLine(" <Platform Condition=\" '$(Platform)' == '' \">{0}</Platform>", firstConfiguration.Platform);
541 } 541 }
542 542
543 ps.WriteLine(" <ReferencePath>{0}</ReferencePath>", MakeRefPath(project)); 543 ps.WriteLine(" <ReferencePath>{0}</ReferencePath>", MakeRefPath(project));
544 ps.WriteLine(" <LastOpenVersion>{0}</LastOpenVersion>", ProductVersion); 544 ps.WriteLine(" <LastOpenVersion>{0}</LastOpenVersion>", ProductVersion);
545 ps.WriteLine(" <ProjectView>ProjectFiles</ProjectView>"); 545 ps.WriteLine(" <ProjectView>ProjectFiles</ProjectView>");
546 ps.WriteLine(" <ProjectTrust>0</ProjectTrust>"); 546 ps.WriteLine(" <ProjectTrust>0</ProjectTrust>");
547 ps.WriteLine(" </PropertyGroup>"); 547 ps.WriteLine(" </PropertyGroup>");
548 foreach (ConfigurationNode conf in project.Configurations) 548 foreach (ConfigurationNode conf in project.Configurations)
549 { 549 {
550 ps.Write(" <PropertyGroup"); 550 ps.Write(" <PropertyGroup");
551 ps.Write(" Condition = \" '$(Configuration)|$(Platform)' == '{0}|{1}' \"", conf.Name, conf.Platform); 551 ps.Write(" Condition = \" '$(Configuration)|$(Platform)' == '{0}|{1}' \"", conf.Name, conf.Platform);
552 ps.WriteLine(" />"); 552 ps.WriteLine(" />");
553 } 553 }
554 ps.WriteLine("</Project>"); 554 ps.WriteLine("</Project>");
555 } 555 }
556 #endregion 556 #endregion
557 557
558 kernel.CurrentWorkingDirectory.Pop(); 558 kernel.CurrentWorkingDirectory.Pop();
559 } 559 }
560 560
561 private void WriteSolution(SolutionNode solution, bool writeSolutionToDisk) 561 private void WriteSolution(SolutionNode solution, bool writeSolutionToDisk)
562 { 562 {
563 kernel.Log.Write("Creating {0} solution and project files", VersionName); 563 kernel.Log.Write("Creating {0} solution and project files", VersionName);
564 564
565 foreach (SolutionNode child in solution.Solutions) 565 foreach (SolutionNode child in solution.Solutions)
566 { 566 {
567 kernel.Log.Write("...Creating folder: {0}", child.Name); 567 kernel.Log.Write("...Creating folder: {0}", child.Name);
568 WriteSolution(child, false); 568 WriteSolution(child, false);
569 } 569 }
570 570
571 foreach (ProjectNode project in solution.Projects) 571 foreach (ProjectNode project in solution.Projects)
572 { 572 {
573 kernel.Log.Write("...Creating project: {0}", project.Name); 573 kernel.Log.Write("...Creating project: {0}", project.Name);
574 WriteProject(solution, project); 574 WriteProject(solution, project);
575 } 575 }
576 576
577 foreach (DatabaseProjectNode project in solution.DatabaseProjects) 577 foreach (DatabaseProjectNode project in solution.DatabaseProjects)
578 { 578 {
579 kernel.Log.Write("...Creating database project: {0}", project.Name); 579 kernel.Log.Write("...Creating database project: {0}", project.Name);
580 WriteDatabaseProject(solution, project); 580 WriteDatabaseProject(solution, project);
581 } 581 }
582 582
583 if (writeSolutionToDisk) // only write main solution 583 if (writeSolutionToDisk) // only write main solution
584 { 584 {
585 kernel.Log.Write(""); 585 kernel.Log.Write("");
586 string solutionFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln"); 586 string solutionFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln");
587 587
588 using (StreamWriter ss = new StreamWriter(solutionFile)) 588 using (StreamWriter ss = new StreamWriter(solutionFile))
589 { 589 {
590 kernel.CurrentWorkingDirectory.Push(); 590 kernel.CurrentWorkingDirectory.Push();
591 Helper.SetCurrentDir(Path.GetDirectoryName(solutionFile)); 591 Helper.SetCurrentDir(Path.GetDirectoryName(solutionFile));
592 592
593 ss.WriteLine("Microsoft Visual Studio Solution File, Format Version {0}", SolutionVersion); 593 ss.WriteLine("Microsoft Visual Studio Solution File, Format Version {0}", SolutionVersion);
594 ss.WriteLine(SolutionTag); 594 ss.WriteLine(SolutionTag);
595 595
596 WriteProjectDeclarations(ss, solution, solution); 596 WriteProjectDeclarations(ss, solution, solution);
597 597
598 ss.WriteLine("Global"); 598 ss.WriteLine("Global");
599 599
600 ss.WriteLine("\tGlobalSection(SolutionConfigurationPlatforms) = preSolution"); 600 ss.WriteLine("\tGlobalSection(SolutionConfigurationPlatforms) = preSolution");
601 foreach (ConfigurationNode conf in solution.Configurations) 601 foreach (ConfigurationNode conf in solution.Configurations)
602 { 602 {
603 ss.WriteLine("\t\t{0} = {0}", conf.NameAndPlatform); 603 ss.WriteLine("\t\t{0} = {0}", conf.NameAndPlatform);
604 } 604 }
605 ss.WriteLine("\tEndGlobalSection"); 605 ss.WriteLine("\tEndGlobalSection");
606 606
607 ss.WriteLine("\tGlobalSection(ProjectConfigurationPlatforms) = postSolution"); 607 ss.WriteLine("\tGlobalSection(ProjectConfigurationPlatforms) = postSolution");
608 WriteConfigurationLines(solution.Configurations, solution, ss); 608 WriteConfigurationLines(solution.Configurations, solution, ss);
609 ss.WriteLine("\tEndGlobalSection"); 609 ss.WriteLine("\tEndGlobalSection");
610 610
611 if (solution.Solutions.Count > 0) 611 if (solution.Solutions.Count > 0)
612 { 612 {
613 ss.WriteLine("\tGlobalSection(NestedProjects) = preSolution"); 613 ss.WriteLine("\tGlobalSection(NestedProjects) = preSolution");
614 foreach (SolutionNode embeddedSolution in solution.Solutions) 614 foreach (SolutionNode embeddedSolution in solution.Solutions)
615 { 615 {
616 WriteNestedProjectMap(ss, embeddedSolution); 616 WriteNestedProjectMap(ss, embeddedSolution);
617 } 617 }
618 ss.WriteLine("\tEndGlobalSection"); 618 ss.WriteLine("\tEndGlobalSection");
619 } 619 }
620 620
621 ss.WriteLine("EndGlobal"); 621 ss.WriteLine("EndGlobal");
622 } 622 }
623 623
624 kernel.CurrentWorkingDirectory.Pop(); 624 kernel.CurrentWorkingDirectory.Pop();
625 } 625 }
626 } 626 }
627 627
628 private void WriteProjectDeclarations(TextWriter writer, SolutionNode actualSolution, SolutionNode embeddedSolution) 628 private void WriteProjectDeclarations(TextWriter writer, SolutionNode actualSolution, SolutionNode embeddedSolution)
629 { 629 {
630 foreach (SolutionNode childSolution in embeddedSolution.Solutions) 630 foreach (SolutionNode childSolution in embeddedSolution.Solutions)
631 { 631 {
632 WriteEmbeddedSolution(writer, childSolution); 632 WriteEmbeddedSolution(writer, childSolution);
633 WriteProjectDeclarations(writer, actualSolution, childSolution); 633 WriteProjectDeclarations(writer, actualSolution, childSolution);
634 } 634 }
635 635
636 foreach (ProjectNode project in embeddedSolution.Projects) 636 foreach (ProjectNode project in embeddedSolution.Projects)
637 { 637 {
638 WriteProject(actualSolution, writer, project); 638 WriteProject(actualSolution, writer, project);
639 } 639 }
640 640
641 foreach (DatabaseProjectNode dbProject in embeddedSolution.DatabaseProjects) 641 foreach (DatabaseProjectNode dbProject in embeddedSolution.DatabaseProjects)
642 { 642 {
643 WriteProject(actualSolution, writer, dbProject); 643 WriteProject(actualSolution, writer, dbProject);
644 } 644 }
645 645
646 if (actualSolution.Guid == embeddedSolution.Guid) 646 if (actualSolution.Guid == embeddedSolution.Guid)
647 { 647 {
648 WriteSolutionFiles(actualSolution, writer); 648 WriteSolutionFiles(actualSolution, writer);
649 } 649 }
650 } 650 }
651 651
652 private static void WriteNestedProjectMap(TextWriter writer, SolutionNode embeddedSolution) 652 private static void WriteNestedProjectMap(TextWriter writer, SolutionNode embeddedSolution)
653 { 653 {
654 foreach (ProjectNode project in embeddedSolution.Projects) 654 foreach (ProjectNode project in embeddedSolution.Projects)
655 { 655 {
656 WriteNestedProject(writer, embeddedSolution, project.Guid); 656 WriteNestedProject(writer, embeddedSolution, project.Guid);
657 } 657 }
658 658
659 foreach (DatabaseProjectNode dbProject in embeddedSolution.DatabaseProjects) 659 foreach (DatabaseProjectNode dbProject in embeddedSolution.DatabaseProjects)
660 { 660 {
661 WriteNestedProject(writer, embeddedSolution, dbProject.Guid); 661 WriteNestedProject(writer, embeddedSolution, dbProject.Guid);
662 } 662 }
663 663
664 foreach (SolutionNode child in embeddedSolution.Solutions) 664 foreach (SolutionNode child in embeddedSolution.Solutions)
665 { 665 {
666 WriteNestedProject(writer, embeddedSolution, child.Guid); 666 WriteNestedProject(writer, embeddedSolution, child.Guid);
667 WriteNestedProjectMap(writer, child); 667 WriteNestedProjectMap(writer, child);
668 } 668 }
669 } 669 }
670 670
671 private static void WriteNestedProject(TextWriter writer, SolutionNode solution, Guid projectGuid) 671 private static void WriteNestedProject(TextWriter writer, SolutionNode solution, Guid projectGuid)
672 { 672 {
673 WriteNestedFolder(writer, solution.Guid, projectGuid); 673 WriteNestedFolder(writer, solution.Guid, projectGuid);
674 } 674 }
675 675
676 private static void WriteNestedFolder(TextWriter writer, Guid parentGuid, Guid childGuid) 676 private static void WriteNestedFolder(TextWriter writer, Guid parentGuid, Guid childGuid)
677 { 677 {
678 writer.WriteLine("\t\t{0} = {1}", 678 writer.WriteLine("\t\t{0} = {1}",
679 childGuid.ToString("B").ToUpper(), 679 childGuid.ToString("B").ToUpper(),
680 parentGuid.ToString("B").ToUpper()); 680 parentGuid.ToString("B").ToUpper());
681 } 681 }
682 682
683 private static void WriteConfigurationLines(IEnumerable<ConfigurationNode> configurations, SolutionNode solution, TextWriter ss) 683 private static void WriteConfigurationLines(IEnumerable<ConfigurationNode> configurations, SolutionNode solution, TextWriter ss)
684 { 684 {
685 foreach (ProjectNode project in solution.Projects) 685 foreach (ProjectNode project in solution.Projects)
686 { 686 {
687 foreach (ConfigurationNode conf in configurations) 687 foreach (ConfigurationNode conf in configurations)
688 { 688 {
689 ss.WriteLine("\t\t{0}.{1}.ActiveCfg = {1}", 689 ss.WriteLine("\t\t{0}.{1}.ActiveCfg = {1}",
690 project.Guid.ToString("B").ToUpper(), 690 project.Guid.ToString("B").ToUpper(),
691 conf.NameAndPlatform); 691 conf.NameAndPlatform);
692 692
693 ss.WriteLine("\t\t{0}.{1}.Build.0 = {1}", 693 ss.WriteLine("\t\t{0}.{1}.Build.0 = {1}",
694 project.Guid.ToString("B").ToUpper(), 694 project.Guid.ToString("B").ToUpper(),
695 conf.NameAndPlatform); 695 conf.NameAndPlatform);
696 } 696 }
697 } 697 }
698 698
699 foreach (SolutionNode child in solution.Solutions) 699 foreach (SolutionNode child in solution.Solutions)
700 { 700 {
701 WriteConfigurationLines(configurations, child, ss); 701 WriteConfigurationLines(configurations, child, ss);
702 } 702 }
703 } 703 }
704 704
705 private void WriteSolutionFiles(SolutionNode solution, TextWriter ss) 705 private void WriteSolutionFiles(SolutionNode solution, TextWriter ss)
706 { 706 {
707 if(solution.Files != null && solution.Files.Count > 0) 707 if(solution.Files != null && solution.Files.Count > 0)
708 WriteProject(ss, "Folder", solution.Guid, "Solution Files", "Solution Files", solution.Files); 708 WriteProject(ss, "Folder", solution.Guid, "Solution Files", "Solution Files", solution.Files);
709 } 709 }
710 710
711 private void WriteEmbeddedSolution(TextWriter writer, SolutionNode embeddedSolution) 711 private void WriteEmbeddedSolution(TextWriter writer, SolutionNode embeddedSolution)
712 { 712 {
713 WriteProject(writer, "Folder", embeddedSolution.Guid, embeddedSolution.Name, embeddedSolution.Name, embeddedSolution.Files); 713 WriteProject(writer, "Folder", embeddedSolution.Guid, embeddedSolution.Name, embeddedSolution.Name, embeddedSolution.Files);
714 } 714 }
715 715
716 private void WriteProject(SolutionNode solution, TextWriter ss, ProjectNode project) 716 private void WriteProject(SolutionNode solution, TextWriter ss, ProjectNode project)
717 { 717 {
718 WriteProject(ss, solution, project.Language, project.Guid, project.Name, project.FullPath); 718 WriteProject(ss, solution, project.Language, project.Guid, project.Name, project.FullPath);
719 } 719 }
720 720
721 private void WriteProject(SolutionNode solution, TextWriter ss, DatabaseProjectNode dbProject) 721 private void WriteProject(SolutionNode solution, TextWriter ss, DatabaseProjectNode dbProject)
722 { 722 {
723 if (solution.Files != null && solution.Files.Count > 0) 723 if (solution.Files != null && solution.Files.Count > 0)
724 WriteProject(ss, solution, "Database", dbProject.Guid, dbProject.Name, dbProject.FullPath); 724 WriteProject(ss, solution, "Database", dbProject.Guid, dbProject.Name, dbProject.FullPath);
725 } 725 }
726 726
727 const string ProjectDeclarationBeginFormat = "Project(\"{0}\") = \"{1}\", \"{2}\", \"{3}\""; 727 const string ProjectDeclarationBeginFormat = "Project(\"{0}\") = \"{1}\", \"{2}\", \"{3}\"";
728 const string ProjectDeclarationEndFormat = "EndProject"; 728 const string ProjectDeclarationEndFormat = "EndProject";
729 729
730 private void WriteProject(TextWriter ss, SolutionNode solution, string language, Guid guid, string name, string projectFullPath) 730 private void WriteProject(TextWriter ss, SolutionNode solution, string language, Guid guid, string name, string projectFullPath)
731 { 731 {
732 if (!tools.ContainsKey(language)) 732 if (!tools.ContainsKey(language))
733 throw new UnknownLanguageException("Unknown .NET language: " + language); 733 throw new UnknownLanguageException("Unknown .NET language: " + language);
734 734
735 ToolInfo toolInfo = tools[language]; 735 ToolInfo toolInfo = tools[language];
736 736
737 string path = Helper.MakePathRelativeTo(solution.FullPath, projectFullPath); 737 string path = Helper.MakePathRelativeTo(solution.FullPath, projectFullPath);
738 738
739 path = Helper.MakeFilePath(path, name, toolInfo.FileExtension); 739 path = Helper.MakeFilePath(path, name, toolInfo.FileExtension);
740 740
741 WriteProject(ss, language, guid, name, path); 741 WriteProject(ss, language, guid, name, path);
742 } 742 }
743 743
744 private void WriteProject(TextWriter writer, string language, Guid projectGuid, string name, string location) 744 private void WriteProject(TextWriter writer, string language, Guid projectGuid, string name, string location)
745 { 745 {
746 WriteProject(writer, language, projectGuid, name, location, null); 746 WriteProject(writer, language, projectGuid, name, location, null);
747 } 747 }
748 748
749 private void WriteProject(TextWriter writer, string language, Guid projectGuid, string name, string location, FilesNode files) 749 private void WriteProject(TextWriter writer, string language, Guid projectGuid, string name, string location, FilesNode files)
750 { 750 {
751 if (!tools.ContainsKey(language)) 751 if (!tools.ContainsKey(language))
752 throw new UnknownLanguageException("Unknown .NET language: " + language); 752 throw new UnknownLanguageException("Unknown .NET language: " + language);
753 753
754 ToolInfo toolInfo = tools[language]; 754 ToolInfo toolInfo = tools[language];
755 755
756 writer.WriteLine(ProjectDeclarationBeginFormat, 756 writer.WriteLine(ProjectDeclarationBeginFormat,
757 toolInfo.Guid, 757 toolInfo.Guid,
758 name, 758 name,
759 location, 759 location,
760 projectGuid.ToString("B").ToUpper()); 760 projectGuid.ToString("B").ToUpper());
761 761
762 if (files != null) 762 if (files != null)
763 { 763 {
764 writer.WriteLine("\tProjectSection(SolutionItems) = preProject"); 764 writer.WriteLine("\tProjectSection(SolutionItems) = preProject");
765 765
766 foreach (string file in files) 766 foreach (string file in files)
767 writer.WriteLine("\t\t{0} = {0}", file); 767 writer.WriteLine("\t\t{0} = {0}", file);
768 768
769 writer.WriteLine("\tEndProjectSection"); 769 writer.WriteLine("\tEndProjectSection");
770 } 770 }
771 771
772 writer.WriteLine(ProjectDeclarationEndFormat); 772 writer.WriteLine(ProjectDeclarationEndFormat);
773 } 773 }
774 774
775 private void WriteDatabaseProject(SolutionNode solution, DatabaseProjectNode project) 775 private void WriteDatabaseProject(SolutionNode solution, DatabaseProjectNode project)
776 { 776 {
777 string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, "dbp"); 777 string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, "dbp");
778 IndentedTextWriter ps = new IndentedTextWriter(new StreamWriter(projectFile), " "); 778 IndentedTextWriter ps = new IndentedTextWriter(new StreamWriter(projectFile), " ");
779 779
780 kernel.CurrentWorkingDirectory.Push(); 780 kernel.CurrentWorkingDirectory.Push();
781 781
782 Helper.SetCurrentDir(Path.GetDirectoryName(projectFile)); 782 Helper.SetCurrentDir(Path.GetDirectoryName(projectFile));
783 783
784 using (ps) 784 using (ps)
785 { 785 {
786 ps.WriteLine("# Microsoft Developer Studio Project File - Database Project"); 786 ps.WriteLine("# Microsoft Developer Studio Project File - Database Project");
787 ps.WriteLine("Begin DataProject = \"{0}\"", project.Name); 787 ps.WriteLine("Begin DataProject = \"{0}\"", project.Name);
788 ps.Indent++; 788 ps.Indent++;
789 ps.WriteLine("MSDTVersion = \"80\""); 789 ps.WriteLine("MSDTVersion = \"80\"");
790 // TODO: Use the project.Files property 790 // TODO: Use the project.Files property
791 if (ContainsSqlFiles(Path.GetDirectoryName(projectFile))) 791 if (ContainsSqlFiles(Path.GetDirectoryName(projectFile)))
792 WriteDatabaseFoldersAndFiles(ps, Path.GetDirectoryName(projectFile)); 792 WriteDatabaseFoldersAndFiles(ps, Path.GetDirectoryName(projectFile));
793 793
794 ps.WriteLine("Begin DBRefFolder = \"Database References\""); 794 ps.WriteLine("Begin DBRefFolder = \"Database References\"");
795 ps.Indent++; 795 ps.Indent++;
796 foreach (DatabaseReferenceNode reference in project.References) 796 foreach (DatabaseReferenceNode reference in project.References)
797 { 797 {
798 ps.WriteLine("Begin DBRefNode = \"{0}\"", reference.Name); 798 ps.WriteLine("Begin DBRefNode = \"{0}\"", reference.Name);
799 ps.Indent++; 799 ps.Indent++;
800 ps.WriteLine("ConnectStr = \"{0}\"", reference.ConnectionString); 800 ps.WriteLine("ConnectStr = \"{0}\"", reference.ConnectionString);
801 ps.WriteLine("Provider = \"{0}\"", reference.ProviderId.ToString("B").ToUpper()); 801 ps.WriteLine("Provider = \"{0}\"", reference.ProviderId.ToString("B").ToUpper());
802 //ps.WriteLine("Colorizer = 5"); 802 //ps.WriteLine("Colorizer = 5");
803 ps.Indent--; 803 ps.Indent--;
804 ps.WriteLine("End"); 804 ps.WriteLine("End");
805 } 805 }
806 ps.Indent--; 806 ps.Indent--;
807 ps.WriteLine("End"); 807 ps.WriteLine("End");
808 ps.Indent--; 808 ps.Indent--;
809 ps.WriteLine("End"); 809 ps.WriteLine("End");
810 810
811 ps.Flush(); 811 ps.Flush();
812 } 812 }
813 813
814 kernel.CurrentWorkingDirectory.Pop(); 814 kernel.CurrentWorkingDirectory.Pop();
815 } 815 }
816 816
817 private static bool ContainsSqlFiles(string folder) 817 private static bool ContainsSqlFiles(string folder)
818 { 818 {
819 if(Directory.GetFiles(folder, "*.sql").Length > 0) 819 if(Directory.GetFiles(folder, "*.sql").Length > 0)
820 return true; // if the folder contains 1 .sql file, that's good enough 820 return true; // if the folder contains 1 .sql file, that's good enough
821 821
822 foreach (string child in Directory.GetDirectories(folder)) 822 foreach (string child in Directory.GetDirectories(folder))
823 { 823 {
824 if (ContainsSqlFiles(child)) 824 if (ContainsSqlFiles(child))
825 return true; // if 1 child folder contains a .sql file, still good enough 825 return true; // if 1 child folder contains a .sql file, still good enough
826 } 826 }
827 827
828 return false; 828 return false;
829 } 829 }
830 830
831 private static void WriteDatabaseFoldersAndFiles(IndentedTextWriter writer, string folder) 831 private static void WriteDatabaseFoldersAndFiles(IndentedTextWriter writer, string folder)
832 { 832 {
833 foreach (string child in Directory.GetDirectories(folder)) 833 foreach (string child in Directory.GetDirectories(folder))
834 { 834 {
835 if (ContainsSqlFiles(child)) 835 if (ContainsSqlFiles(child))
836 { 836 {
837 writer.WriteLine("Begin Folder = \"{0}\"", Path.GetFileName(child)); 837 writer.WriteLine("Begin Folder = \"{0}\"", Path.GetFileName(child));
838 writer.Indent++; 838 writer.Indent++;
839 WriteDatabaseFoldersAndFiles(writer, child); 839 WriteDatabaseFoldersAndFiles(writer, child);
840 writer.Indent--; 840 writer.Indent--;
841 writer.WriteLine("End"); 841 writer.WriteLine("End");
842 } 842 }
843 } 843 }
844 foreach (string file in Directory.GetFiles(folder, "*.sql")) 844 foreach (string file in Directory.GetFiles(folder, "*.sql"))
845 { 845 {
846 writer.WriteLine("Script = \"{0}\"", Path.GetFileName(file)); 846 writer.WriteLine("Script = \"{0}\"", Path.GetFileName(file));
847 } 847 }
848 } 848 }
849 849
850 private void CleanProject(ProjectNode project) 850 private void CleanProject(ProjectNode project)
851 { 851 {
852 kernel.Log.Write("...Cleaning project: {0}", project.Name); 852 kernel.Log.Write("...Cleaning project: {0}", project.Name);
853 853
854 ToolInfo toolInfo = tools[project.Language]; 854 ToolInfo toolInfo = tools[project.Language];
855 string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); 855 string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension);
856 string userFile = projectFile + ".user"; 856 string userFile = projectFile + ".user";
857 857
858 Helper.DeleteIfExists(projectFile); 858 Helper.DeleteIfExists(projectFile);
859 Helper.DeleteIfExists(userFile); 859 Helper.DeleteIfExists(userFile);
860 } 860 }
861 861
862 private void CleanSolution(SolutionNode solution) 862 private void CleanSolution(SolutionNode solution)
863 { 863 {
864 kernel.Log.Write("Cleaning {0} solution and project files", VersionName, solution.Name); 864 kernel.Log.Write("Cleaning {0} solution and project files", VersionName, solution.Name);
865 865
866 string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln"); 866 string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln");
867 string suoFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "suo"); 867 string suoFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "suo");
868 868
869 Helper.DeleteIfExists(slnFile); 869 Helper.DeleteIfExists(slnFile);
870 Helper.DeleteIfExists(suoFile); 870 Helper.DeleteIfExists(suoFile);
871 871
872 foreach (ProjectNode project in solution.Projects) 872 foreach (ProjectNode project in solution.Projects)
873 { 873 {
874 CleanProject(project); 874 CleanProject(project);
875 } 875 }
876 876
877 kernel.Log.Write(""); 877 kernel.Log.Write("");
878 } 878 }
879 879
880 #endregion 880 #endregion
881 881
882 #region ITarget Members 882 #region ITarget Members
883 883
884 /// <summary> 884 /// <summary>
885 /// Writes the specified kern. 885 /// Writes the specified kern.
886 /// </summary> 886 /// </summary>
887 /// <param name="kern">The kern.</param> 887 /// <param name="kern">The kern.</param>
888 public virtual void Write(Kernel kern) 888 public virtual void Write(Kernel kern)
889 { 889 {
890 if (kern == null) 890 if (kern == null)
891 { 891 {
892 throw new ArgumentNullException("kern"); 892 throw new ArgumentNullException("kern");
893 } 893 }
894 kernel = kern; 894 kernel = kern;
895 foreach (SolutionNode sol in kernel.Solutions) 895 foreach (SolutionNode sol in kernel.Solutions)
896 { 896 {
897 WriteSolution(sol, true); 897 WriteSolution(sol, true);
898 } 898 }
899 kernel = null; 899 kernel = null;
900 } 900 }
901 901
902 /// <summary> 902 /// <summary>
903 /// Cleans the specified kern. 903 /// Cleans the specified kern.
904 /// </summary> 904 /// </summary>
905 /// <param name="kern">The kern.</param> 905 /// <param name="kern">The kern.</param>
906 public virtual void Clean(Kernel kern) 906 public virtual void Clean(Kernel kern)
907 { 907 {
908 if (kern == null) 908 if (kern == null)
909 { 909 {
910 throw new ArgumentNullException("kern"); 910 throw new ArgumentNullException("kern");
911 } 911 }
912 kernel = kern; 912 kernel = kern;
913 foreach (SolutionNode sol in kernel.Solutions) 913 foreach (SolutionNode sol in kernel.Solutions)
914 { 914 {
915 CleanSolution(sol); 915 CleanSolution(sol);
916 } 916 }
917 kernel = null; 917 kernel = null;
918 } 918 }
919 919
920 #endregion 920 #endregion
921 } 921 }
922} 922}
diff --git a/Prebuild/src/Core/Targets/AutotoolsTarget.cs b/Prebuild/src/Core/Targets/AutotoolsTarget.cs
index e46b5a5..485e4dd 100644
--- a/Prebuild/src/Core/Targets/AutotoolsTarget.cs
+++ b/Prebuild/src/Core/Targets/AutotoolsTarget.cs
@@ -1,1070 +1,1070 @@
1#region BSD License 1#region BSD License
2/* 2/*
3 3
4Copyright (c) 2004 - 2008 4Copyright (c) 2004 - 2008
5Matthew Holmes (matthew@wildfiregames.com), 5Matthew Holmes (matthew@wildfiregames.com),
6Dan Moorehead (dan05a@gmail.com), 6Dan Moorehead (dan05a@gmail.com),
7Dave Hudson (jendave@yahoo.com), 7Dave Hudson (jendave@yahoo.com),
8C.J. Adams-Collier (cjac@colliertech.org), 8C.J. Adams-Collier (cjac@colliertech.org),
9 9
10Redistribution and use in source and binary forms, with or without 10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are 11modification, are permitted provided that the following conditions are
12met: 12met:
13 13
14* Redistributions of source code must retain the above copyright 14* Redistributions of source code must retain the above copyright
15notice, this list of conditions and the following disclaimer. 15notice, this list of conditions and the following disclaimer.
16 16
17* Redistributions in binary form must reproduce the above copyright 17* Redistributions in binary form must reproduce the above copyright
18notice, this list of conditions and the following disclaimer in the 18notice, this list of conditions and the following disclaimer in the
19documentation and/or other materials provided with the distribution. 19documentation and/or other materials provided with the distribution.
20 20
21* The name of the author may not be used to endorse or promote 21* The name of the author may not be used to endorse or promote
22products derived from this software without specific prior written 22products derived from this software without specific prior written
23permission. 23permission.
24 24
25THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 25THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
26IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 26IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
27WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 28DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
29INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
33STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 33STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
34IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35POSSIBILITY OF SUCH DAMAGE. 35POSSIBILITY OF SUCH DAMAGE.
36 36
37*/ 37*/
38#endregion 38#endregion
39 39
40#region MIT X11 license 40#region MIT X11 license
41 41
42/* 42/*
43 Portions of this file authored by Lluis Sanchez Gual 43 Portions of this file authored by Lluis Sanchez Gual
44 44
45 Copyright (C) 2006 Novell, Inc (http://www.novell.com) 45 Copyright (C) 2006 Novell, Inc (http://www.novell.com)
46 46
47 Permission is hereby granted, free of charge, to any person obtaining 47 Permission is hereby granted, free of charge, to any person obtaining
48 a copy of this software and associated documentation files (the 48 a copy of this software and associated documentation files (the
49 "Software"), to deal in the Software without restriction, including 49 "Software"), to deal in the Software without restriction, including
50 without limitation the rights to use, copy, modify, merge, publish, 50 without limitation the rights to use, copy, modify, merge, publish,
51 distribute, sublicense, and/or sell copies of the Software, and to 51 distribute, sublicense, and/or sell copies of the Software, and to
52 permit persons to whom the Software is furnished to do so, subject to 52 permit persons to whom the Software is furnished to do so, subject to
53 the following conditions: 53 the following conditions:
54 54
55 The above copyright notice and this permission notice shall be 55 The above copyright notice and this permission notice shall be
56 included in all copies or substantial portions of the Software. 56 included in all copies or substantial portions of the Software.
57 57
58 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 58 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
59 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 59 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
60 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 60 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
61 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 61 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
62 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 62 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
63 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 63 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
64 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 64 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
65 */ 65 */
66 66
67#endregion 67#endregion
68using System; 68using System;
69using System.Collections.Generic; 69using System.Collections.Generic;
70using System.IO; 70using System.IO;
71using System.Reflection; 71using System.Reflection;
72using System.Text; 72using System.Text;
73using System.Text.RegularExpressions; 73using System.Text.RegularExpressions;
74using System.Xml; 74using System.Xml;
75using System.Xml.Xsl; 75using System.Xml.Xsl;
76using System.Net; 76using System.Net;
77using System.Diagnostics; 77using System.Diagnostics;
78 78
79using Prebuild.Core.Attributes; 79using Prebuild.Core.Attributes;
80using Prebuild.Core.Interfaces; 80using Prebuild.Core.Interfaces;
81using Prebuild.Core.Nodes; 81using Prebuild.Core.Nodes;
82using Prebuild.Core.Utilities; 82using Prebuild.Core.Utilities;
83 83
84namespace Prebuild.Core.Targets 84namespace Prebuild.Core.Targets
85{ 85{
86 public enum ClrVersion 86 public enum ClrVersion
87 { 87 {
88 Default, 88 Default,
89 Net_1_1, 89 Net_1_1,
90 Net_2_0 90 Net_2_0
91 } 91 }
92 92
93 public class SystemPackage 93 public class SystemPackage
94 { 94 {
95 string name; 95 string name;
96 string version; 96 string version;
97 string description; 97 string description;
98 string[] assemblies; 98 string[] assemblies;
99 bool isInternal; 99 bool isInternal;
100 ClrVersion targetVersion; 100 ClrVersion targetVersion;
101 101
102 public void Initialize(string name, 102 public void Initialize(string name,
103 string version, 103 string version,
104 string description, 104 string description,
105 string[] assemblies, 105 string[] assemblies,
106 ClrVersion targetVersion, 106 ClrVersion targetVersion,
107 bool isInternal) 107 bool isInternal)
108 { 108 {
109 this.isInternal = isInternal; 109 this.isInternal = isInternal;
110 this.name = name; 110 this.name = name;
111 this.version = version; 111 this.version = version;
112 this.assemblies = assemblies; 112 this.assemblies = assemblies;
113 this.description = description; 113 this.description = description;
114 this.targetVersion = targetVersion; 114 this.targetVersion = targetVersion;
115 } 115 }
116 116
117 public string Name 117 public string Name
118 { 118 {
119 get { return name; } 119 get { return name; }
120 } 120 }
121 121
122 public string Version 122 public string Version
123 { 123 {
124 get { return version; } 124 get { return version; }
125 } 125 }
126 126
127 public string Description 127 public string Description
128 { 128 {
129 get { return description; } 129 get { return description; }
130 } 130 }
131 131
132 public ClrVersion TargetVersion 132 public ClrVersion TargetVersion
133 { 133 {
134 get { return targetVersion; } 134 get { return targetVersion; }
135 } 135 }
136 136
137 // The package is part of the mono SDK 137 // The package is part of the mono SDK
138 public bool IsCorePackage 138 public bool IsCorePackage
139 { 139 {
140 get { return name == "mono"; } 140 get { return name == "mono"; }
141 } 141 }
142 142
143 // The package has been registered by an add-in, and is not installed 143 // The package has been registered by an add-in, and is not installed
144 // in the system. 144 // in the system.
145 public bool IsInternalPackage 145 public bool IsInternalPackage
146 { 146 {
147 get { return isInternal; } 147 get { return isInternal; }
148 } 148 }
149 149
150 public string[] Assemblies 150 public string[] Assemblies
151 { 151 {
152 get { return assemblies; } 152 get { return assemblies; }
153 } 153 }
154 154
155 } 155 }
156 156
157 157
158 /// <summary> 158 /// <summary>
159 /// 159 ///
160 /// </summary> 160 /// </summary>
161 [Target("autotools")] 161 [Target("autotools")]
162 public class AutotoolsTarget : ITarget 162 public class AutotoolsTarget : ITarget
163 { 163 {
164 #region Fields 164 #region Fields
165 165
166 Kernel m_Kernel; 166 Kernel m_Kernel;
167 XmlDocument autotoolsDoc; 167 XmlDocument autotoolsDoc;
168 XmlUrlResolver xr; 168 XmlUrlResolver xr;
169 System.Security.Policy.Evidence e; 169 System.Security.Policy.Evidence e;
170 readonly Dictionary<string, SystemPackage> assemblyPathToPackage = new Dictionary<string, SystemPackage>(); 170 readonly Dictionary<string, SystemPackage> assemblyPathToPackage = new Dictionary<string, SystemPackage>();
171 readonly Dictionary<string, string> assemblyFullNameToPath = new Dictionary<string, string>(); 171 readonly Dictionary<string, string> assemblyFullNameToPath = new Dictionary<string, string>();
172 readonly Dictionary<string, SystemPackage> packagesHash = new Dictionary<string, SystemPackage>(); 172 readonly Dictionary<string, SystemPackage> packagesHash = new Dictionary<string, SystemPackage>();
173 readonly List<SystemPackage> packages = new List<SystemPackage>(); 173 readonly List<SystemPackage> packages = new List<SystemPackage>();
174 174
175 #endregion 175 #endregion
176 176
177 #region Private Methods 177 #region Private Methods
178 178
179 private static void mkdirDashP(string dirName) 179 private static void mkdirDashP(string dirName)
180 { 180 {
181 DirectoryInfo di = new DirectoryInfo(dirName); 181 DirectoryInfo di = new DirectoryInfo(dirName);
182 if (di.Exists) 182 if (di.Exists)
183 return; 183 return;
184 184
185 string parentDirName = System.IO.Path.GetDirectoryName(dirName); 185 string parentDirName = System.IO.Path.GetDirectoryName(dirName);
186 DirectoryInfo parentDi = new DirectoryInfo(parentDirName); 186 DirectoryInfo parentDi = new DirectoryInfo(parentDirName);
187 if (!parentDi.Exists) 187 if (!parentDi.Exists)
188 mkdirDashP(parentDirName); 188 mkdirDashP(parentDirName);
189 189
190 di.Create(); 190 di.Create();
191 } 191 }
192 192
193 private static void chkMkDir(string dirName) 193 private static void chkMkDir(string dirName)
194 { 194 {
195 System.IO.DirectoryInfo di = 195 System.IO.DirectoryInfo di =
196 new System.IO.DirectoryInfo(dirName); 196 new System.IO.DirectoryInfo(dirName);
197 197
198 if (!di.Exists) 198 if (!di.Exists)
199 di.Create(); 199 di.Create();
200 } 200 }
201 201
202 private void transformToFile(string filename, XsltArgumentList argList, string nodeName) 202 private void transformToFile(string filename, XsltArgumentList argList, string nodeName)
203 { 203 {
204 // Create an XslTransform for this file 204 // Create an XslTransform for this file
205 XslTransform templateTransformer = 205 XslTransform templateTransformer =
206 new XslTransform(); 206 new XslTransform();
207 207
208 // Load up the template 208 // Load up the template
209 XmlNode templateNode = 209 XmlNode templateNode =
210 autotoolsDoc.SelectSingleNode(nodeName + "/*"); 210 autotoolsDoc.SelectSingleNode(nodeName + "/*");
211 templateTransformer.Load(templateNode.CreateNavigator(), xr, e); 211 templateTransformer.Load(templateNode.CreateNavigator(), xr, e);
212 212
213 // Create a writer for the transformed template 213 // Create a writer for the transformed template
214 XmlTextWriter templateWriter = 214 XmlTextWriter templateWriter =
215 new XmlTextWriter(filename, null); 215 new XmlTextWriter(filename, null);
216 216
217 // Perform transformation, writing the file 217 // Perform transformation, writing the file
218 templateTransformer.Transform 218 templateTransformer.Transform
219 (m_Kernel.CurrentDoc, argList, templateWriter, xr); 219 (m_Kernel.CurrentDoc, argList, templateWriter, xr);
220 } 220 }
221 221
222 static string NormalizeAsmName(string name) 222 static string NormalizeAsmName(string name)
223 { 223 {
224 int i = name.IndexOf(", PublicKeyToken=null"); 224 int i = name.IndexOf(", PublicKeyToken=null");
225 if (i != -1) 225 if (i != -1)
226 return name.Substring(0, i).Trim(); 226 return name.Substring(0, i).Trim();
227 return name; 227 return name;
228 } 228 }
229 229
230 private void AddAssembly(string assemblyfile, SystemPackage package) 230 private void AddAssembly(string assemblyfile, SystemPackage package)
231 { 231 {
232 if (!File.Exists(assemblyfile)) 232 if (!File.Exists(assemblyfile))
233 return; 233 return;
234 234
235 try 235 try
236 { 236 {
237 System.Reflection.AssemblyName an = System.Reflection.AssemblyName.GetAssemblyName(assemblyfile); 237 System.Reflection.AssemblyName an = System.Reflection.AssemblyName.GetAssemblyName(assemblyfile);
238 assemblyFullNameToPath[NormalizeAsmName(an.FullName)] = assemblyfile; 238 assemblyFullNameToPath[NormalizeAsmName(an.FullName)] = assemblyfile;
239 assemblyPathToPackage[assemblyfile] = package; 239 assemblyPathToPackage[assemblyfile] = package;
240 } 240 }
241 catch 241 catch
242 { 242 {
243 } 243 }
244 } 244 }
245 245
246 private static List<string> GetAssembliesWithLibInfo(string line, string file) 246 private static List<string> GetAssembliesWithLibInfo(string line, string file)
247 { 247 {
248 List<string> references = new List<string>(); 248 List<string> references = new List<string>();
249 List<string> libdirs = new List<string>(); 249 List<string> libdirs = new List<string>();
250 List<string> retval = new List<string>(); 250 List<string> retval = new List<string>();
251 foreach (string piece in line.Split(' ')) 251 foreach (string piece in line.Split(' '))
252 { 252 {
253 if (piece.ToLower().Trim().StartsWith("/r:") || piece.ToLower().Trim().StartsWith("-r:")) 253 if (piece.ToLower().Trim().StartsWith("/r:") || piece.ToLower().Trim().StartsWith("-r:"))
254 { 254 {
255 references.Add(ProcessPiece(piece.Substring(3).Trim(), file)); 255 references.Add(ProcessPiece(piece.Substring(3).Trim(), file));
256 } 256 }
257 else if (piece.ToLower().Trim().StartsWith("/lib:") || piece.ToLower().Trim().StartsWith("-lib:")) 257 else if (piece.ToLower().Trim().StartsWith("/lib:") || piece.ToLower().Trim().StartsWith("-lib:"))
258 { 258 {
259 libdirs.Add(ProcessPiece(piece.Substring(5).Trim(), file)); 259 libdirs.Add(ProcessPiece(piece.Substring(5).Trim(), file));
260 } 260 }
261 } 261 }
262 262
263 foreach (string refrnc in references) 263 foreach (string refrnc in references)
264 { 264 {
265 foreach (string libdir in libdirs) 265 foreach (string libdir in libdirs)
266 { 266 {
267 if (File.Exists(libdir + Path.DirectorySeparatorChar + refrnc)) 267 if (File.Exists(libdir + Path.DirectorySeparatorChar + refrnc))
268 { 268 {
269 retval.Add(libdir + Path.DirectorySeparatorChar + refrnc); 269 retval.Add(libdir + Path.DirectorySeparatorChar + refrnc);
270 } 270 }
271 } 271 }
272 } 272 }
273 273
274 return retval; 274 return retval;
275 } 275 }
276 276
277 private static List<string> GetAssembliesWithoutLibInfo(string line, string file) 277 private static List<string> GetAssembliesWithoutLibInfo(string line, string file)
278 { 278 {
279 List<string> references = new List<string>(); 279 List<string> references = new List<string>();
280 foreach (string reference in line.Split(' ')) 280 foreach (string reference in line.Split(' '))
281 { 281 {
282 if (reference.ToLower().Trim().StartsWith("/r:") || reference.ToLower().Trim().StartsWith("-r:")) 282 if (reference.ToLower().Trim().StartsWith("/r:") || reference.ToLower().Trim().StartsWith("-r:"))
283 { 283 {
284 string final_ref = reference.Substring(3).Trim(); 284 string final_ref = reference.Substring(3).Trim();
285 references.Add(ProcessPiece(final_ref, file)); 285 references.Add(ProcessPiece(final_ref, file));
286 } 286 }
287 } 287 }
288 return references; 288 return references;
289 } 289 }
290 290
291 private static string ProcessPiece(string piece, string pcfile) 291 private static string ProcessPiece(string piece, string pcfile)
292 { 292 {
293 int start = piece.IndexOf("${"); 293 int start = piece.IndexOf("${");
294 if (start == -1) 294 if (start == -1)
295 return piece; 295 return piece;
296 296
297 int end = piece.IndexOf("}"); 297 int end = piece.IndexOf("}");
298 if (end == -1) 298 if (end == -1)
299 return piece; 299 return piece;
300 300
301 string variable = piece.Substring(start + 2, end - start - 2); 301 string variable = piece.Substring(start + 2, end - start - 2);
302 string interp = GetVariableFromPkgConfig(variable, Path.GetFileNameWithoutExtension(pcfile)); 302 string interp = GetVariableFromPkgConfig(variable, Path.GetFileNameWithoutExtension(pcfile));
303 return ProcessPiece(piece.Replace("${" + variable + "}", interp), pcfile); 303 return ProcessPiece(piece.Replace("${" + variable + "}", interp), pcfile);
304 } 304 }
305 305
306 private static string GetVariableFromPkgConfig(string var, string pcfile) 306 private static string GetVariableFromPkgConfig(string var, string pcfile)
307 { 307 {
308 ProcessStartInfo psi = new ProcessStartInfo("pkg-config"); 308 ProcessStartInfo psi = new ProcessStartInfo("pkg-config");
309 psi.RedirectStandardOutput = true; 309 psi.RedirectStandardOutput = true;
310 psi.UseShellExecute = false; 310 psi.UseShellExecute = false;
311 psi.Arguments = String.Format("--variable={0} {1}", var, pcfile); 311 psi.Arguments = String.Format("--variable={0} {1}", var, pcfile);
312 Process p = new Process(); 312 Process p = new Process();
313 p.StartInfo = psi; 313 p.StartInfo = psi;
314 p.Start(); 314 p.Start();
315 string ret = p.StandardOutput.ReadToEnd().Trim(); 315 string ret = p.StandardOutput.ReadToEnd().Trim();
316 p.WaitForExit(); 316 p.WaitForExit();
317 if (String.IsNullOrEmpty(ret)) 317 if (String.IsNullOrEmpty(ret))
318 return String.Empty; 318 return String.Empty;
319 return ret; 319 return ret;
320 } 320 }
321 321
322 private void ParsePCFile(string pcfile) 322 private void ParsePCFile(string pcfile)
323 { 323 {
324 // Don't register the package twice 324 // Don't register the package twice
325 string pname = Path.GetFileNameWithoutExtension(pcfile); 325 string pname = Path.GetFileNameWithoutExtension(pcfile);
326 if (packagesHash.ContainsKey(pname)) 326 if (packagesHash.ContainsKey(pname))
327 return; 327 return;
328 328
329 List<string> fullassemblies = null; 329 List<string> fullassemblies = null;
330 string version = ""; 330 string version = "";
331 string desc = ""; 331 string desc = "";
332 332
333 SystemPackage package = new SystemPackage(); 333 SystemPackage package = new SystemPackage();
334 334
335 using (StreamReader reader = new StreamReader(pcfile)) 335 using (StreamReader reader = new StreamReader(pcfile))
336 { 336 {
337 string line; 337 string line;
338 while ((line = reader.ReadLine()) != null) 338 while ((line = reader.ReadLine()) != null)
339 { 339 {
340 string lowerLine = line.ToLower(); 340 string lowerLine = line.ToLower();
341 if (lowerLine.StartsWith("libs:") && lowerLine.IndexOf(".dll") != -1) 341 if (lowerLine.StartsWith("libs:") && lowerLine.IndexOf(".dll") != -1)
342 { 342 {
343 string choppedLine = line.Substring(5).Trim(); 343 string choppedLine = line.Substring(5).Trim();
344 if (choppedLine.IndexOf("-lib:") != -1 || choppedLine.IndexOf("/lib:") != -1) 344 if (choppedLine.IndexOf("-lib:") != -1 || choppedLine.IndexOf("/lib:") != -1)
345 { 345 {
346 fullassemblies = GetAssembliesWithLibInfo(choppedLine, pcfile); 346 fullassemblies = GetAssembliesWithLibInfo(choppedLine, pcfile);
347 } 347 }
348 else 348 else
349 { 349 {
350 fullassemblies = GetAssembliesWithoutLibInfo(choppedLine, pcfile); 350 fullassemblies = GetAssembliesWithoutLibInfo(choppedLine, pcfile);
351 } 351 }
352 } 352 }
353 else if (lowerLine.StartsWith("version:")) 353 else if (lowerLine.StartsWith("version:"))
354 { 354 {
355 // "version:".Length == 8 355 // "version:".Length == 8
356 version = line.Substring(8).Trim(); 356 version = line.Substring(8).Trim();
357 } 357 }
358 else if (lowerLine.StartsWith("description:")) 358 else if (lowerLine.StartsWith("description:"))
359 { 359 {
360 // "description:".Length == 12 360 // "description:".Length == 12
361 desc = line.Substring(12).Trim(); 361 desc = line.Substring(12).Trim();
362 } 362 }
363 } 363 }
364 } 364 }
365 365
366 if (fullassemblies == null) 366 if (fullassemblies == null)
367 return; 367 return;
368 368
369 foreach (string assembly in fullassemblies) 369 foreach (string assembly in fullassemblies)
370 { 370 {
371 AddAssembly(assembly, package); 371 AddAssembly(assembly, package);
372 } 372 }
373 373
374 package.Initialize(pname, 374 package.Initialize(pname,
375 version, 375 version,
376 desc, 376 desc,
377 fullassemblies.ToArray(), 377 fullassemblies.ToArray(),
378 ClrVersion.Default, 378 ClrVersion.Default,
379 false); 379 false);
380 packages.Add(package); 380 packages.Add(package);
381 packagesHash[pname] = package; 381 packagesHash[pname] = package;
382 } 382 }
383 383
384 void RegisterSystemAssemblies(string prefix, string version, ClrVersion ver) 384 void RegisterSystemAssemblies(string prefix, string version, ClrVersion ver)
385 { 385 {
386 SystemPackage package = new SystemPackage(); 386 SystemPackage package = new SystemPackage();
387 List<string> list = new List<string>(); 387 List<string> list = new List<string>();
388 388
389 string dir = Path.Combine(prefix, version); 389 string dir = Path.Combine(prefix, version);
390 if (!Directory.Exists(dir)) 390 if (!Directory.Exists(dir))
391 { 391 {
392 return; 392 return;
393 } 393 }
394 394
395 foreach (string assembly in Directory.GetFiles(dir, "*.dll")) 395 foreach (string assembly in Directory.GetFiles(dir, "*.dll"))
396 { 396 {
397 AddAssembly(assembly, package); 397 AddAssembly(assembly, package);
398 list.Add(assembly); 398 list.Add(assembly);
399 } 399 }
400 400
401 package.Initialize("mono", 401 package.Initialize("mono",
402 version, 402 version,
403 "The Mono runtime", 403 "The Mono runtime",
404 list.ToArray(), 404 list.ToArray(),
405 ver, 405 ver,
406 false); 406 false);
407 packages.Add(package); 407 packages.Add(package);
408 } 408 }
409 409
410 void RunInitialization() 410 void RunInitialization()
411 { 411 {
412 string versionDir; 412 string versionDir;
413 413
414 if (Environment.Version.Major == 1) 414 if (Environment.Version.Major == 1)
415 { 415 {
416 versionDir = "1.0"; 416 versionDir = "1.0";
417 } 417 }
418 else 418 else
419 { 419 {
420 versionDir = "2.0"; 420 versionDir = "2.0";
421 } 421 }
422 422
423 //Pull up assemblies from the installed mono system. 423 //Pull up assemblies from the installed mono system.
424 string prefix = Path.GetDirectoryName(typeof(int).Assembly.Location); 424 string prefix = Path.GetDirectoryName(typeof(int).Assembly.Location);
425 425
426 if (prefix.IndexOf(Path.Combine("mono", versionDir)) == -1) 426 if (prefix.IndexOf(Path.Combine("mono", versionDir)) == -1)
427 prefix = Path.Combine(prefix, "mono"); 427 prefix = Path.Combine(prefix, "mono");
428 else 428 else
429 prefix = Path.GetDirectoryName(prefix); 429 prefix = Path.GetDirectoryName(prefix);
430 430
431 RegisterSystemAssemblies(prefix, "1.0", ClrVersion.Net_1_1); 431 RegisterSystemAssemblies(prefix, "1.0", ClrVersion.Net_1_1);
432 RegisterSystemAssemblies(prefix, "2.0", ClrVersion.Net_2_0); 432 RegisterSystemAssemblies(prefix, "2.0", ClrVersion.Net_2_0);
433 433
434 string search_dirs = Environment.GetEnvironmentVariable("PKG_CONFIG_PATH"); 434 string search_dirs = Environment.GetEnvironmentVariable("PKG_CONFIG_PATH");
435 string libpath = Environment.GetEnvironmentVariable("PKG_CONFIG_LIBPATH"); 435 string libpath = Environment.GetEnvironmentVariable("PKG_CONFIG_LIBPATH");
436 436
437 if (String.IsNullOrEmpty(libpath)) 437 if (String.IsNullOrEmpty(libpath))
438 { 438 {
439 string path_dirs = Environment.GetEnvironmentVariable("PATH"); 439 string path_dirs = Environment.GetEnvironmentVariable("PATH");
440 foreach (string pathdir in path_dirs.Split(Path.PathSeparator)) 440 foreach (string pathdir in path_dirs.Split(Path.PathSeparator))
441 { 441 {
442 if (pathdir == null) 442 if (pathdir == null)
443 continue; 443 continue;
444 if (File.Exists(pathdir + Path.DirectorySeparatorChar + "pkg-config")) 444 if (File.Exists(pathdir + Path.DirectorySeparatorChar + "pkg-config"))
445 { 445 {
446 libpath = Path.Combine(pathdir, ".."); 446 libpath = Path.Combine(pathdir, "..");
447 libpath = Path.Combine(libpath, "lib"); 447 libpath = Path.Combine(libpath, "lib");
448 libpath = Path.Combine(libpath, "pkgconfig"); 448 libpath = Path.Combine(libpath, "pkgconfig");
449 break; 449 break;
450 } 450 }
451 } 451 }
452 } 452 }
453 search_dirs += Path.PathSeparator + libpath; 453 search_dirs += Path.PathSeparator + libpath;
454 if (!string.IsNullOrEmpty(search_dirs)) 454 if (!string.IsNullOrEmpty(search_dirs))
455 { 455 {
456 List<string> scanDirs = new List<string>(); 456 List<string> scanDirs = new List<string>();
457 foreach (string potentialDir in search_dirs.Split(Path.PathSeparator)) 457 foreach (string potentialDir in search_dirs.Split(Path.PathSeparator))
458 { 458 {
459 if (!scanDirs.Contains(potentialDir)) 459 if (!scanDirs.Contains(potentialDir))
460 scanDirs.Add(potentialDir); 460 scanDirs.Add(potentialDir);
461 } 461 }
462 foreach (string pcdir in scanDirs) 462 foreach (string pcdir in scanDirs)
463 { 463 {
464 if (pcdir == null) 464 if (pcdir == null)
465 continue; 465 continue;
466 466
467 if (Directory.Exists(pcdir)) 467 if (Directory.Exists(pcdir))
468 { 468 {
469 foreach (string pcfile in Directory.GetFiles(pcdir, "*.pc")) 469 foreach (string pcfile in Directory.GetFiles(pcdir, "*.pc"))
470 { 470 {
471 ParsePCFile(pcfile); 471 ParsePCFile(pcfile);
472 } 472 }
473 } 473 }
474 } 474 }
475 } 475 }
476 } 476 }
477 477
478 private void WriteCombine(SolutionNode solution) 478 private void WriteCombine(SolutionNode solution)
479 { 479 {
480 #region "Create Solution directory if it doesn't exist" 480 #region "Create Solution directory if it doesn't exist"
481 string solutionDir = Path.Combine(solution.FullPath, 481 string solutionDir = Path.Combine(solution.FullPath,
482 Path.Combine("autotools", 482 Path.Combine("autotools",
483 solution.Name)); 483 solution.Name));
484 chkMkDir(solutionDir); 484 chkMkDir(solutionDir);
485 #endregion 485 #endregion
486 486
487 #region "Write Solution-level files" 487 #region "Write Solution-level files"
488 XsltArgumentList argList = new XsltArgumentList(); 488 XsltArgumentList argList = new XsltArgumentList();
489 argList.AddParam("solutionName", "", solution.Name); 489 argList.AddParam("solutionName", "", solution.Name);
490 // $solutionDir is $rootDir/$solutionName/ 490 // $solutionDir is $rootDir/$solutionName/
491 transformToFile(Path.Combine(solutionDir, "configure.ac"), 491 transformToFile(Path.Combine(solutionDir, "configure.ac"),
492 argList, "/Autotools/SolutionConfigureAc"); 492 argList, "/Autotools/SolutionConfigureAc");
493 transformToFile(Path.Combine(solutionDir, "Makefile.am"), 493 transformToFile(Path.Combine(solutionDir, "Makefile.am"),
494 argList, "/Autotools/SolutionMakefileAm"); 494 argList, "/Autotools/SolutionMakefileAm");
495 transformToFile(Path.Combine(solutionDir, "autogen.sh"), 495 transformToFile(Path.Combine(solutionDir, "autogen.sh"),
496 argList, "/Autotools/SolutionAutogenSh"); 496 argList, "/Autotools/SolutionAutogenSh");
497 #endregion 497 #endregion
498 498
499 foreach (ProjectNode project in solution.ProjectsTableOrder) 499 foreach (ProjectNode project in solution.ProjectsTableOrder)
500 { 500 {
501 m_Kernel.Log.Write(String.Format("Writing project: {0}", 501 m_Kernel.Log.Write(String.Format("Writing project: {0}",
502 project.Name)); 502 project.Name));
503 WriteProject(solution, project); 503 WriteProject(solution, project);
504 } 504 }
505 } 505 }
506 506
507 private static string FindFileReference(string refName, 507 private static string FindFileReference(string refName,
508 ProjectNode project) 508 ProjectNode project)
509 { 509 {
510 foreach (ReferencePathNode refPath in project.ReferencePaths) 510 foreach (ReferencePathNode refPath in project.ReferencePaths)
511 { 511 {
512 string fullPath = 512 string fullPath =
513 Helper.MakeFilePath(refPath.Path, refName, "dll"); 513 Helper.MakeFilePath(refPath.Path, refName, "dll");
514 514
515 if (File.Exists(fullPath)) { 515 if (File.Exists(fullPath)) {
516 return fullPath; 516 return fullPath;
517 } 517 }
518 } 518 }
519 519
520 return null; 520 return null;
521 } 521 }
522 522
523 /// <summary> 523 /// <summary>
524 /// Gets the XML doc file. 524 /// Gets the XML doc file.
525 /// </summary> 525 /// </summary>
526 /// <param name="project">The project.</param> 526 /// <param name="project">The project.</param>
527 /// <param name="conf">The conf.</param> 527 /// <param name="conf">The conf.</param>
528 /// <returns></returns> 528 /// <returns></returns>
529 public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf) 529 public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf)
530 { 530 {
531 if (conf == null) 531 if (conf == null)
532 { 532 {
533 throw new ArgumentNullException("conf"); 533 throw new ArgumentNullException("conf");
534 } 534 }
535 if (project == null) 535 if (project == null)
536 { 536 {
537 throw new ArgumentNullException("project"); 537 throw new ArgumentNullException("project");
538 } 538 }
539 string docFile = (string)conf.Options["XmlDocFile"]; 539 string docFile = (string)conf.Options["XmlDocFile"];
540 // if(docFile != null && docFile.Length == 0)//default to assembly name if not specified 540 // if(docFile != null && docFile.Length == 0)//default to assembly name if not specified
541 // { 541 // {
542 // return Path.GetFileNameWithoutExtension(project.AssemblyName) + ".xml"; 542 // return Path.GetFileNameWithoutExtension(project.AssemblyName) + ".xml";
543 // } 543 // }
544 return docFile; 544 return docFile;
545 } 545 }
546 546
547 /// <summary> 547 /// <summary>
548 /// Normalizes the path. 548 /// Normalizes the path.
549 /// </summary> 549 /// </summary>
550 /// <param name="path">The path.</param> 550 /// <param name="path">The path.</param>
551 /// <returns></returns> 551 /// <returns></returns>
552 public static string NormalizePath(string path) 552 public static string NormalizePath(string path)
553 { 553 {
554 if (path == null) 554 if (path == null)
555 { 555 {
556 return ""; 556 return "";
557 } 557 }
558 558
559 StringBuilder tmpPath; 559 StringBuilder tmpPath;
560 560
561 if (Core.Parse.Preprocessor.GetOS() == "Win32") 561 if (Core.Parse.Preprocessor.GetOS() == "Win32")
562 { 562 {
563 tmpPath = new StringBuilder(path.Replace('\\', '/')); 563 tmpPath = new StringBuilder(path.Replace('\\', '/'));
564 tmpPath.Replace("/", @"\\"); 564 tmpPath.Replace("/", @"\\");
565 } 565 }
566 else 566 else
567 { 567 {
568 tmpPath = new StringBuilder(path.Replace('\\', '/')); 568 tmpPath = new StringBuilder(path.Replace('\\', '/'));
569 tmpPath = tmpPath.Replace('/', Path.DirectorySeparatorChar); 569 tmpPath = tmpPath.Replace('/', Path.DirectorySeparatorChar);
570 } 570 }
571 return tmpPath.ToString(); 571 return tmpPath.ToString();
572 } 572 }
573 573
574 private void WriteProject(SolutionNode solution, ProjectNode project) 574 private void WriteProject(SolutionNode solution, ProjectNode project)
575 { 575 {
576 string solutionDir = Path.Combine(solution.FullPath, Path.Combine("autotools", solution.Name)); 576 string solutionDir = Path.Combine(solution.FullPath, Path.Combine("autotools", solution.Name));
577 string projectDir = Path.Combine(solutionDir, project.Name); 577 string projectDir = Path.Combine(solutionDir, project.Name);
578 string projectVersion = project.Version; 578 string projectVersion = project.Version;
579 bool hasAssemblyConfig = false; 579 bool hasAssemblyConfig = false;
580 chkMkDir(projectDir); 580 chkMkDir(projectDir);
581 581
582 List<string> 582 List<string>
583 compiledFiles = new List<string>(), 583 compiledFiles = new List<string>(),
584 contentFiles = new List<string>(), 584 contentFiles = new List<string>(),
585 embeddedFiles = new List<string>(), 585 embeddedFiles = new List<string>(),
586 586
587 binaryLibs = new List<string>(), 587 binaryLibs = new List<string>(),
588 pkgLibs = new List<string>(), 588 pkgLibs = new List<string>(),
589 systemLibs = new List<string>(), 589 systemLibs = new List<string>(),
590 runtimeLibs = new List<string>(), 590 runtimeLibs = new List<string>(),
591 591
592 extraDistFiles = new List<string>(), 592 extraDistFiles = new List<string>(),
593 localCopyTargets = new List<string>(); 593 localCopyTargets = new List<string>();
594 594
595 // If there exists a .config file for this assembly, copy 595 // If there exists a .config file for this assembly, copy
596 // it to the project folder 596 // it to the project folder
597 597
598 // TODO: Support copying .config.osx files 598 // TODO: Support copying .config.osx files
599 // TODO: support processing the .config file for native library deps 599 // TODO: support processing the .config file for native library deps
600 string projectAssemblyName = project.Name; 600 string projectAssemblyName = project.Name;
601 if (project.AssemblyName != null) 601 if (project.AssemblyName != null)
602 projectAssemblyName = project.AssemblyName; 602 projectAssemblyName = project.AssemblyName;
603 603
604 if (File.Exists(Path.Combine(project.FullPath, projectAssemblyName) + ".dll.config")) 604 if (File.Exists(Path.Combine(project.FullPath, projectAssemblyName) + ".dll.config"))
605 { 605 {
606 hasAssemblyConfig = true; 606 hasAssemblyConfig = true;
607 System.IO.File.Copy(Path.Combine(project.FullPath, projectAssemblyName + ".dll.config"), Path.Combine(projectDir, projectAssemblyName + ".dll.config"), true); 607 System.IO.File.Copy(Path.Combine(project.FullPath, projectAssemblyName + ".dll.config"), Path.Combine(projectDir, projectAssemblyName + ".dll.config"), true);
608 extraDistFiles.Add(project.AssemblyName + ".dll.config"); 608 extraDistFiles.Add(project.AssemblyName + ".dll.config");
609 } 609 }
610 610
611 foreach (ConfigurationNode conf in project.Configurations) 611 foreach (ConfigurationNode conf in project.Configurations)
612 { 612 {
613 if (conf.Options.KeyFile != string.Empty) 613 if (conf.Options.KeyFile != string.Empty)
614 { 614 {
615 // Copy snk file into the project's directory 615 // Copy snk file into the project's directory
616 // Use the snk from the project directory directly 616 // Use the snk from the project directory directly
617 string source = Path.Combine(project.FullPath, conf.Options.KeyFile); 617 string source = Path.Combine(project.FullPath, conf.Options.KeyFile);
618 string keyFile = conf.Options.KeyFile; 618 string keyFile = conf.Options.KeyFile;
619 Regex re = new Regex(".*/"); 619 Regex re = new Regex(".*/");
620 keyFile = re.Replace(keyFile, ""); 620 keyFile = re.Replace(keyFile, "");
621 621
622 string dest = Path.Combine(projectDir, keyFile); 622 string dest = Path.Combine(projectDir, keyFile);
623 // Tell the user if there's a problem copying the file 623 // Tell the user if there's a problem copying the file
624 try 624 try
625 { 625 {
626 mkdirDashP(System.IO.Path.GetDirectoryName(dest)); 626 mkdirDashP(System.IO.Path.GetDirectoryName(dest));
627 System.IO.File.Copy(source, dest, true); 627 System.IO.File.Copy(source, dest, true);
628 } 628 }
629 catch (System.IO.IOException e) 629 catch (System.IO.IOException e)
630 { 630 {
631 Console.WriteLine(e.Message); 631 Console.WriteLine(e.Message);
632 } 632 }
633 } 633 }
634 } 634 }
635 635
636 // Copy compiled, embedded and content files into the project's directory 636 // Copy compiled, embedded and content files into the project's directory
637 foreach (string filename in project.Files) 637 foreach (string filename in project.Files)
638 { 638 {
639 string source = Path.Combine(project.FullPath, filename); 639 string source = Path.Combine(project.FullPath, filename);
640 string dest = Path.Combine(projectDir, filename); 640 string dest = Path.Combine(projectDir, filename);
641 641
642 if (filename.Contains("AssemblyInfo.cs")) 642 if (filename.Contains("AssemblyInfo.cs"))
643 { 643 {
644 // If we've got an AssemblyInfo.cs, pull the version number from it 644 // If we've got an AssemblyInfo.cs, pull the version number from it
645 string[] sources = { source }; 645 string[] sources = { source };
646 string[] args = { "" }; 646 string[] args = { "" };
647 Microsoft.CSharp.CSharpCodeProvider cscp = 647 Microsoft.CSharp.CSharpCodeProvider cscp =
648 new Microsoft.CSharp.CSharpCodeProvider(); 648 new Microsoft.CSharp.CSharpCodeProvider();
649 649
650 string tempAssemblyFile = Path.Combine(Path.GetTempPath(), project.Name + "-temp.dll"); 650 string tempAssemblyFile = Path.Combine(Path.GetTempPath(), project.Name + "-temp.dll");
651 System.CodeDom.Compiler.CompilerParameters cparam = 651 System.CodeDom.Compiler.CompilerParameters cparam =
652 new System.CodeDom.Compiler.CompilerParameters(args, tempAssemblyFile); 652 new System.CodeDom.Compiler.CompilerParameters(args, tempAssemblyFile);
653 653
654 System.CodeDom.Compiler.CompilerResults cr = 654 System.CodeDom.Compiler.CompilerResults cr =
655 cscp.CompileAssemblyFromFile(cparam, sources); 655 cscp.CompileAssemblyFromFile(cparam, sources);
656 656
657 foreach (System.CodeDom.Compiler.CompilerError error in cr.Errors) 657 foreach (System.CodeDom.Compiler.CompilerError error in cr.Errors)
658 Console.WriteLine("Error! '{0}'", error.ErrorText); 658 Console.WriteLine("Error! '{0}'", error.ErrorText);
659 659
660 try { 660 try {
661 string projectFullName = cr.CompiledAssembly.FullName; 661 string projectFullName = cr.CompiledAssembly.FullName;
662 Regex verRegex = new Regex("Version=([\\d\\.]+)"); 662 Regex verRegex = new Regex("Version=([\\d\\.]+)");
663 Match verMatch = verRegex.Match(projectFullName); 663 Match verMatch = verRegex.Match(projectFullName);
664 if (verMatch.Success) 664 if (verMatch.Success)
665 projectVersion = verMatch.Groups[1].Value; 665 projectVersion = verMatch.Groups[1].Value;
666 }catch{ 666 }catch{
667 Console.WriteLine("Couldn't compile AssemblyInfo.cs"); 667 Console.WriteLine("Couldn't compile AssemblyInfo.cs");
668 } 668 }
669 669
670 // Clean up the temp file 670 // Clean up the temp file
671 try 671 try
672 { 672 {
673 if (File.Exists(tempAssemblyFile)) 673 if (File.Exists(tempAssemblyFile))
674 File.Delete(tempAssemblyFile); 674 File.Delete(tempAssemblyFile);
675 } 675 }
676 catch 676 catch
677 { 677 {
678 Console.WriteLine("Error! '{0}'", e); 678 Console.WriteLine("Error! '{0}'", e);
679 } 679 }
680 680
681 } 681 }
682 682
683 // Tell the user if there's a problem copying the file 683 // Tell the user if there's a problem copying the file
684 try 684 try
685 { 685 {
686 mkdirDashP(System.IO.Path.GetDirectoryName(dest)); 686 mkdirDashP(System.IO.Path.GetDirectoryName(dest));
687 System.IO.File.Copy(source, dest, true); 687 System.IO.File.Copy(source, dest, true);
688 } 688 }
689 catch (System.IO.IOException e) 689 catch (System.IO.IOException e)
690 { 690 {
691 Console.WriteLine(e.Message); 691 Console.WriteLine(e.Message);
692 } 692 }
693 693
694 switch (project.Files.GetBuildAction(filename)) 694 switch (project.Files.GetBuildAction(filename))
695 { 695 {
696 case BuildAction.Compile: 696 case BuildAction.Compile:
697 compiledFiles.Add(filename); 697 compiledFiles.Add(filename);
698 break; 698 break;
699 case BuildAction.Content: 699 case BuildAction.Content:
700 contentFiles.Add(filename); 700 contentFiles.Add(filename);
701 extraDistFiles.Add(filename); 701 extraDistFiles.Add(filename);
702 break; 702 break;
703 case BuildAction.EmbeddedResource: 703 case BuildAction.EmbeddedResource:
704 embeddedFiles.Add(filename); 704 embeddedFiles.Add(filename);
705 break; 705 break;
706 } 706 }
707 } 707 }
708 708
709 // Set up references 709 // Set up references
710 for (int refNum = 0; refNum < project.References.Count; refNum++) 710 for (int refNum = 0; refNum < project.References.Count; refNum++)
711 { 711 {
712 ReferenceNode refr = project.References[refNum]; 712 ReferenceNode refr = project.References[refNum];
713 Assembly refAssembly = Assembly.LoadWithPartialName(refr.Name); 713 Assembly refAssembly = Assembly.LoadWithPartialName(refr.Name);
714 714
715 /* Determine which pkg-config (.pc) file refers to 715 /* Determine which pkg-config (.pc) file refers to
716 this assembly */ 716 this assembly */
717 717
718 SystemPackage package = null; 718 SystemPackage package = null;
719 719
720 if (packagesHash.ContainsKey(refr.Name)) 720 if (packagesHash.ContainsKey(refr.Name))
721 { 721 {
722 package = packagesHash[refr.Name]; 722 package = packagesHash[refr.Name];
723 723
724 } 724 }
725 else 725 else
726 { 726 {
727 string assemblyFullName = string.Empty; 727 string assemblyFullName = string.Empty;
728 if (refAssembly != null) 728 if (refAssembly != null)
729 assemblyFullName = refAssembly.FullName; 729 assemblyFullName = refAssembly.FullName;
730 730
731 string assemblyFileName = string.Empty; 731 string assemblyFileName = string.Empty;
732 if (assemblyFullName != string.Empty && 732 if (assemblyFullName != string.Empty &&
733 assemblyFullNameToPath.ContainsKey(assemblyFullName) 733 assemblyFullNameToPath.ContainsKey(assemblyFullName)
734 ) 734 )
735 assemblyFileName = 735 assemblyFileName =
736 assemblyFullNameToPath[assemblyFullName]; 736 assemblyFullNameToPath[assemblyFullName];
737 737
738 if (assemblyFileName != string.Empty && 738 if (assemblyFileName != string.Empty &&
739 assemblyPathToPackage.ContainsKey(assemblyFileName) 739 assemblyPathToPackage.ContainsKey(assemblyFileName)
740 ) 740 )
741 package = assemblyPathToPackage[assemblyFileName]; 741 package = assemblyPathToPackage[assemblyFileName];
742 742
743 } 743 }
744 744
745 /* If we know the .pc file and it is not "mono" 745 /* If we know the .pc file and it is not "mono"
746 (already in the path), add a -pkg: argument */ 746 (already in the path), add a -pkg: argument */
747 747
748 if (package != null && 748 if (package != null &&
749 package.Name != "mono" && 749 package.Name != "mono" &&
750 !pkgLibs.Contains(package.Name) 750 !pkgLibs.Contains(package.Name)
751 ) 751 )
752 pkgLibs.Add(package.Name); 752 pkgLibs.Add(package.Name);
753 753
754 string fileRef = 754 string fileRef =
755 FindFileReference(refr.Name, (ProjectNode)refr.Parent); 755 FindFileReference(refr.Name, (ProjectNode)refr.Parent);
756 756
757 if (refr.LocalCopy || 757 if (refr.LocalCopy ||
758 solution.ProjectsTable.ContainsKey(refr.Name) || 758 solution.ProjectsTable.ContainsKey(refr.Name) ||
759 fileRef != null || 759 fileRef != null ||
760 refr.Path != null 760 refr.Path != null
761 ) 761 )
762 { 762 {
763 763
764 /* Attempt to copy the referenced lib to the 764 /* Attempt to copy the referenced lib to the
765 project's directory */ 765 project's directory */
766 766
767 string filename = refr.Name + ".dll"; 767 string filename = refr.Name + ".dll";
768 string source = filename; 768 string source = filename;
769 if (refr.Path != null) 769 if (refr.Path != null)
770 source = Path.Combine(refr.Path, source); 770 source = Path.Combine(refr.Path, source);
771 source = Path.Combine(project.FullPath, source); 771 source = Path.Combine(project.FullPath, source);
772 string dest = Path.Combine(projectDir, filename); 772 string dest = Path.Combine(projectDir, filename);
773 773
774 /* Since we depend on this binary dll to build, we 774 /* Since we depend on this binary dll to build, we
775 * will add a compile- time dependency on the 775 * will add a compile- time dependency on the
776 * copied dll, and add the dll to the list of 776 * copied dll, and add the dll to the list of
777 * files distributed with this package 777 * files distributed with this package
778 */ 778 */
779 779
780 binaryLibs.Add(refr.Name + ".dll"); 780 binaryLibs.Add(refr.Name + ".dll");
781 extraDistFiles.Add(refr.Name + ".dll"); 781 extraDistFiles.Add(refr.Name + ".dll");
782 782
783 // TODO: Support copying .config.osx files 783 // TODO: Support copying .config.osx files
784 // TODO: Support for determining native dependencies 784 // TODO: Support for determining native dependencies
785 if (File.Exists(source + ".config")) 785 if (File.Exists(source + ".config"))
786 { 786 {
787 System.IO.File.Copy(source + ".config", Path.GetDirectoryName(dest), true); 787 System.IO.File.Copy(source + ".config", Path.GetDirectoryName(dest), true);
788 extraDistFiles.Add(refr.Name + ".dll.config"); 788 extraDistFiles.Add(refr.Name + ".dll.config");
789 } 789 }
790 790
791 try 791 try
792 { 792 {
793 System.IO.File.Copy(source, dest, true); 793 System.IO.File.Copy(source, dest, true);
794 } 794 }
795 catch (System.IO.IOException) 795 catch (System.IO.IOException)
796 { 796 {
797 if (solution.ProjectsTable.ContainsKey(refr.Name)){ 797 if (solution.ProjectsTable.ContainsKey(refr.Name)){
798 798
799 /* If an assembly is referenced, marked for 799 /* If an assembly is referenced, marked for
800 * local copy, in the list of projects for 800 * local copy, in the list of projects for
801 * this solution, but does not exist, put a 801 * this solution, but does not exist, put a
802 * target into the Makefile.am to build the 802 * target into the Makefile.am to build the
803 * assembly and copy it to this project's 803 * assembly and copy it to this project's
804 * directory 804 * directory
805 */ 805 */
806 806
807 ProjectNode sourcePrj = 807 ProjectNode sourcePrj =
808 ((solution.ProjectsTable[refr.Name])); 808 ((solution.ProjectsTable[refr.Name]));
809 809
810 string target = 810 string target =
811 String.Format("{0}:\n" + 811 String.Format("{0}:\n" +
812 "\t$(MAKE) -C ../{1}\n" + 812 "\t$(MAKE) -C ../{1}\n" +
813 "\tln ../{2}/$@ $@\n", 813 "\tln ../{2}/$@ $@\n",
814 filename, 814 filename,
815 sourcePrj.Name, 815 sourcePrj.Name,
816 sourcePrj.Name ); 816 sourcePrj.Name );
817 817
818 localCopyTargets.Add(target); 818 localCopyTargets.Add(target);
819 } 819 }
820 } 820 }
821 } 821 }
822 else if( !pkgLibs.Contains(refr.Name) ) 822 else if( !pkgLibs.Contains(refr.Name) )
823 { 823 {
824 // Else, let's assume it's in the GAC or the lib path 824 // Else, let's assume it's in the GAC or the lib path
825 string assemName = string.Empty; 825 string assemName = string.Empty;
826 int index = refr.Name.IndexOf(","); 826 int index = refr.Name.IndexOf(",");
827 827
828 if (index > 0) 828 if (index > 0)
829 assemName = refr.Name.Substring(0, index); 829 assemName = refr.Name.Substring(0, index);
830 else 830 else
831 assemName = refr.Name; 831 assemName = refr.Name;
832 832
833 m_Kernel.Log.Write(String.Format( 833 m_Kernel.Log.Write(String.Format(
834 "Warning: Couldn't find an appropriate assembly " + 834 "Warning: Couldn't find an appropriate assembly " +
835 "for reference:\n'{0}'", refr.Name 835 "for reference:\n'{0}'", refr.Name
836 )); 836 ));
837 systemLibs.Add(assemName); 837 systemLibs.Add(assemName);
838 } 838 }
839 } 839 }
840 840
841 const string lineSep = " \\\n\t"; 841 const string lineSep = " \\\n\t";
842 string compiledFilesString = string.Empty; 842 string compiledFilesString = string.Empty;
843 if (compiledFiles.Count > 0) 843 if (compiledFiles.Count > 0)
844 compiledFilesString = 844 compiledFilesString =
845 lineSep + string.Join(lineSep, compiledFiles.ToArray()); 845 lineSep + string.Join(lineSep, compiledFiles.ToArray());
846 846
847 string embeddedFilesString = ""; 847 string embeddedFilesString = "";
848 if (embeddedFiles.Count > 0) 848 if (embeddedFiles.Count > 0)
849 embeddedFilesString = 849 embeddedFilesString =
850 lineSep + string.Join(lineSep, embeddedFiles.ToArray()); 850 lineSep + string.Join(lineSep, embeddedFiles.ToArray());
851 851
852 string contentFilesString = ""; 852 string contentFilesString = "";
853 if (contentFiles.Count > 0) 853 if (contentFiles.Count > 0)
854 contentFilesString = 854 contentFilesString =
855 lineSep + string.Join(lineSep, contentFiles.ToArray()); 855 lineSep + string.Join(lineSep, contentFiles.ToArray());
856 856
857 string extraDistFilesString = ""; 857 string extraDistFilesString = "";
858 if (extraDistFiles.Count > 0) 858 if (extraDistFiles.Count > 0)
859 extraDistFilesString = 859 extraDistFilesString =
860 lineSep + string.Join(lineSep, extraDistFiles.ToArray()); 860 lineSep + string.Join(lineSep, extraDistFiles.ToArray());
861 861
862 string pkgLibsString = ""; 862 string pkgLibsString = "";
863 if (pkgLibs.Count > 0) 863 if (pkgLibs.Count > 0)
864 pkgLibsString = 864 pkgLibsString =
865 lineSep + string.Join(lineSep, pkgLibs.ToArray()); 865 lineSep + string.Join(lineSep, pkgLibs.ToArray());
866 866
867 string binaryLibsString = ""; 867 string binaryLibsString = "";
868 if (binaryLibs.Count > 0) 868 if (binaryLibs.Count > 0)
869 binaryLibsString = 869 binaryLibsString =
870 lineSep + string.Join(lineSep, binaryLibs.ToArray()); 870 lineSep + string.Join(lineSep, binaryLibs.ToArray());
871 871
872 string systemLibsString = ""; 872 string systemLibsString = "";
873 if (systemLibs.Count > 0) 873 if (systemLibs.Count > 0)
874 systemLibsString = 874 systemLibsString =
875 lineSep + string.Join(lineSep, systemLibs.ToArray()); 875 lineSep + string.Join(lineSep, systemLibs.ToArray());
876 876
877 string localCopyTargetsString = ""; 877 string localCopyTargetsString = "";
878 if (localCopyTargets.Count > 0) 878 if (localCopyTargets.Count > 0)
879 localCopyTargetsString = 879 localCopyTargetsString =
880 string.Join("\n", localCopyTargets.ToArray()); 880 string.Join("\n", localCopyTargets.ToArray());
881 881
882 string monoPath = ""; 882 string monoPath = "";
883 foreach (string runtimeLib in runtimeLibs) 883 foreach (string runtimeLib in runtimeLibs)
884 { 884 {
885 monoPath += ":`pkg-config --variable=libdir " + runtimeLib + "`"; 885 monoPath += ":`pkg-config --variable=libdir " + runtimeLib + "`";
886 } 886 }
887 887
888 // Add the project name to the list of transformation 888 // Add the project name to the list of transformation
889 // parameters 889 // parameters
890 XsltArgumentList argList = new XsltArgumentList(); 890 XsltArgumentList argList = new XsltArgumentList();
891 argList.AddParam("projectName", "", project.Name); 891 argList.AddParam("projectName", "", project.Name);
892 argList.AddParam("solutionName", "", solution.Name); 892 argList.AddParam("solutionName", "", solution.Name);
893 argList.AddParam("assemblyName", "", projectAssemblyName); 893 argList.AddParam("assemblyName", "", projectAssemblyName);
894 argList.AddParam("compiledFiles", "", compiledFilesString); 894 argList.AddParam("compiledFiles", "", compiledFilesString);
895 argList.AddParam("embeddedFiles", "", embeddedFilesString); 895 argList.AddParam("embeddedFiles", "", embeddedFilesString);
896 argList.AddParam("contentFiles", "", contentFilesString); 896 argList.AddParam("contentFiles", "", contentFilesString);
897 argList.AddParam("extraDistFiles", "", extraDistFilesString); 897 argList.AddParam("extraDistFiles", "", extraDistFilesString);
898 argList.AddParam("pkgLibs", "", pkgLibsString); 898 argList.AddParam("pkgLibs", "", pkgLibsString);
899 argList.AddParam("binaryLibs", "", binaryLibsString); 899 argList.AddParam("binaryLibs", "", binaryLibsString);
900 argList.AddParam("systemLibs", "", systemLibsString); 900 argList.AddParam("systemLibs", "", systemLibsString);
901 argList.AddParam("monoPath", "", monoPath); 901 argList.AddParam("monoPath", "", monoPath);
902 argList.AddParam("localCopyTargets", "", localCopyTargetsString); 902 argList.AddParam("localCopyTargets", "", localCopyTargetsString);
903 argList.AddParam("projectVersion", "", projectVersion); 903 argList.AddParam("projectVersion", "", projectVersion);
904 argList.AddParam("hasAssemblyConfig", "", hasAssemblyConfig ? "true" : ""); 904 argList.AddParam("hasAssemblyConfig", "", hasAssemblyConfig ? "true" : "");
905 905
906 // Transform the templates 906 // Transform the templates
907 transformToFile(Path.Combine(projectDir, "configure.ac"), argList, "/Autotools/ProjectConfigureAc"); 907 transformToFile(Path.Combine(projectDir, "configure.ac"), argList, "/Autotools/ProjectConfigureAc");
908 transformToFile(Path.Combine(projectDir, "Makefile.am"), argList, "/Autotools/ProjectMakefileAm"); 908 transformToFile(Path.Combine(projectDir, "Makefile.am"), argList, "/Autotools/ProjectMakefileAm");
909 transformToFile(Path.Combine(projectDir, "autogen.sh"), argList, "/Autotools/ProjectAutogenSh"); 909 transformToFile(Path.Combine(projectDir, "autogen.sh"), argList, "/Autotools/ProjectAutogenSh");
910 910
911 if (project.Type == Core.Nodes.ProjectType.Library) 911 if (project.Type == Core.Nodes.ProjectType.Library)
912 transformToFile(Path.Combine(projectDir, project.Name + ".pc.in"), argList, "/Autotools/ProjectPcIn"); 912 transformToFile(Path.Combine(projectDir, project.Name + ".pc.in"), argList, "/Autotools/ProjectPcIn");
913 if (project.Type == Core.Nodes.ProjectType.Exe || project.Type == Core.Nodes.ProjectType.WinExe) 913 if (project.Type == Core.Nodes.ProjectType.Exe || project.Type == Core.Nodes.ProjectType.WinExe)
914 transformToFile(Path.Combine(projectDir, project.Name.ToLower() + ".in"), argList, "/Autotools/ProjectWrapperScriptIn"); 914 transformToFile(Path.Combine(projectDir, project.Name.ToLower() + ".in"), argList, "/Autotools/ProjectWrapperScriptIn");
915 } 915 }
916 916
917 private void CleanProject(ProjectNode project) 917 private void CleanProject(ProjectNode project)
918 { 918 {
919 m_Kernel.Log.Write("...Cleaning project: {0}", project.Name); 919 m_Kernel.Log.Write("...Cleaning project: {0}", project.Name);
920 string projectFile = Helper.MakeFilePath(project.FullPath, "Include", "am"); 920 string projectFile = Helper.MakeFilePath(project.FullPath, "Include", "am");
921 Helper.DeleteIfExists(projectFile); 921 Helper.DeleteIfExists(projectFile);
922 } 922 }
923 923
924 private void CleanSolution(SolutionNode solution) 924 private void CleanSolution(SolutionNode solution)
925 { 925 {
926 m_Kernel.Log.Write("Cleaning Autotools make files for", solution.Name); 926 m_Kernel.Log.Write("Cleaning Autotools make files for", solution.Name);
927 927
928 string slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile", "am"); 928 string slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile", "am");
929 Helper.DeleteIfExists(slnFile); 929 Helper.DeleteIfExists(slnFile);
930 930
931 slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile", "in"); 931 slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile", "in");
932 Helper.DeleteIfExists(slnFile); 932 Helper.DeleteIfExists(slnFile);
933 933
934 slnFile = Helper.MakeFilePath(solution.FullPath, "configure", "ac"); 934 slnFile = Helper.MakeFilePath(solution.FullPath, "configure", "ac");
935 Helper.DeleteIfExists(slnFile); 935 Helper.DeleteIfExists(slnFile);
936 936
937 slnFile = Helper.MakeFilePath(solution.FullPath, "configure"); 937 slnFile = Helper.MakeFilePath(solution.FullPath, "configure");
938 Helper.DeleteIfExists(slnFile); 938 Helper.DeleteIfExists(slnFile);
939 939
940 slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile"); 940 slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile");
941 Helper.DeleteIfExists(slnFile); 941 Helper.DeleteIfExists(slnFile);
942 942
943 foreach (ProjectNode project in solution.Projects) 943 foreach (ProjectNode project in solution.Projects)
944 { 944 {
945 CleanProject(project); 945 CleanProject(project);
946 } 946 }
947 947
948 m_Kernel.Log.Write(""); 948 m_Kernel.Log.Write("");
949 } 949 }
950 950
951 #endregion 951 #endregion
952 952
953 #region ITarget Members 953 #region ITarget Members
954 954
955 /// <summary> 955 /// <summary>
956 /// Writes the specified kern. 956 /// Writes the specified kern.
957 /// </summary> 957 /// </summary>
958 /// <param name="kern">The kern.</param> 958 /// <param name="kern">The kern.</param>
959 public void Write(Kernel kern) 959 public void Write(Kernel kern)
960 { 960 {
961 if (kern == null) 961 if (kern == null)
962 { 962 {
963 throw new ArgumentNullException("kern"); 963 throw new ArgumentNullException("kern");
964 } 964 }
965 m_Kernel = kern; 965 m_Kernel = kern;
966 m_Kernel.Log.Write("Parsing system pkg-config files"); 966 m_Kernel.Log.Write("Parsing system pkg-config files");
967 RunInitialization(); 967 RunInitialization();
968 968
969 const string streamName = "autotools.xml"; 969 const string streamName = "autotools.xml";
970 string fqStreamName = String.Format("Prebuild.data.{0}", 970 string fqStreamName = String.Format("Prebuild.data.{0}",
971 streamName 971 streamName
972 ); 972 );
973 973
974 // Retrieve stream for the autotools template XML 974 // Retrieve stream for the autotools template XML
975 Stream autotoolsStream = Assembly.GetExecutingAssembly() 975 Stream autotoolsStream = Assembly.GetExecutingAssembly()
976 .GetManifestResourceStream(fqStreamName); 976 .GetManifestResourceStream(fqStreamName);
977 977
978 if(autotoolsStream == null) { 978 if(autotoolsStream == null) {
979 979
980 /* 980 /*
981 * try without the default namespace prepended, in 981 * try without the default namespace prepended, in
982 * case prebuild.exe assembly was compiled with 982 * case prebuild.exe assembly was compiled with
983 * something other than Visual Studio .NET 983 * something other than Visual Studio .NET
984 */ 984 */
985 985
986 autotoolsStream = Assembly.GetExecutingAssembly() 986 autotoolsStream = Assembly.GetExecutingAssembly()
987 .GetManifestResourceStream(streamName); 987 .GetManifestResourceStream(streamName);
988 if(autotoolsStream == null){ 988 if(autotoolsStream == null){
989 string errStr = 989 string errStr =
990 String.Format("Could not find embedded resource file:\n" + 990 String.Format("Could not find embedded resource file:\n" +
991 "'{0}' or '{1}'", 991 "'{0}' or '{1}'",
992 streamName, fqStreamName 992 streamName, fqStreamName
993 ); 993 );
994 994
995 m_Kernel.Log.Write(errStr); 995 m_Kernel.Log.Write(errStr);
996 996
997 throw new System.Reflection.TargetException(errStr); 997 throw new System.Reflection.TargetException(errStr);
998 } 998 }
999 } 999 }
1000 1000
1001 // Create an XML URL Resolver with default credentials 1001 // Create an XML URL Resolver with default credentials
1002 xr = new System.Xml.XmlUrlResolver(); 1002 xr = new System.Xml.XmlUrlResolver();
1003 xr.Credentials = CredentialCache.DefaultCredentials; 1003 xr.Credentials = CredentialCache.DefaultCredentials;
1004 1004
1005 // Create a default evidence - no need to limit access 1005 // Create a default evidence - no need to limit access
1006 e = new System.Security.Policy.Evidence(); 1006 e = new System.Security.Policy.Evidence();
1007 1007
1008 // Load the autotools XML 1008 // Load the autotools XML
1009 autotoolsDoc = new XmlDocument(); 1009 autotoolsDoc = new XmlDocument();
1010 autotoolsDoc.Load(autotoolsStream); 1010 autotoolsDoc.Load(autotoolsStream);
1011 1011
1012 /* rootDir is the filesystem location where the Autotools 1012 /* rootDir is the filesystem location where the Autotools
1013 * build tree will be created - for now we'll make it 1013 * build tree will be created - for now we'll make it
1014 * $PWD/autotools 1014 * $PWD/autotools
1015 */ 1015 */
1016 1016
1017 string pwd = Directory.GetCurrentDirectory(); 1017 string pwd = Directory.GetCurrentDirectory();
1018 //string pwd = System.Environment.GetEnvironmentVariable("PWD"); 1018 //string pwd = System.Environment.GetEnvironmentVariable("PWD");
1019 //if (pwd.Length != 0) 1019 //if (pwd.Length != 0)
1020 //{ 1020 //{
1021 string rootDir = Path.Combine(pwd, "autotools"); 1021 string rootDir = Path.Combine(pwd, "autotools");
1022 //} 1022 //}
1023 //else 1023 //else
1024 //{ 1024 //{
1025 // pwd = Assembly.GetExecutingAssembly() 1025 // pwd = Assembly.GetExecutingAssembly()
1026 //} 1026 //}
1027 chkMkDir(rootDir); 1027 chkMkDir(rootDir);
1028 1028
1029 foreach (SolutionNode solution in kern.Solutions) 1029 foreach (SolutionNode solution in kern.Solutions)
1030 { 1030 {
1031 m_Kernel.Log.Write(String.Format("Writing solution: {0}", 1031 m_Kernel.Log.Write(String.Format("Writing solution: {0}",
1032 solution.Name)); 1032 solution.Name));
1033 WriteCombine(solution); 1033 WriteCombine(solution);
1034 } 1034 }
1035 m_Kernel = null; 1035 m_Kernel = null;
1036 } 1036 }
1037 1037
1038 /// <summary> 1038 /// <summary>
1039 /// Cleans the specified kern. 1039 /// Cleans the specified kern.
1040 /// </summary> 1040 /// </summary>
1041 /// <param name="kern">The kern.</param> 1041 /// <param name="kern">The kern.</param>
1042 public virtual void Clean(Kernel kern) 1042 public virtual void Clean(Kernel kern)
1043 { 1043 {
1044 if (kern == null) 1044 if (kern == null)
1045 { 1045 {
1046 throw new ArgumentNullException("kern"); 1046 throw new ArgumentNullException("kern");
1047 } 1047 }
1048 m_Kernel = kern; 1048 m_Kernel = kern;
1049 foreach (SolutionNode sol in kern.Solutions) 1049 foreach (SolutionNode sol in kern.Solutions)
1050 { 1050 {
1051 CleanSolution(sol); 1051 CleanSolution(sol);
1052 } 1052 }
1053 m_Kernel = null; 1053 m_Kernel = null;
1054 } 1054 }
1055 1055
1056 /// <summary> 1056 /// <summary>
1057 /// Gets the name. 1057 /// Gets the name.
1058 /// </summary> 1058 /// </summary>
1059 /// <value>The name.</value> 1059 /// <value>The name.</value>
1060 public string Name 1060 public string Name
1061 { 1061 {
1062 get 1062 get
1063 { 1063 {
1064 return "autotools"; 1064 return "autotools";
1065 } 1065 }
1066 } 1066 }
1067 1067
1068 #endregion 1068 #endregion
1069 } 1069 }
1070} 1070}
diff --git a/Prebuild/src/Core/Targets/VS2010Target.cs b/Prebuild/src/Core/Targets/VS2010Target.cs
index ea9f736..b16120c 100644
--- a/Prebuild/src/Core/Targets/VS2010Target.cs
+++ b/Prebuild/src/Core/Targets/VS2010Target.cs
@@ -1,138 +1,138 @@
1using System; 1using System;
2using System.IO; 2using System.IO;
3using System.Text; 3using System.Text;
4 4
5using Prebuild.Core.Attributes; 5using Prebuild.Core.Attributes;
6using Prebuild.Core.Interfaces; 6using Prebuild.Core.Interfaces;
7using Prebuild.Core.Nodes; 7using Prebuild.Core.Nodes;
8using Prebuild.Core.Utilities; 8using Prebuild.Core.Utilities;
9using System.CodeDom.Compiler; 9using System.CodeDom.Compiler;
10 10
11namespace Prebuild.Core.Targets 11namespace Prebuild.Core.Targets
12{ 12{
13 13
14 /// <summary> 14 /// <summary>
15 /// 15 ///
16 /// </summary> 16 /// </summary>
17 [Target("vs2010")] 17 [Target("vs2010")]
18 public class VS2010Target : VSGenericTarget 18 public class VS2010Target : VSGenericTarget
19 { 19 {
20 #region Fields 20 #region Fields
21 21
22 string solutionVersion = "11.00"; 22 string solutionVersion = "11.00";
23 string productVersion = "9.0.30729"; 23 string productVersion = "9.0.30729";
24 string schemaVersion = "2.0"; 24 string schemaVersion = "2.0";
25 string versionName = "Visual Studio 2010"; 25 string versionName = "Visual Studio 2010";
26 string name = "vs2010"; 26 string name = "vs2010";
27 VSVersion version = VSVersion.VS10; 27 VSVersion version = VSVersion.VS10;
28 28
29 #endregion 29 #endregion
30 30
31 #region Properties 31 #region Properties
32 32
33 /// <summary> 33 /// <summary>
34 /// Gets or sets the solution version. 34 /// Gets or sets the solution version.
35 /// </summary> 35 /// </summary>
36 /// <value>The solution version.</value> 36 /// <value>The solution version.</value>
37 public override string SolutionVersion 37 public override string SolutionVersion
38 { 38 {
39 get 39 get
40 { 40 {
41 return solutionVersion; 41 return solutionVersion;
42 } 42 }
43 } 43 }
44 44
45 /// <summary> 45 /// <summary>
46 /// Gets or sets the product version. 46 /// Gets or sets the product version.
47 /// </summary> 47 /// </summary>
48 /// <value>The product version.</value> 48 /// <value>The product version.</value>
49 public override string ProductVersion 49 public override string ProductVersion
50 { 50 {
51 get 51 get
52 { 52 {
53 return productVersion; 53 return productVersion;
54 } 54 }
55 } 55 }
56 56
57 /// <summary> 57 /// <summary>
58 /// Gets or sets the schema version. 58 /// Gets or sets the schema version.
59 /// </summary> 59 /// </summary>
60 /// <value>The schema version.</value> 60 /// <value>The schema version.</value>
61 public override string SchemaVersion 61 public override string SchemaVersion
62 { 62 {
63 get 63 get
64 { 64 {
65 return schemaVersion; 65 return schemaVersion;
66 } 66 }
67 } 67 }
68 68
69 /// <summary> 69 /// <summary>
70 /// Gets or sets the name of the version. 70 /// Gets or sets the name of the version.
71 /// </summary> 71 /// </summary>
72 /// <value>The name of the version.</value> 72 /// <value>The name of the version.</value>
73 public override string VersionName 73 public override string VersionName
74 { 74 {
75 get 75 get
76 { 76 {
77 return versionName; 77 return versionName;
78 } 78 }
79 } 79 }
80 80
81 /// <summary> 81 /// <summary>
82 /// Gets or sets the version. 82 /// Gets or sets the version.
83 /// </summary> 83 /// </summary>
84 /// <value>The version.</value> 84 /// <value>The version.</value>
85 public override VSVersion Version 85 public override VSVersion Version
86 { 86 {
87 get 87 get
88 { 88 {
89 return version; 89 return version;
90 } 90 }
91 } 91 }
92 92
93 /// <summary> 93 /// <summary>
94 /// Gets the name. 94 /// Gets the name.
95 /// </summary> 95 /// </summary>
96 /// <value>The name.</value> 96 /// <value>The name.</value>
97 public override string Name 97 public override string Name
98 { 98 {
99 get 99 get
100 { 100 {
101 return name; 101 return name;
102 } 102 }
103 } 103 }
104 104
105 protected override string GetToolsVersionXml(FrameworkVersion frameworkVersion) 105 protected override string GetToolsVersionXml(FrameworkVersion frameworkVersion)
106 { 106 {
107 switch (frameworkVersion) 107 switch (frameworkVersion)
108 { 108 {
109 case FrameworkVersion.v4_0: 109 case FrameworkVersion.v4_0:
110 case FrameworkVersion.v3_5: 110 case FrameworkVersion.v3_5:
111 return "ToolsVersion=\"4.0\""; 111 return "ToolsVersion=\"4.0\"";
112 case FrameworkVersion.v3_0: 112 case FrameworkVersion.v3_0:
113 return "ToolsVersion=\"3.0\""; 113 return "ToolsVersion=\"3.0\"";
114 default: 114 default:
115 return "ToolsVersion=\"2.0\""; 115 return "ToolsVersion=\"2.0\"";
116 } 116 }
117 } 117 }
118 118
119 public override string SolutionTag 119 public override string SolutionTag
120 { 120 {
121 get { return "# Visual Studio 2010"; } 121 get { return "# Visual Studio 2010"; }
122 } 122 }
123 123
124 #endregion 124 #endregion
125 125
126 #region Constructors 126 #region Constructors
127 127
128 /// <summary> 128 /// <summary>
129 /// Initializes a new instance of the <see cref="VS2005Target"/> class. 129 /// Initializes a new instance of the <see cref="VS2005Target"/> class.
130 /// </summary> 130 /// </summary>
131 public VS2010Target() 131 public VS2010Target()
132 : base() 132 : base()
133 { 133 {
134 } 134 }
135 135
136 #endregion 136 #endregion
137 } 137 }
138} 138}
diff --git a/Prebuild/src/Core/Targets/VSGenericTarget.cs b/Prebuild/src/Core/Targets/VSGenericTarget.cs
index 6969dd7..cd3f5bb 100644
--- a/Prebuild/src/Core/Targets/VSGenericTarget.cs
+++ b/Prebuild/src/Core/Targets/VSGenericTarget.cs
@@ -1,922 +1,922 @@
1#region BSD License 1#region BSD License
2/* 2/*
3Copyright (c) 2008 Matthew Holmes (matthew@wildfiregames.com), John Anderson (sontek@gmail.com) 3Copyright (c) 2008 Matthew Holmes (matthew@wildfiregames.com), John Anderson (sontek@gmail.com)
4 4
5Redistribution and use in source and binary forms, with or without modification, are permitted 5Redistribution and use in source and binary forms, with or without modification, are permitted
6provided that the following conditions are met: 6provided that the following conditions are met:
7 7
8 * Redistributions of source code must retain the above copyright notice, this list of conditions 8 * Redistributions of source code must retain the above copyright notice, this list of conditions
9 and the following disclaimer. 9 and the following disclaimer.
10 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions 10 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions
11 and the following disclaimer in the documentation and/or other materials provided with the 11 and the following disclaimer in the documentation and/or other materials provided with the
12 distribution. 12 distribution.
13 * The name of the author may not be used to endorse or promote products derived from this software 13 * The name of the author may not be used to endorse or promote products derived from this software
14 without specific prior written permission. 14 without specific prior written permission.
15 15
16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
17BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 21OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
22IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */ 23 */
24#endregion 24#endregion
25 25
26using System; 26using System;
27using System.Collections.Generic; 27using System.Collections.Generic;
28using System.IO; 28using System.IO;
29using Prebuild.Core.Interfaces; 29using Prebuild.Core.Interfaces;
30using Prebuild.Core.Nodes; 30using Prebuild.Core.Nodes;
31using Prebuild.Core.Utilities; 31using Prebuild.Core.Utilities;
32using System.CodeDom.Compiler; 32using System.CodeDom.Compiler;
33 33
34namespace Prebuild.Core.Targets 34namespace Prebuild.Core.Targets
35{ 35{
36 36
37 /// <summary> 37 /// <summary>
38 /// 38 ///
39 /// </summary> 39 /// </summary>
40 public abstract class VSGenericTarget : ITarget 40 public abstract class VSGenericTarget : ITarget
41 { 41 {
42 #region Fields 42 #region Fields
43 43
44 readonly Dictionary<string, ToolInfo> tools = new Dictionary<string, ToolInfo>(); 44 readonly Dictionary<string, ToolInfo> tools = new Dictionary<string, ToolInfo>();
45 Kernel kernel; 45 Kernel kernel;
46 #endregion 46 #endregion
47 47
48 #region Properties 48 #region Properties
49 /// <summary> 49 /// <summary>
50 /// Gets or sets the solution version. 50 /// Gets or sets the solution version.
51 /// </summary> 51 /// </summary>
52 /// <value>The solution version.</value> 52 /// <value>The solution version.</value>
53 public abstract string SolutionVersion { get; } 53 public abstract string SolutionVersion { get; }
54 /// <summary> 54 /// <summary>
55 /// Gets or sets the product version. 55 /// Gets or sets the product version.
56 /// </summary> 56 /// </summary>
57 /// <value>The product version.</value> 57 /// <value>The product version.</value>
58 public abstract string ProductVersion { get; } 58 public abstract string ProductVersion { get; }
59 /// <summary> 59 /// <summary>
60 /// Gets or sets the schema version. 60 /// Gets or sets the schema version.
61 /// </summary> 61 /// </summary>
62 /// <value>The schema version.</value> 62 /// <value>The schema version.</value>
63 public abstract string SchemaVersion { get; } 63 public abstract string SchemaVersion { get; }
64 /// <summary> 64 /// <summary>
65 /// Gets or sets the name of the version. 65 /// Gets or sets the name of the version.
66 /// </summary> 66 /// </summary>
67 /// <value>The name of the version.</value> 67 /// <value>The name of the version.</value>
68 public abstract string VersionName { get; } 68 public abstract string VersionName { get; }
69 /// <summary> 69 /// <summary>
70 /// Gets or sets the version. 70 /// Gets or sets the version.
71 /// </summary> 71 /// </summary>
72 /// <value>The version.</value> 72 /// <value>The version.</value>
73 public abstract VSVersion Version { get; } 73 public abstract VSVersion Version { get; }
74 /// <summary> 74 /// <summary>
75 /// Gets the name. 75 /// Gets the name.
76 /// </summary> 76 /// </summary>
77 /// <value>The name.</value> 77 /// <value>The name.</value>
78 public abstract string Name { get; } 78 public abstract string Name { get; }
79 79
80 protected abstract string GetToolsVersionXml(FrameworkVersion version); 80 protected abstract string GetToolsVersionXml(FrameworkVersion version);
81 public abstract string SolutionTag { get; } 81 public abstract string SolutionTag { get; }
82 82
83 #endregion 83 #endregion
84 84
85 #region Constructors 85 #region Constructors
86 86
87 /// <summary> 87 /// <summary>
88 /// Initializes a new instance of the <see cref="VSGenericTarget"/> class. 88 /// Initializes a new instance of the <see cref="VSGenericTarget"/> class.
89 /// </summary> 89 /// </summary>
90 protected VSGenericTarget() 90 protected VSGenericTarget()
91 { 91 {
92 tools["C#"] = new ToolInfo("C#", "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}", "csproj", "CSHARP", "$(MSBuildBinPath)\\Microsoft.CSHARP.Targets"); 92 tools["C#"] = new ToolInfo("C#", "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}", "csproj", "CSHARP", "$(MSBuildBinPath)\\Microsoft.CSHARP.Targets");
93 tools["Database"] = new ToolInfo("Database", "{4F174C21-8C12-11D0-8340-0000F80270F8}", "dbp", "UNKNOWN"); 93 tools["Database"] = new ToolInfo("Database", "{4F174C21-8C12-11D0-8340-0000F80270F8}", "dbp", "UNKNOWN");
94 tools["Boo"] = new ToolInfo("Boo", "{45CEA7DC-C2ED-48A6-ACE0-E16144C02365}", "booproj", "Boo", "$(BooBinPath)\\Boo.Microsoft.Build.targets"); 94 tools["Boo"] = new ToolInfo("Boo", "{45CEA7DC-C2ED-48A6-ACE0-E16144C02365}", "booproj", "Boo", "$(BooBinPath)\\Boo.Microsoft.Build.targets");
95 tools["VisualBasic"] = new ToolInfo("VisualBasic", "{F184B08F-C81C-45F6-A57F-5ABD9991F28F}", "vbproj", "VisualBasic", "$(MSBuildBinPath)\\Microsoft.VisualBasic.Targets"); 95 tools["VisualBasic"] = new ToolInfo("VisualBasic", "{F184B08F-C81C-45F6-A57F-5ABD9991F28F}", "vbproj", "VisualBasic", "$(MSBuildBinPath)\\Microsoft.VisualBasic.Targets");
96 tools["Folder"] = new ToolInfo("Folder", "{2150E333-8FDC-42A3-9474-1A3956D46DE8}", null, null); 96 tools["Folder"] = new ToolInfo("Folder", "{2150E333-8FDC-42A3-9474-1A3956D46DE8}", null, null);
97 } 97 }
98 98
99 #endregion 99 #endregion
100 100
101 #region Private Methods 101 #region Private Methods
102 102
103 private string MakeRefPath(ProjectNode project) 103 private string MakeRefPath(ProjectNode project)
104 { 104 {
105 string ret = ""; 105 string ret = "";
106 foreach (ReferencePathNode node in project.ReferencePaths) 106 foreach (ReferencePathNode node in project.ReferencePaths)
107 { 107 {
108 try 108 try
109 { 109 {
110 string fullPath = Helper.ResolvePath(node.Path); 110 string fullPath = Helper.ResolvePath(node.Path);
111 if (ret.Length < 1) 111 if (ret.Length < 1)
112 { 112 {
113 ret = fullPath; 113 ret = fullPath;
114 } 114 }
115 else 115 else
116 { 116 {
117 ret += ";" + fullPath; 117 ret += ";" + fullPath;
118 } 118 }
119 } 119 }
120 catch (ArgumentException) 120 catch (ArgumentException)
121 { 121 {
122 kernel.Log.Write(LogType.Warning, "Could not resolve reference path: {0}", node.Path); 122 kernel.Log.Write(LogType.Warning, "Could not resolve reference path: {0}", node.Path);
123 } 123 }
124 } 124 }
125 125
126 return ret; 126 return ret;
127 } 127 }
128 128
129 private static ProjectNode FindProjectInSolution(string name, SolutionNode solution) 129 private static ProjectNode FindProjectInSolution(string name, SolutionNode solution)
130 { 130 {
131 SolutionNode node = solution; 131 SolutionNode node = solution;
132 132
133 while (node.Parent is SolutionNode) 133 while (node.Parent is SolutionNode)
134 node = node.Parent as SolutionNode; 134 node = node.Parent as SolutionNode;
135 135
136 return FindProjectInSolutionRecursively(name, node); 136 return FindProjectInSolutionRecursively(name, node);
137 } 137 }
138 138
139 private static ProjectNode FindProjectInSolutionRecursively(string name, SolutionNode solution) 139 private static ProjectNode FindProjectInSolutionRecursively(string name, SolutionNode solution)
140 { 140 {
141 if (solution.ProjectsTable.ContainsKey(name)) 141 if (solution.ProjectsTable.ContainsKey(name))
142 return solution.ProjectsTable[name]; 142 return solution.ProjectsTable[name];
143 143
144 foreach (SolutionNode child in solution.Solutions) 144 foreach (SolutionNode child in solution.Solutions)
145 { 145 {
146 ProjectNode node = FindProjectInSolutionRecursively(name, child); 146 ProjectNode node = FindProjectInSolutionRecursively(name, child);
147 if (node != null) 147 if (node != null)
148 return node; 148 return node;
149 } 149 }
150 150
151 return null; 151 return null;
152 } 152 }
153 153
154 private void WriteProject(SolutionNode solution, ProjectNode project) 154 private void WriteProject(SolutionNode solution, ProjectNode project)
155 { 155 {
156 if (!tools.ContainsKey(project.Language)) 156 if (!tools.ContainsKey(project.Language))
157 { 157 {
158 throw new UnknownLanguageException("Unknown .NET language: " + project.Language); 158 throw new UnknownLanguageException("Unknown .NET language: " + project.Language);
159 } 159 }
160 160
161 ToolInfo toolInfo = tools[project.Language]; 161 ToolInfo toolInfo = tools[project.Language];
162 string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); 162 string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension);
163 StreamWriter ps = new StreamWriter(projectFile); 163 StreamWriter ps = new StreamWriter(projectFile);
164 164
165 kernel.CurrentWorkingDirectory.Push(); 165 kernel.CurrentWorkingDirectory.Push();
166 Helper.SetCurrentDir(Path.GetDirectoryName(projectFile)); 166 Helper.SetCurrentDir(Path.GetDirectoryName(projectFile));
167 167
168 #region Project File 168 #region Project File
169 using (ps) 169 using (ps)
170 { 170 {
171 ps.WriteLine("<Project DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\" {0}>", GetToolsVersionXml(project.FrameworkVersion)); 171 ps.WriteLine("<Project DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\" {0}>", GetToolsVersionXml(project.FrameworkVersion));
172 ps.WriteLine(" <PropertyGroup>"); 172 ps.WriteLine(" <PropertyGroup>");
173 ps.WriteLine(" <ProjectType>Local</ProjectType>"); 173 ps.WriteLine(" <ProjectType>Local</ProjectType>");
174 ps.WriteLine(" <ProductVersion>{0}</ProductVersion>", ProductVersion); 174 ps.WriteLine(" <ProductVersion>{0}</ProductVersion>", ProductVersion);
175 ps.WriteLine(" <SchemaVersion>{0}</SchemaVersion>", SchemaVersion); 175 ps.WriteLine(" <SchemaVersion>{0}</SchemaVersion>", SchemaVersion);
176 ps.WriteLine(" <ProjectGuid>{{{0}}}</ProjectGuid>", project.Guid.ToString().ToUpper()); 176 ps.WriteLine(" <ProjectGuid>{{{0}}}</ProjectGuid>", project.Guid.ToString().ToUpper());
177 177
178 // Visual Studio has a hard coded guid for the project type 178 // Visual Studio has a hard coded guid for the project type
179 if (project.Type == ProjectType.Web) 179 if (project.Type == ProjectType.Web)
180 ps.WriteLine(" <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>"); 180 ps.WriteLine(" <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>");
181 ps.WriteLine(" <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>"); 181 ps.WriteLine(" <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>");
182 ps.WriteLine(" <ApplicationIcon>{0}</ApplicationIcon>", project.AppIcon); 182 ps.WriteLine(" <ApplicationIcon>{0}</ApplicationIcon>", project.AppIcon);
183 ps.WriteLine(" <AssemblyKeyContainerName>"); 183 ps.WriteLine(" <AssemblyKeyContainerName>");
184 ps.WriteLine(" </AssemblyKeyContainerName>"); 184 ps.WriteLine(" </AssemblyKeyContainerName>");
185 ps.WriteLine(" <AssemblyName>{0}</AssemblyName>", project.AssemblyName); 185 ps.WriteLine(" <AssemblyName>{0}</AssemblyName>", project.AssemblyName);
186 foreach (ConfigurationNode conf in project.Configurations) 186 foreach (ConfigurationNode conf in project.Configurations)
187 { 187 {
188 if (conf.Options.KeyFile != "") 188 if (conf.Options.KeyFile != "")
189 { 189 {
190 ps.WriteLine(" <AssemblyOriginatorKeyFile>{0}</AssemblyOriginatorKeyFile>", conf.Options.KeyFile); 190 ps.WriteLine(" <AssemblyOriginatorKeyFile>{0}</AssemblyOriginatorKeyFile>", conf.Options.KeyFile);
191 ps.WriteLine(" <SignAssembly>true</SignAssembly>"); 191 ps.WriteLine(" <SignAssembly>true</SignAssembly>");
192 break; 192 break;
193 } 193 }
194 } 194 }
195 ps.WriteLine(" <DefaultClientScript>JScript</DefaultClientScript>"); 195 ps.WriteLine(" <DefaultClientScript>JScript</DefaultClientScript>");
196 ps.WriteLine(" <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>"); 196 ps.WriteLine(" <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>");
197 ps.WriteLine(" <DefaultTargetSchema>IE50</DefaultTargetSchema>"); 197 ps.WriteLine(" <DefaultTargetSchema>IE50</DefaultTargetSchema>");
198 ps.WriteLine(" <DelaySign>false</DelaySign>"); 198 ps.WriteLine(" <DelaySign>false</DelaySign>");
199 ps.WriteLine(" <TargetFrameworkVersion>{0}</TargetFrameworkVersion>", project.FrameworkVersion.ToString().Replace("_", ".")); 199 ps.WriteLine(" <TargetFrameworkVersion>{0}</TargetFrameworkVersion>", project.FrameworkVersion.ToString().Replace("_", "."));
200 200
201 ps.WriteLine(" <OutputType>{0}</OutputType>", project.Type == ProjectType.Web ? ProjectType.Library.ToString() : project.Type.ToString()); 201 ps.WriteLine(" <OutputType>{0}</OutputType>", project.Type == ProjectType.Web ? ProjectType.Library.ToString() : project.Type.ToString());
202 ps.WriteLine(" <AppDesignerFolder>{0}</AppDesignerFolder>", project.DesignerFolder); 202 ps.WriteLine(" <AppDesignerFolder>{0}</AppDesignerFolder>", project.DesignerFolder);
203 ps.WriteLine(" <RootNamespace>{0}</RootNamespace>", project.RootNamespace); 203 ps.WriteLine(" <RootNamespace>{0}</RootNamespace>", project.RootNamespace);
204 ps.WriteLine(" <StartupObject>{0}</StartupObject>", project.StartupObject); 204 ps.WriteLine(" <StartupObject>{0}</StartupObject>", project.StartupObject);
205 if (string.IsNullOrEmpty(project.DebugStartParameters)) 205 if (string.IsNullOrEmpty(project.DebugStartParameters))
206 { 206 {
207 ps.WriteLine(" <StartArguments>{0}</StartArguments>", project.DebugStartParameters); 207 ps.WriteLine(" <StartArguments>{0}</StartArguments>", project.DebugStartParameters);
208 } 208 }
209 ps.WriteLine(" <FileUpgradeFlags>"); 209 ps.WriteLine(" <FileUpgradeFlags>");
210 ps.WriteLine(" </FileUpgradeFlags>"); 210 ps.WriteLine(" </FileUpgradeFlags>");
211 211
212 ps.WriteLine(" </PropertyGroup>"); 212 ps.WriteLine(" </PropertyGroup>");
213 213
214 foreach (ConfigurationNode conf in project.Configurations) 214 foreach (ConfigurationNode conf in project.Configurations)
215 { 215 {
216 ps.Write(" <PropertyGroup "); 216 ps.Write(" <PropertyGroup ");
217 ps.WriteLine("Condition=\" '$(Configuration)|$(Platform)' == '{0}|{1}' \">", conf.Name, conf.Platform); 217 ps.WriteLine("Condition=\" '$(Configuration)|$(Platform)' == '{0}|{1}' \">", conf.Name, conf.Platform);
218 ps.WriteLine(" <AllowUnsafeBlocks>{0}</AllowUnsafeBlocks>", conf.Options["AllowUnsafe"]); 218 ps.WriteLine(" <AllowUnsafeBlocks>{0}</AllowUnsafeBlocks>", conf.Options["AllowUnsafe"]);
219 ps.WriteLine(" <BaseAddress>{0}</BaseAddress>", conf.Options["BaseAddress"]); 219 ps.WriteLine(" <BaseAddress>{0}</BaseAddress>", conf.Options["BaseAddress"]);
220 ps.WriteLine(" <CheckForOverflowUnderflow>{0}</CheckForOverflowUnderflow>", conf.Options["CheckUnderflowOverflow"]); 220 ps.WriteLine(" <CheckForOverflowUnderflow>{0}</CheckForOverflowUnderflow>", conf.Options["CheckUnderflowOverflow"]);
221 ps.WriteLine(" <ConfigurationOverrideFile>"); 221 ps.WriteLine(" <ConfigurationOverrideFile>");
222 ps.WriteLine(" </ConfigurationOverrideFile>"); 222 ps.WriteLine(" </ConfigurationOverrideFile>");
223 ps.WriteLine(" <DefineConstants>{0}</DefineConstants>", conf.Options["CompilerDefines"]); 223 ps.WriteLine(" <DefineConstants>{0}</DefineConstants>", conf.Options["CompilerDefines"]);
224 ps.WriteLine(" <DocumentationFile>{0}</DocumentationFile>", Helper.NormalizePath(conf.Options["XmlDocFile"].ToString())); 224 ps.WriteLine(" <DocumentationFile>{0}</DocumentationFile>", Helper.NormalizePath(conf.Options["XmlDocFile"].ToString()));
225 ps.WriteLine(" <DebugSymbols>{0}</DebugSymbols>", conf.Options["DebugInformation"]); 225 ps.WriteLine(" <DebugSymbols>{0}</DebugSymbols>", conf.Options["DebugInformation"]);
226 ps.WriteLine(" <FileAlignment>{0}</FileAlignment>", conf.Options["FileAlignment"]); 226 ps.WriteLine(" <FileAlignment>{0}</FileAlignment>", conf.Options["FileAlignment"]);
227 ps.WriteLine(" <Optimize>{0}</Optimize>", conf.Options["OptimizeCode"]); 227 ps.WriteLine(" <Optimize>{0}</Optimize>", conf.Options["OptimizeCode"]);
228 if (project.Type != ProjectType.Web) 228 if (project.Type != ProjectType.Web)
229 ps.WriteLine(" <OutputPath>{0}</OutputPath>", 229 ps.WriteLine(" <OutputPath>{0}</OutputPath>",
230 Helper.EndPath(Helper.NormalizePath(conf.Options["OutputPath"].ToString()))); 230 Helper.EndPath(Helper.NormalizePath(conf.Options["OutputPath"].ToString())));
231 else 231 else
232 ps.WriteLine(" <OutputPath>{0}</OutputPath>", 232 ps.WriteLine(" <OutputPath>{0}</OutputPath>",
233 Helper.EndPath(Helper.NormalizePath("bin\\"))); 233 Helper.EndPath(Helper.NormalizePath("bin\\")));
234 234
235 ps.WriteLine(" <RegisterForComInterop>{0}</RegisterForComInterop>", conf.Options["RegisterComInterop"]); 235 ps.WriteLine(" <RegisterForComInterop>{0}</RegisterForComInterop>", conf.Options["RegisterComInterop"]);
236 ps.WriteLine(" <RemoveIntegerChecks>{0}</RemoveIntegerChecks>", conf.Options["RemoveIntegerChecks"]); 236 ps.WriteLine(" <RemoveIntegerChecks>{0}</RemoveIntegerChecks>", conf.Options["RemoveIntegerChecks"]);
237 ps.WriteLine(" <TreatWarningsAsErrors>{0}</TreatWarningsAsErrors>", conf.Options["WarningsAsErrors"]); 237 ps.WriteLine(" <TreatWarningsAsErrors>{0}</TreatWarningsAsErrors>", conf.Options["WarningsAsErrors"]);
238 ps.WriteLine(" <WarningLevel>{0}</WarningLevel>", conf.Options["WarningLevel"]); 238 ps.WriteLine(" <WarningLevel>{0}</WarningLevel>", conf.Options["WarningLevel"]);
239 ps.WriteLine(" <NoStdLib>{0}</NoStdLib>", conf.Options["NoStdLib"]); 239 ps.WriteLine(" <NoStdLib>{0}</NoStdLib>", conf.Options["NoStdLib"]);
240 ps.WriteLine(" <NoWarn>{0}</NoWarn>", conf.Options["SuppressWarnings"]); 240 ps.WriteLine(" <NoWarn>{0}</NoWarn>", conf.Options["SuppressWarnings"]);
241 ps.WriteLine(" <PlatformTarget>{0}</PlatformTarget>", conf.Platform); 241 ps.WriteLine(" <PlatformTarget>{0}</PlatformTarget>", conf.Platform);
242 ps.WriteLine(" </PropertyGroup>"); 242 ps.WriteLine(" </PropertyGroup>");
243 } 243 }
244 244
245 //ps.WriteLine(" </Settings>"); 245 //ps.WriteLine(" </Settings>");
246 246
247 Dictionary<ReferenceNode, ProjectNode> projectReferences = new Dictionary<ReferenceNode, ProjectNode>(); 247 Dictionary<ReferenceNode, ProjectNode> projectReferences = new Dictionary<ReferenceNode, ProjectNode>();
248 List<ReferenceNode> otherReferences = new List<ReferenceNode>(); 248 List<ReferenceNode> otherReferences = new List<ReferenceNode>();
249 249
250 foreach (ReferenceNode refr in project.References) 250 foreach (ReferenceNode refr in project.References)
251 { 251 {
252 ProjectNode projectNode = FindProjectInSolution(refr.Name, solution); 252 ProjectNode projectNode = FindProjectInSolution(refr.Name, solution);
253 253
254 if (projectNode == null) 254 if (projectNode == null)
255 otherReferences.Add(refr); 255 otherReferences.Add(refr);
256 else 256 else
257 projectReferences.Add(refr, projectNode); 257 projectReferences.Add(refr, projectNode);
258 } 258 }
259 // Assembly References 259 // Assembly References
260 ps.WriteLine(" <ItemGroup>"); 260 ps.WriteLine(" <ItemGroup>");
261 261
262 foreach (ReferenceNode refr in otherReferences) 262 foreach (ReferenceNode refr in otherReferences)
263 { 263 {
264 ps.Write(" <Reference"); 264 ps.Write(" <Reference");
265 ps.Write(" Include=\""); 265 ps.Write(" Include=\"");
266 ps.Write(refr.Name); 266 ps.Write(refr.Name);
267 ps.WriteLine("\" >"); 267 ps.WriteLine("\" >");
268 ps.Write(" <Name>"); 268 ps.Write(" <Name>");
269 ps.Write(refr.Name); 269 ps.Write(refr.Name);
270 ps.WriteLine("</Name>"); 270 ps.WriteLine("</Name>");
271 271
272 if(!String.IsNullOrEmpty(refr.Path)) 272 if(!String.IsNullOrEmpty(refr.Path))
273 { 273 {
274 // Use absolute path to assembly (for determining assembly type) 274 // Use absolute path to assembly (for determining assembly type)
275 string absolutePath = Path.Combine(project.FullPath, refr.Path); 275 string absolutePath = Path.Combine(project.FullPath, refr.Path);
276 if(File.Exists(Helper.MakeFilePath(absolutePath, refr.Name, "exe"))) { 276 if(File.Exists(Helper.MakeFilePath(absolutePath, refr.Name, "exe"))) {
277 // Assembly is an executable (exe) 277 // Assembly is an executable (exe)
278 ps.WriteLine(" <HintPath>{0}</HintPath>", Helper.MakeFilePath(refr.Path, refr.Name, "exe")); 278 ps.WriteLine(" <HintPath>{0}</HintPath>", Helper.MakeFilePath(refr.Path, refr.Name, "exe"));
279 } else if(File.Exists(Helper.MakeFilePath(absolutePath, refr.Name, "dll"))) { 279 } else if(File.Exists(Helper.MakeFilePath(absolutePath, refr.Name, "dll"))) {
280 // Assembly is an library (dll) 280 // Assembly is an library (dll)
281 ps.WriteLine(" <HintPath>{0}</HintPath>", Helper.MakeFilePath(refr.Path, refr.Name, "dll")); 281 ps.WriteLine(" <HintPath>{0}</HintPath>", Helper.MakeFilePath(refr.Path, refr.Name, "dll"));
282 } else { 282 } else {
283 string referencePath = Helper.MakeFilePath(refr.Path, refr.Name, "dll"); 283 string referencePath = Helper.MakeFilePath(refr.Path, refr.Name, "dll");
284 kernel.Log.Write(LogType.Warning, "Reference \"{0}\": The specified file doesn't exist.", referencePath); 284 kernel.Log.Write(LogType.Warning, "Reference \"{0}\": The specified file doesn't exist.", referencePath);
285 ps.WriteLine(" <HintPath>{0}</HintPath>", Helper.MakeFilePath(refr.Path, refr.Name, "dll")); 285 ps.WriteLine(" <HintPath>{0}</HintPath>", Helper.MakeFilePath(refr.Path, refr.Name, "dll"));
286 } 286 }
287 } 287 }
288 288
289 ps.WriteLine(" <Private>{0}</Private>", refr.LocalCopy); 289 ps.WriteLine(" <Private>{0}</Private>", refr.LocalCopy);
290 ps.WriteLine(" </Reference>"); 290 ps.WriteLine(" </Reference>");
291 } 291 }
292 ps.WriteLine(" </ItemGroup>"); 292 ps.WriteLine(" </ItemGroup>");
293 293
294 //Project References 294 //Project References
295 ps.WriteLine(" <ItemGroup>"); 295 ps.WriteLine(" <ItemGroup>");
296 foreach (KeyValuePair<ReferenceNode, ProjectNode> pair in projectReferences) 296 foreach (KeyValuePair<ReferenceNode, ProjectNode> pair in projectReferences)
297 { 297 {
298 ToolInfo tool = tools[pair.Value.Language]; 298 ToolInfo tool = tools[pair.Value.Language];
299 if (tools == null) 299 if (tools == null)
300 throw new UnknownLanguageException(); 300 throw new UnknownLanguageException();
301 301
302 string path = 302 string path =
303 Helper.MakePathRelativeTo(project.FullPath, 303 Helper.MakePathRelativeTo(project.FullPath,
304 Helper.MakeFilePath(pair.Value.FullPath, pair.Value.Name, tool.FileExtension)); 304 Helper.MakeFilePath(pair.Value.FullPath, pair.Value.Name, tool.FileExtension));
305 ps.WriteLine(" <ProjectReference Include=\"{0}\">", path); 305 ps.WriteLine(" <ProjectReference Include=\"{0}\">", path);
306 306
307 // TODO: Allow reference to visual basic projects 307 // TODO: Allow reference to visual basic projects
308 ps.WriteLine(" <Name>{0}</Name>", pair.Value.Name); 308 ps.WriteLine(" <Name>{0}</Name>", pair.Value.Name);
309 ps.WriteLine(" <Project>{0}</Project>", pair.Value.Guid.ToString("B").ToUpper()); 309 ps.WriteLine(" <Project>{0}</Project>", pair.Value.Guid.ToString("B").ToUpper());
310 ps.WriteLine(" <Package>{0}</Package>", tool.Guid.ToUpper()); 310 ps.WriteLine(" <Package>{0}</Package>", tool.Guid.ToUpper());
311 311
312 //This is the Copy Local flag in VS 312 //This is the Copy Local flag in VS
313 ps.WriteLine(" <Private>{0}</Private>", pair.Key.LocalCopy); 313 ps.WriteLine(" <Private>{0}</Private>", pair.Key.LocalCopy);
314 314
315 ps.WriteLine(" </ProjectReference>"); 315 ps.WriteLine(" </ProjectReference>");
316 } 316 }
317 ps.WriteLine(" </ItemGroup>"); 317 ps.WriteLine(" </ItemGroup>");
318 318
319 // ps.WriteLine(" </Build>"); 319 // ps.WriteLine(" </Build>");
320 ps.WriteLine(" <ItemGroup>"); 320 ps.WriteLine(" <ItemGroup>");
321 321
322 // ps.WriteLine(" <Include>"); 322 // ps.WriteLine(" <Include>");
323 List<string> list = new List<string>(); 323 List<string> list = new List<string>();
324 324
325 foreach (string path in project.Files) 325 foreach (string path in project.Files)
326 { 326 {
327 string lower = path.ToLower(); 327 string lower = path.ToLower();
328 if (lower.EndsWith(".resx")) 328 if (lower.EndsWith(".resx"))
329 { 329 {
330 string codebehind = String.Format("{0}.Designer{1}", path.Substring(0, path.LastIndexOf('.')), toolInfo.LanguageExtension); 330 string codebehind = String.Format("{0}.Designer{1}", path.Substring(0, path.LastIndexOf('.')), toolInfo.LanguageExtension);
331 if (!list.Contains(codebehind)) 331 if (!list.Contains(codebehind))
332 list.Add(codebehind); 332 list.Add(codebehind);
333 } 333 }
334 334
335 } 335 }
336 336
337 foreach (string filePath in project.Files) 337 foreach (string filePath in project.Files)
338 { 338 {
339 // if (file == "Properties\\Bind.Designer.cs") 339 // if (file == "Properties\\Bind.Designer.cs")
340 // { 340 // {
341 // Console.WriteLine("Wait a minute!"); 341 // Console.WriteLine("Wait a minute!");
342 // Console.WriteLine(project.Files.GetSubType(file).ToString()); 342 // Console.WriteLine(project.Files.GetSubType(file).ToString());
343 // } 343 // }
344 SubType subType = project.Files.GetSubType(filePath); 344 SubType subType = project.Files.GetSubType(filePath);
345 345
346 // Visual Studio chokes on file names if forward slash is used as a path separator 346 // Visual Studio chokes on file names if forward slash is used as a path separator
347 // instead of backslash. So we must make sure that all file paths written to the 347 // instead of backslash. So we must make sure that all file paths written to the
348 // project file use \ as a path separator. 348 // project file use \ as a path separator.
349 string file = filePath.Replace(@"/", @"\"); 349 string file = filePath.Replace(@"/", @"\");
350 350
351 if (subType != SubType.Code && subType != SubType.Settings && subType != SubType.Designer 351 if (subType != SubType.Code && subType != SubType.Settings && subType != SubType.Designer
352 && subType != SubType.CodeBehind) 352 && subType != SubType.CodeBehind)
353 { 353 {
354 ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".resx"); 354 ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".resx");
355 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file)); 355 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file));
356 ps.WriteLine(" <SubType>Designer</SubType>"); 356 ps.WriteLine(" <SubType>Designer</SubType>");
357 ps.WriteLine(" </EmbeddedResource>"); 357 ps.WriteLine(" </EmbeddedResource>");
358 // 358 //
359 } 359 }
360 360
361 if (subType == SubType.Designer) 361 if (subType == SubType.Designer)
362 { 362 {
363 ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file); 363 ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file);
364 364
365 string autogen_name = file.Substring(0, file.LastIndexOf('.')) + ".Designer.cs"; 365 string autogen_name = file.Substring(0, file.LastIndexOf('.')) + ".Designer.cs";
366 string dependent_name = filePath.Substring(0, file.LastIndexOf('.')) + ".cs"; 366 string dependent_name = filePath.Substring(0, file.LastIndexOf('.')) + ".cs";
367 367
368 // Check for a parent .cs file with the same name as this designer file 368 // Check for a parent .cs file with the same name as this designer file
369 if (File.Exists(Helper.NormalizePath(dependent_name))) 369 if (File.Exists(Helper.NormalizePath(dependent_name)))
370 { 370 {
371 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(dependent_name)); 371 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(dependent_name));
372 } 372 }
373 else 373 else
374 { 374 {
375 ps.WriteLine(" <Generator>ResXFileCodeGenerator</Generator>"); 375 ps.WriteLine(" <Generator>ResXFileCodeGenerator</Generator>");
376 ps.WriteLine(" <LastGenOutput>{0}</LastGenOutput>", Path.GetFileName(autogen_name)); 376 ps.WriteLine(" <LastGenOutput>{0}</LastGenOutput>", Path.GetFileName(autogen_name));
377 ps.WriteLine(" <SubType>" + subType + "</SubType>"); 377 ps.WriteLine(" <SubType>" + subType + "</SubType>");
378 } 378 }
379 379
380 ps.WriteLine(" </EmbeddedResource>"); 380 ps.WriteLine(" </EmbeddedResource>");
381 if (File.Exists(Helper.NormalizePath(autogen_name))) 381 if (File.Exists(Helper.NormalizePath(autogen_name)))
382 { 382 {
383 ps.WriteLine(" <Compile Include=\"{0}\">", autogen_name); 383 ps.WriteLine(" <Compile Include=\"{0}\">", autogen_name);
384 //ps.WriteLine(" <DesignTime>True</DesignTime>"); 384 //ps.WriteLine(" <DesignTime>True</DesignTime>");
385 385
386 // If a parent .cs file exists, link this autogen file to it. Otherwise link 386 // If a parent .cs file exists, link this autogen file to it. Otherwise link
387 // to the designer file 387 // to the designer file
388 if (File.Exists(dependent_name)) 388 if (File.Exists(dependent_name))
389 { 389 {
390 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(dependent_name)); 390 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(dependent_name));
391 } 391 }
392 else 392 else
393 { 393 {
394 ps.WriteLine(" <AutoGen>True</AutoGen>"); 394 ps.WriteLine(" <AutoGen>True</AutoGen>");
395 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(filePath)); 395 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(filePath));
396 } 396 }
397 397
398 ps.WriteLine(" </Compile>"); 398 ps.WriteLine(" </Compile>");
399 } 399 }
400 list.Add(autogen_name); 400 list.Add(autogen_name);
401 } 401 }
402 if (subType == SubType.Settings) 402 if (subType == SubType.Settings)
403 { 403 {
404 ps.Write(" <{0} ", project.Files.GetBuildAction(filePath)); 404 ps.Write(" <{0} ", project.Files.GetBuildAction(filePath));
405 ps.WriteLine("Include=\"{0}\">", file); 405 ps.WriteLine("Include=\"{0}\">", file);
406 string fileName = Path.GetFileName(filePath); 406 string fileName = Path.GetFileName(filePath);
407 if (project.Files.GetBuildAction(filePath) == BuildAction.None) 407 if (project.Files.GetBuildAction(filePath) == BuildAction.None)
408 { 408 {
409 ps.WriteLine(" <Generator>SettingsSingleFileGenerator</Generator>"); 409 ps.WriteLine(" <Generator>SettingsSingleFileGenerator</Generator>");
410 ps.WriteLine(" <LastGenOutput>{0}</LastGenOutput>", fileName.Substring(0, fileName.LastIndexOf('.')) + ".Designer.cs"); 410 ps.WriteLine(" <LastGenOutput>{0}</LastGenOutput>", fileName.Substring(0, fileName.LastIndexOf('.')) + ".Designer.cs");
411 } 411 }
412 else 412 else
413 { 413 {
414 ps.WriteLine(" <SubType>Code</SubType>"); 414 ps.WriteLine(" <SubType>Code</SubType>");
415 ps.WriteLine(" <AutoGen>True</AutoGen>"); 415 ps.WriteLine(" <AutoGen>True</AutoGen>");
416 ps.WriteLine(" <DesignTimeSharedInput>True</DesignTimeSharedInput>"); 416 ps.WriteLine(" <DesignTimeSharedInput>True</DesignTimeSharedInput>");
417 string fileNameShort = fileName.Substring(0, fileName.LastIndexOf('.')); 417 string fileNameShort = fileName.Substring(0, fileName.LastIndexOf('.'));
418 string fileNameShorter = fileNameShort.Substring(0, fileNameShort.LastIndexOf('.')); 418 string fileNameShorter = fileNameShort.Substring(0, fileNameShort.LastIndexOf('.'));
419 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(fileNameShorter + ".settings")); 419 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(fileNameShorter + ".settings"));
420 } 420 }
421 ps.WriteLine(" </{0}>", project.Files.GetBuildAction(filePath)); 421 ps.WriteLine(" </{0}>", project.Files.GetBuildAction(filePath));
422 } 422 }
423 else if (subType != SubType.Designer) 423 else if (subType != SubType.Designer)
424 { 424 {
425 string path = Helper.NormalizePath(file); 425 string path = Helper.NormalizePath(file);
426 string path_lower = path.ToLower(); 426 string path_lower = path.ToLower();
427 427
428 if (!list.Contains(filePath)) 428 if (!list.Contains(filePath))
429 { 429 {
430 ps.Write(" <{0} ", project.Files.GetBuildAction(filePath)); 430 ps.Write(" <{0} ", project.Files.GetBuildAction(filePath));
431 431
432 int startPos = 0; 432 int startPos = 0;
433 if (project.Files.GetPreservePath(filePath)) 433 if (project.Files.GetPreservePath(filePath))
434 { 434 {
435 while ((@"./\").IndexOf(file.Substring(startPos, 1)) != -1) 435 while ((@"./\").IndexOf(file.Substring(startPos, 1)) != -1)
436 startPos++; 436 startPos++;
437 437
438 } 438 }
439 else 439 else
440 { 440 {
441 startPos = file.LastIndexOf(Path.GetFileName(path)); 441 startPos = file.LastIndexOf(Path.GetFileName(path));
442 } 442 }
443 443
444 // be sure to write out the path with backslashes so VS recognizes 444 // be sure to write out the path with backslashes so VS recognizes
445 // the file properly. 445 // the file properly.
446 ps.WriteLine("Include=\"{0}\">", file); 446 ps.WriteLine("Include=\"{0}\">", file);
447 447
448 int last_period_index = file.LastIndexOf('.'); 448 int last_period_index = file.LastIndexOf('.');
449 string short_file_name = file.Substring(0, last_period_index); 449 string short_file_name = file.Substring(0, last_period_index);
450 string extension = Path.GetExtension(path); 450 string extension = Path.GetExtension(path);
451 // make this upper case, so that when File.Exists tests for the 451 // make this upper case, so that when File.Exists tests for the
452 // existence of a designer file on a case-sensitive platform, 452 // existence of a designer file on a case-sensitive platform,
453 // it is correctly identified. 453 // it is correctly identified.
454 string designer_format = string.Format(".Designer{0}", extension); 454 string designer_format = string.Format(".Designer{0}", extension);
455 455
456 if (path_lower.EndsWith(designer_format.ToLowerInvariant())) 456 if (path_lower.EndsWith(designer_format.ToLowerInvariant()))
457 { 457 {
458 int designer_index = path.IndexOf(designer_format); 458 int designer_index = path.IndexOf(designer_format);
459 string file_name = path.Substring(0, designer_index); 459 string file_name = path.Substring(0, designer_index);
460 460
461 // There are two corrections to the next lines: 461 // There are two corrections to the next lines:
462 // 1. Fix the connection between a designer file and a form 462 // 1. Fix the connection between a designer file and a form
463 // or usercontrol that don't have an associated resx file. 463 // or usercontrol that don't have an associated resx file.
464 // 2. Connect settings files to associated designer files. 464 // 2. Connect settings files to associated designer files.
465 if (File.Exists(file_name + extension)) 465 if (File.Exists(file_name + extension))
466 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file_name + extension)); 466 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file_name + extension));
467 else if (File.Exists(file_name + ".resx")) 467 else if (File.Exists(file_name + ".resx"))
468 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file_name + ".resx")); 468 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file_name + ".resx"));
469 else if (File.Exists(file_name + ".settings")) 469 else if (File.Exists(file_name + ".settings"))
470 { 470 {
471 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file_name + ".settings")); 471 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file_name + ".settings"));
472 ps.WriteLine(" <AutoGen>True</AutoGen>"); 472 ps.WriteLine(" <AutoGen>True</AutoGen>");
473 ps.WriteLine(" <DesignTimeSharedInput>True</DesignTimeSharedInput>"); 473 ps.WriteLine(" <DesignTimeSharedInput>True</DesignTimeSharedInput>");
474 } 474 }
475 } 475 }
476 else if (subType == SubType.CodeBehind) 476 else if (subType == SubType.CodeBehind)
477 { 477 {
478 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(short_file_name)); 478 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(short_file_name));
479 } 479 }
480 if (project.Files.GetIsLink(filePath)) 480 if (project.Files.GetIsLink(filePath))
481 { 481 {
482 string alias = project.Files.GetLinkPath(filePath); 482 string alias = project.Files.GetLinkPath(filePath);
483 alias += file.Substring(startPos); 483 alias += file.Substring(startPos);
484 alias = Helper.NormalizePath(alias); 484 alias = Helper.NormalizePath(alias);
485 ps.WriteLine(" <Link>{0}</Link>", alias); 485 ps.WriteLine(" <Link>{0}</Link>", alias);
486 } 486 }
487 else if (project.Files.GetBuildAction(filePath) != BuildAction.None) 487 else if (project.Files.GetBuildAction(filePath) != BuildAction.None)
488 { 488 {
489 if (project.Files.GetBuildAction(filePath) != BuildAction.EmbeddedResource) 489 if (project.Files.GetBuildAction(filePath) != BuildAction.EmbeddedResource)
490 { 490 {
491 ps.WriteLine(" <SubType>{0}</SubType>", subType); 491 ps.WriteLine(" <SubType>{0}</SubType>", subType);
492 } 492 }
493 } 493 }
494 494
495 if (project.Files.GetCopyToOutput(filePath) != CopyToOutput.Never) 495 if (project.Files.GetCopyToOutput(filePath) != CopyToOutput.Never)
496 { 496 {
497 ps.WriteLine(" <CopyToOutputDirectory>{0}</CopyToOutputDirectory>", project.Files.GetCopyToOutput(filePath)); 497 ps.WriteLine(" <CopyToOutputDirectory>{0}</CopyToOutputDirectory>", project.Files.GetCopyToOutput(filePath));
498 } 498 }
499 499
500 ps.WriteLine(" </{0}>", project.Files.GetBuildAction(filePath)); 500 ps.WriteLine(" </{0}>", project.Files.GetBuildAction(filePath));
501 } 501 }
502 } 502 }
503 } 503 }
504 504
505 ps.WriteLine(" </ItemGroup>"); 505 ps.WriteLine(" </ItemGroup>");
506 ps.WriteLine(" <Import Project=\"" + toolInfo.ImportProject + "\" />"); 506 ps.WriteLine(" <Import Project=\"" + toolInfo.ImportProject + "\" />");
507 ps.WriteLine(" <PropertyGroup>"); 507 ps.WriteLine(" <PropertyGroup>");
508 ps.WriteLine(" <PreBuildEvent>"); 508 ps.WriteLine(" <PreBuildEvent>");
509 ps.WriteLine(" </PreBuildEvent>"); 509 ps.WriteLine(" </PreBuildEvent>");
510 ps.WriteLine(" <PostBuildEvent>"); 510 ps.WriteLine(" <PostBuildEvent>");
511 ps.WriteLine(" </PostBuildEvent>"); 511 ps.WriteLine(" </PostBuildEvent>");
512 ps.WriteLine(" </PropertyGroup>"); 512 ps.WriteLine(" </PropertyGroup>");
513 ps.WriteLine("</Project>"); 513 ps.WriteLine("</Project>");
514 } 514 }
515 #endregion 515 #endregion
516 516
517 #region User File 517 #region User File
518 518
519 ps = new StreamWriter(projectFile + ".user"); 519 ps = new StreamWriter(projectFile + ".user");
520 using (ps) 520 using (ps)
521 { 521 {
522 // Get the first configuration from the project. 522 // Get the first configuration from the project.
523 ConfigurationNode firstConfiguration = null; 523 ConfigurationNode firstConfiguration = null;
524 524
525 if (project.Configurations.Count > 0) 525 if (project.Configurations.Count > 0)
526 { 526 {
527 firstConfiguration = project.Configurations[0]; 527 firstConfiguration = project.Configurations[0];
528 } 528 }
529 529
530 ps.WriteLine("<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">"); 530 ps.WriteLine("<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">");
531 //ps.WriteLine( "<VisualStudioProject>" ); 531 //ps.WriteLine( "<VisualStudioProject>" );
532 //ps.WriteLine(" <{0}>", toolInfo.XMLTag); 532 //ps.WriteLine(" <{0}>", toolInfo.XMLTag);
533 //ps.WriteLine(" <Build>"); 533 //ps.WriteLine(" <Build>");
534 ps.WriteLine(" <PropertyGroup>"); 534 ps.WriteLine(" <PropertyGroup>");
535 //ps.WriteLine(" <Settings ReferencePath=\"{0}\">", MakeRefPath(project)); 535 //ps.WriteLine(" <Settings ReferencePath=\"{0}\">", MakeRefPath(project));
536 536
537 if (firstConfiguration != null) 537 if (firstConfiguration != null)
538 { 538 {
539 ps.WriteLine(" <Configuration Condition=\" '$(Configuration)' == '' \">{0}</Configuration>", firstConfiguration.Name); 539 ps.WriteLine(" <Configuration Condition=\" '$(Configuration)' == '' \">{0}</Configuration>", firstConfiguration.Name);
540 ps.WriteLine(" <Platform Condition=\" '$(Platform)' == '' \">{0}</Platform>", firstConfiguration.Platform); 540 ps.WriteLine(" <Platform Condition=\" '$(Platform)' == '' \">{0}</Platform>", firstConfiguration.Platform);
541 } 541 }
542 542
543 ps.WriteLine(" <ReferencePath>{0}</ReferencePath>", MakeRefPath(project)); 543 ps.WriteLine(" <ReferencePath>{0}</ReferencePath>", MakeRefPath(project));
544 ps.WriteLine(" <LastOpenVersion>{0}</LastOpenVersion>", ProductVersion); 544 ps.WriteLine(" <LastOpenVersion>{0}</LastOpenVersion>", ProductVersion);
545 ps.WriteLine(" <ProjectView>ProjectFiles</ProjectView>"); 545 ps.WriteLine(" <ProjectView>ProjectFiles</ProjectView>");
546 ps.WriteLine(" <ProjectTrust>0</ProjectTrust>"); 546 ps.WriteLine(" <ProjectTrust>0</ProjectTrust>");
547 ps.WriteLine(" </PropertyGroup>"); 547 ps.WriteLine(" </PropertyGroup>");
548 foreach (ConfigurationNode conf in project.Configurations) 548 foreach (ConfigurationNode conf in project.Configurations)
549 { 549 {
550 ps.Write(" <PropertyGroup"); 550 ps.Write(" <PropertyGroup");
551 ps.Write(" Condition = \" '$(Configuration)|$(Platform)' == '{0}|{1}' \"", conf.Name, conf.Platform); 551 ps.Write(" Condition = \" '$(Configuration)|$(Platform)' == '{0}|{1}' \"", conf.Name, conf.Platform);
552 ps.WriteLine(" />"); 552 ps.WriteLine(" />");
553 } 553 }
554 ps.WriteLine("</Project>"); 554 ps.WriteLine("</Project>");
555 } 555 }
556 #endregion 556 #endregion
557 557
558 kernel.CurrentWorkingDirectory.Pop(); 558 kernel.CurrentWorkingDirectory.Pop();
559 } 559 }
560 560
561 private void WriteSolution(SolutionNode solution, bool writeSolutionToDisk) 561 private void WriteSolution(SolutionNode solution, bool writeSolutionToDisk)
562 { 562 {
563 kernel.Log.Write("Creating {0} solution and project files", VersionName); 563 kernel.Log.Write("Creating {0} solution and project files", VersionName);
564 564
565 foreach (SolutionNode child in solution.Solutions) 565 foreach (SolutionNode child in solution.Solutions)
566 { 566 {
567 kernel.Log.Write("...Creating folder: {0}", child.Name); 567 kernel.Log.Write("...Creating folder: {0}", child.Name);
568 WriteSolution(child, false); 568 WriteSolution(child, false);
569 } 569 }
570 570
571 foreach (ProjectNode project in solution.Projects) 571 foreach (ProjectNode project in solution.Projects)
572 { 572 {
573 kernel.Log.Write("...Creating project: {0}", project.Name); 573 kernel.Log.Write("...Creating project: {0}", project.Name);
574 WriteProject(solution, project); 574 WriteProject(solution, project);
575 } 575 }
576 576
577 foreach (DatabaseProjectNode project in solution.DatabaseProjects) 577 foreach (DatabaseProjectNode project in solution.DatabaseProjects)
578 { 578 {
579 kernel.Log.Write("...Creating database project: {0}", project.Name); 579 kernel.Log.Write("...Creating database project: {0}", project.Name);
580 WriteDatabaseProject(solution, project); 580 WriteDatabaseProject(solution, project);
581 } 581 }
582 582
583 if (writeSolutionToDisk) // only write main solution 583 if (writeSolutionToDisk) // only write main solution
584 { 584 {
585 kernel.Log.Write(""); 585 kernel.Log.Write("");
586 string solutionFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln"); 586 string solutionFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln");
587 587
588 using (StreamWriter ss = new StreamWriter(solutionFile)) 588 using (StreamWriter ss = new StreamWriter(solutionFile))
589 { 589 {
590 kernel.CurrentWorkingDirectory.Push(); 590 kernel.CurrentWorkingDirectory.Push();
591 Helper.SetCurrentDir(Path.GetDirectoryName(solutionFile)); 591 Helper.SetCurrentDir(Path.GetDirectoryName(solutionFile));
592 592
593 ss.WriteLine("Microsoft Visual Studio Solution File, Format Version {0}", SolutionVersion); 593 ss.WriteLine("Microsoft Visual Studio Solution File, Format Version {0}", SolutionVersion);
594 ss.WriteLine(SolutionTag); 594 ss.WriteLine(SolutionTag);
595 595
596 WriteProjectDeclarations(ss, solution, solution); 596 WriteProjectDeclarations(ss, solution, solution);
597 597
598 ss.WriteLine("Global"); 598 ss.WriteLine("Global");
599 599
600 ss.WriteLine("\tGlobalSection(SolutionConfigurationPlatforms) = preSolution"); 600 ss.WriteLine("\tGlobalSection(SolutionConfigurationPlatforms) = preSolution");
601 foreach (ConfigurationNode conf in solution.Configurations) 601 foreach (ConfigurationNode conf in solution.Configurations)
602 { 602 {
603 ss.WriteLine("\t\t{0} = {0}", conf.NameAndPlatform); 603 ss.WriteLine("\t\t{0} = {0}", conf.NameAndPlatform);
604 } 604 }
605 ss.WriteLine("\tEndGlobalSection"); 605 ss.WriteLine("\tEndGlobalSection");
606 606
607 ss.WriteLine("\tGlobalSection(ProjectConfigurationPlatforms) = postSolution"); 607 ss.WriteLine("\tGlobalSection(ProjectConfigurationPlatforms) = postSolution");
608 WriteConfigurationLines(solution.Configurations, solution, ss); 608 WriteConfigurationLines(solution.Configurations, solution, ss);
609 ss.WriteLine("\tEndGlobalSection"); 609 ss.WriteLine("\tEndGlobalSection");
610 610
611 if (solution.Solutions.Count > 0) 611 if (solution.Solutions.Count > 0)
612 { 612 {
613 ss.WriteLine("\tGlobalSection(NestedProjects) = preSolution"); 613 ss.WriteLine("\tGlobalSection(NestedProjects) = preSolution");
614 foreach (SolutionNode embeddedSolution in solution.Solutions) 614 foreach (SolutionNode embeddedSolution in solution.Solutions)
615 { 615 {
616 WriteNestedProjectMap(ss, embeddedSolution); 616 WriteNestedProjectMap(ss, embeddedSolution);
617 } 617 }
618 ss.WriteLine("\tEndGlobalSection"); 618 ss.WriteLine("\tEndGlobalSection");
619 } 619 }
620 620
621 ss.WriteLine("EndGlobal"); 621 ss.WriteLine("EndGlobal");
622 } 622 }
623 623
624 kernel.CurrentWorkingDirectory.Pop(); 624 kernel.CurrentWorkingDirectory.Pop();
625 } 625 }
626 } 626 }
627 627
628 private void WriteProjectDeclarations(TextWriter writer, SolutionNode actualSolution, SolutionNode embeddedSolution) 628 private void WriteProjectDeclarations(TextWriter writer, SolutionNode actualSolution, SolutionNode embeddedSolution)
629 { 629 {
630 foreach (SolutionNode childSolution in embeddedSolution.Solutions) 630 foreach (SolutionNode childSolution in embeddedSolution.Solutions)
631 { 631 {
632 WriteEmbeddedSolution(writer, childSolution); 632 WriteEmbeddedSolution(writer, childSolution);
633 WriteProjectDeclarations(writer, actualSolution, childSolution); 633 WriteProjectDeclarations(writer, actualSolution, childSolution);
634 } 634 }
635 635
636 foreach (ProjectNode project in embeddedSolution.Projects) 636 foreach (ProjectNode project in embeddedSolution.Projects)
637 { 637 {
638 WriteProject(actualSolution, writer, project); 638 WriteProject(actualSolution, writer, project);
639 } 639 }
640 640
641 foreach (DatabaseProjectNode dbProject in embeddedSolution.DatabaseProjects) 641 foreach (DatabaseProjectNode dbProject in embeddedSolution.DatabaseProjects)
642 { 642 {
643 WriteProject(actualSolution, writer, dbProject); 643 WriteProject(actualSolution, writer, dbProject);
644 } 644 }
645 645
646 if (actualSolution.Guid == embeddedSolution.Guid) 646 if (actualSolution.Guid == embeddedSolution.Guid)
647 { 647 {
648 WriteSolutionFiles(actualSolution, writer); 648 WriteSolutionFiles(actualSolution, writer);
649 } 649 }
650 } 650 }
651 651
652 private static void WriteNestedProjectMap(TextWriter writer, SolutionNode embeddedSolution) 652 private static void WriteNestedProjectMap(TextWriter writer, SolutionNode embeddedSolution)
653 { 653 {
654 foreach (ProjectNode project in embeddedSolution.Projects) 654 foreach (ProjectNode project in embeddedSolution.Projects)
655 { 655 {
656 WriteNestedProject(writer, embeddedSolution, project.Guid); 656 WriteNestedProject(writer, embeddedSolution, project.Guid);
657 } 657 }
658 658
659 foreach (DatabaseProjectNode dbProject in embeddedSolution.DatabaseProjects) 659 foreach (DatabaseProjectNode dbProject in embeddedSolution.DatabaseProjects)
660 { 660 {
661 WriteNestedProject(writer, embeddedSolution, dbProject.Guid); 661 WriteNestedProject(writer, embeddedSolution, dbProject.Guid);
662 } 662 }
663 663
664 foreach (SolutionNode child in embeddedSolution.Solutions) 664 foreach (SolutionNode child in embeddedSolution.Solutions)
665 { 665 {
666 WriteNestedProject(writer, embeddedSolution, child.Guid); 666 WriteNestedProject(writer, embeddedSolution, child.Guid);
667 WriteNestedProjectMap(writer, child); 667 WriteNestedProjectMap(writer, child);
668 } 668 }
669 } 669 }
670 670
671 private static void WriteNestedProject(TextWriter writer, SolutionNode solution, Guid projectGuid) 671 private static void WriteNestedProject(TextWriter writer, SolutionNode solution, Guid projectGuid)
672 { 672 {
673 WriteNestedFolder(writer, solution.Guid, projectGuid); 673 WriteNestedFolder(writer, solution.Guid, projectGuid);
674 } 674 }
675 675
676 private static void WriteNestedFolder(TextWriter writer, Guid parentGuid, Guid childGuid) 676 private static void WriteNestedFolder(TextWriter writer, Guid parentGuid, Guid childGuid)
677 { 677 {
678 writer.WriteLine("\t\t{0} = {1}", 678 writer.WriteLine("\t\t{0} = {1}",
679 childGuid.ToString("B").ToUpper(), 679 childGuid.ToString("B").ToUpper(),
680 parentGuid.ToString("B").ToUpper()); 680 parentGuid.ToString("B").ToUpper());
681 } 681 }
682 682
683 private static void WriteConfigurationLines(IEnumerable<ConfigurationNode> configurations, SolutionNode solution, TextWriter ss) 683 private static void WriteConfigurationLines(IEnumerable<ConfigurationNode> configurations, SolutionNode solution, TextWriter ss)
684 { 684 {
685 foreach (ProjectNode project in solution.Projects) 685 foreach (ProjectNode project in solution.Projects)
686 { 686 {
687 foreach (ConfigurationNode conf in configurations) 687 foreach (ConfigurationNode conf in configurations)
688 { 688 {
689 ss.WriteLine("\t\t{0}.{1}.ActiveCfg = {1}", 689 ss.WriteLine("\t\t{0}.{1}.ActiveCfg = {1}",
690 project.Guid.ToString("B").ToUpper(), 690 project.Guid.ToString("B").ToUpper(),
691 conf.NameAndPlatform); 691 conf.NameAndPlatform);
692 692
693 ss.WriteLine("\t\t{0}.{1}.Build.0 = {1}", 693 ss.WriteLine("\t\t{0}.{1}.Build.0 = {1}",
694 project.Guid.ToString("B").ToUpper(), 694 project.Guid.ToString("B").ToUpper(),
695 conf.NameAndPlatform); 695 conf.NameAndPlatform);
696 } 696 }
697 } 697 }
698 698
699 foreach (SolutionNode child in solution.Solutions) 699 foreach (SolutionNode child in solution.Solutions)
700 { 700 {
701 WriteConfigurationLines(configurations, child, ss); 701 WriteConfigurationLines(configurations, child, ss);
702 } 702 }
703 } 703 }
704 704
705 private void WriteSolutionFiles(SolutionNode solution, TextWriter ss) 705 private void WriteSolutionFiles(SolutionNode solution, TextWriter ss)
706 { 706 {
707 if(solution.Files != null && solution.Files.Count > 0) 707 if(solution.Files != null && solution.Files.Count > 0)
708 WriteProject(ss, "Folder", solution.Guid, "Solution Files", "Solution Files", solution.Files); 708 WriteProject(ss, "Folder", solution.Guid, "Solution Files", "Solution Files", solution.Files);
709 } 709 }
710 710
711 private void WriteEmbeddedSolution(TextWriter writer, SolutionNode embeddedSolution) 711 private void WriteEmbeddedSolution(TextWriter writer, SolutionNode embeddedSolution)
712 { 712 {
713 WriteProject(writer, "Folder", embeddedSolution.Guid, embeddedSolution.Name, embeddedSolution.Name, embeddedSolution.Files); 713 WriteProject(writer, "Folder", embeddedSolution.Guid, embeddedSolution.Name, embeddedSolution.Name, embeddedSolution.Files);
714 } 714 }
715 715
716 private void WriteProject(SolutionNode solution, TextWriter ss, ProjectNode project) 716 private void WriteProject(SolutionNode solution, TextWriter ss, ProjectNode project)
717 { 717 {
718 WriteProject(ss, solution, project.Language, project.Guid, project.Name, project.FullPath); 718 WriteProject(ss, solution, project.Language, project.Guid, project.Name, project.FullPath);
719 } 719 }
720 720
721 private void WriteProject(SolutionNode solution, TextWriter ss, DatabaseProjectNode dbProject) 721 private void WriteProject(SolutionNode solution, TextWriter ss, DatabaseProjectNode dbProject)
722 { 722 {
723 if (solution.Files != null && solution.Files.Count > 0) 723 if (solution.Files != null && solution.Files.Count > 0)
724 WriteProject(ss, solution, "Database", dbProject.Guid, dbProject.Name, dbProject.FullPath); 724 WriteProject(ss, solution, "Database", dbProject.Guid, dbProject.Name, dbProject.FullPath);
725 } 725 }
726 726
727 const string ProjectDeclarationBeginFormat = "Project(\"{0}\") = \"{1}\", \"{2}\", \"{3}\""; 727 const string ProjectDeclarationBeginFormat = "Project(\"{0}\") = \"{1}\", \"{2}\", \"{3}\"";
728 const string ProjectDeclarationEndFormat = "EndProject"; 728 const string ProjectDeclarationEndFormat = "EndProject";
729 729
730 private void WriteProject(TextWriter ss, SolutionNode solution, string language, Guid guid, string name, string projectFullPath) 730 private void WriteProject(TextWriter ss, SolutionNode solution, string language, Guid guid, string name, string projectFullPath)
731 { 731 {
732 if (!tools.ContainsKey(language)) 732 if (!tools.ContainsKey(language))
733 throw new UnknownLanguageException("Unknown .NET language: " + language); 733 throw new UnknownLanguageException("Unknown .NET language: " + language);
734 734
735 ToolInfo toolInfo = tools[language]; 735 ToolInfo toolInfo = tools[language];
736 736
737 string path = Helper.MakePathRelativeTo(solution.FullPath, projectFullPath); 737 string path = Helper.MakePathRelativeTo(solution.FullPath, projectFullPath);
738 738
739 path = Helper.MakeFilePath(path, name, toolInfo.FileExtension); 739 path = Helper.MakeFilePath(path, name, toolInfo.FileExtension);
740 740
741 WriteProject(ss, language, guid, name, path); 741 WriteProject(ss, language, guid, name, path);
742 } 742 }
743 743
744 private void WriteProject(TextWriter writer, string language, Guid projectGuid, string name, string location) 744 private void WriteProject(TextWriter writer, string language, Guid projectGuid, string name, string location)
745 { 745 {
746 WriteProject(writer, language, projectGuid, name, location, null); 746 WriteProject(writer, language, projectGuid, name, location, null);
747 } 747 }
748 748
749 private void WriteProject(TextWriter writer, string language, Guid projectGuid, string name, string location, FilesNode files) 749 private void WriteProject(TextWriter writer, string language, Guid projectGuid, string name, string location, FilesNode files)
750 { 750 {
751 if (!tools.ContainsKey(language)) 751 if (!tools.ContainsKey(language))
752 throw new UnknownLanguageException("Unknown .NET language: " + language); 752 throw new UnknownLanguageException("Unknown .NET language: " + language);
753 753
754 ToolInfo toolInfo = tools[language]; 754 ToolInfo toolInfo = tools[language];
755 755
756 writer.WriteLine(ProjectDeclarationBeginFormat, 756 writer.WriteLine(ProjectDeclarationBeginFormat,
757 toolInfo.Guid, 757 toolInfo.Guid,
758 name, 758 name,
759 location, 759 location,
760 projectGuid.ToString("B").ToUpper()); 760 projectGuid.ToString("B").ToUpper());
761 761
762 if (files != null) 762 if (files != null)
763 { 763 {
764 writer.WriteLine("\tProjectSection(SolutionItems) = preProject"); 764 writer.WriteLine("\tProjectSection(SolutionItems) = preProject");
765 765
766 foreach (string file in files) 766 foreach (string file in files)
767 writer.WriteLine("\t\t{0} = {0}", file); 767 writer.WriteLine("\t\t{0} = {0}", file);
768 768
769 writer.WriteLine("\tEndProjectSection"); 769 writer.WriteLine("\tEndProjectSection");
770 } 770 }
771 771
772 writer.WriteLine(ProjectDeclarationEndFormat); 772 writer.WriteLine(ProjectDeclarationEndFormat);
773 } 773 }
774 774
775 private void WriteDatabaseProject(SolutionNode solution, DatabaseProjectNode project) 775 private void WriteDatabaseProject(SolutionNode solution, DatabaseProjectNode project)
776 { 776 {
777 string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, "dbp"); 777 string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, "dbp");
778 IndentedTextWriter ps = new IndentedTextWriter(new StreamWriter(projectFile), " "); 778 IndentedTextWriter ps = new IndentedTextWriter(new StreamWriter(projectFile), " ");
779 779
780 kernel.CurrentWorkingDirectory.Push(); 780 kernel.CurrentWorkingDirectory.Push();
781 781
782 Helper.SetCurrentDir(Path.GetDirectoryName(projectFile)); 782 Helper.SetCurrentDir(Path.GetDirectoryName(projectFile));
783 783
784 using (ps) 784 using (ps)
785 { 785 {
786 ps.WriteLine("# Microsoft Developer Studio Project File - Database Project"); 786 ps.WriteLine("# Microsoft Developer Studio Project File - Database Project");
787 ps.WriteLine("Begin DataProject = \"{0}\"", project.Name); 787 ps.WriteLine("Begin DataProject = \"{0}\"", project.Name);
788 ps.Indent++; 788 ps.Indent++;
789 ps.WriteLine("MSDTVersion = \"80\""); 789 ps.WriteLine("MSDTVersion = \"80\"");
790 // TODO: Use the project.Files property 790 // TODO: Use the project.Files property
791 if (ContainsSqlFiles(Path.GetDirectoryName(projectFile))) 791 if (ContainsSqlFiles(Path.GetDirectoryName(projectFile)))
792 WriteDatabaseFoldersAndFiles(ps, Path.GetDirectoryName(projectFile)); 792 WriteDatabaseFoldersAndFiles(ps, Path.GetDirectoryName(projectFile));
793 793
794 ps.WriteLine("Begin DBRefFolder = \"Database References\""); 794 ps.WriteLine("Begin DBRefFolder = \"Database References\"");
795 ps.Indent++; 795 ps.Indent++;
796 foreach (DatabaseReferenceNode reference in project.References) 796 foreach (DatabaseReferenceNode reference in project.References)
797 { 797 {
798 ps.WriteLine("Begin DBRefNode = \"{0}\"", reference.Name); 798 ps.WriteLine("Begin DBRefNode = \"{0}\"", reference.Name);
799 ps.Indent++; 799 ps.Indent++;
800 ps.WriteLine("ConnectStr = \"{0}\"", reference.ConnectionString); 800 ps.WriteLine("ConnectStr = \"{0}\"", reference.ConnectionString);
801 ps.WriteLine("Provider = \"{0}\"", reference.ProviderId.ToString("B").ToUpper()); 801 ps.WriteLine("Provider = \"{0}\"", reference.ProviderId.ToString("B").ToUpper());
802 //ps.WriteLine("Colorizer = 5"); 802 //ps.WriteLine("Colorizer = 5");
803 ps.Indent--; 803 ps.Indent--;
804 ps.WriteLine("End"); 804 ps.WriteLine("End");
805 } 805 }
806 ps.Indent--; 806 ps.Indent--;
807 ps.WriteLine("End"); 807 ps.WriteLine("End");
808 ps.Indent--; 808 ps.Indent--;
809 ps.WriteLine("End"); 809 ps.WriteLine("End");
810 810
811 ps.Flush(); 811 ps.Flush();
812 } 812 }
813 813
814 kernel.CurrentWorkingDirectory.Pop(); 814 kernel.CurrentWorkingDirectory.Pop();
815 } 815 }
816 816
817 private static bool ContainsSqlFiles(string folder) 817 private static bool ContainsSqlFiles(string folder)
818 { 818 {
819 if(Directory.GetFiles(folder, "*.sql").Length > 0) 819 if(Directory.GetFiles(folder, "*.sql").Length > 0)
820 return true; // if the folder contains 1 .sql file, that's good enough 820 return true; // if the folder contains 1 .sql file, that's good enough
821 821
822 foreach (string child in Directory.GetDirectories(folder)) 822 foreach (string child in Directory.GetDirectories(folder))
823 { 823 {
824 if (ContainsSqlFiles(child)) 824 if (ContainsSqlFiles(child))
825 return true; // if 1 child folder contains a .sql file, still good enough 825 return true; // if 1 child folder contains a .sql file, still good enough
826 } 826 }
827 827
828 return false; 828 return false;
829 } 829 }
830 830
831 private static void WriteDatabaseFoldersAndFiles(IndentedTextWriter writer, string folder) 831 private static void WriteDatabaseFoldersAndFiles(IndentedTextWriter writer, string folder)
832 { 832 {
833 foreach (string child in Directory.GetDirectories(folder)) 833 foreach (string child in Directory.GetDirectories(folder))
834 { 834 {
835 if (ContainsSqlFiles(child)) 835 if (ContainsSqlFiles(child))
836 { 836 {
837 writer.WriteLine("Begin Folder = \"{0}\"", Path.GetFileName(child)); 837 writer.WriteLine("Begin Folder = \"{0}\"", Path.GetFileName(child));
838 writer.Indent++; 838 writer.Indent++;
839 WriteDatabaseFoldersAndFiles(writer, child); 839 WriteDatabaseFoldersAndFiles(writer, child);
840 writer.Indent--; 840 writer.Indent--;
841 writer.WriteLine("End"); 841 writer.WriteLine("End");
842 } 842 }
843 } 843 }
844 foreach (string file in Directory.GetFiles(folder, "*.sql")) 844 foreach (string file in Directory.GetFiles(folder, "*.sql"))
845 { 845 {
846 writer.WriteLine("Script = \"{0}\"", Path.GetFileName(file)); 846 writer.WriteLine("Script = \"{0}\"", Path.GetFileName(file));
847 } 847 }
848 } 848 }
849 849
850 private void CleanProject(ProjectNode project) 850 private void CleanProject(ProjectNode project)
851 { 851 {
852 kernel.Log.Write("...Cleaning project: {0}", project.Name); 852 kernel.Log.Write("...Cleaning project: {0}", project.Name);
853 853
854 ToolInfo toolInfo = tools[project.Language]; 854 ToolInfo toolInfo = tools[project.Language];
855 string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); 855 string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension);
856 string userFile = projectFile + ".user"; 856 string userFile = projectFile + ".user";
857 857
858 Helper.DeleteIfExists(projectFile); 858 Helper.DeleteIfExists(projectFile);
859 Helper.DeleteIfExists(userFile); 859 Helper.DeleteIfExists(userFile);
860 } 860 }
861 861
862 private void CleanSolution(SolutionNode solution) 862 private void CleanSolution(SolutionNode solution)
863 { 863 {
864 kernel.Log.Write("Cleaning {0} solution and project files", VersionName, solution.Name); 864 kernel.Log.Write("Cleaning {0} solution and project files", VersionName, solution.Name);
865 865
866 string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln"); 866 string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln");
867 string suoFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "suo"); 867 string suoFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "suo");
868 868
869 Helper.DeleteIfExists(slnFile); 869 Helper.DeleteIfExists(slnFile);
870 Helper.DeleteIfExists(suoFile); 870 Helper.DeleteIfExists(suoFile);
871 871
872 foreach (ProjectNode project in solution.Projects) 872 foreach (ProjectNode project in solution.Projects)
873 { 873 {
874 CleanProject(project); 874 CleanProject(project);
875 } 875 }
876 876
877 kernel.Log.Write(""); 877 kernel.Log.Write("");
878 } 878 }
879 879
880 #endregion 880 #endregion
881 881
882 #region ITarget Members 882 #region ITarget Members
883 883
884 /// <summary> 884 /// <summary>
885 /// Writes the specified kern. 885 /// Writes the specified kern.
886 /// </summary> 886 /// </summary>
887 /// <param name="kern">The kern.</param> 887 /// <param name="kern">The kern.</param>
888 public virtual void Write(Kernel kern) 888 public virtual void Write(Kernel kern)
889 { 889 {
890 if (kern == null) 890 if (kern == null)
891 { 891 {
892 throw new ArgumentNullException("kern"); 892 throw new ArgumentNullException("kern");
893 } 893 }
894 kernel = kern; 894 kernel = kern;
895 foreach (SolutionNode sol in kernel.Solutions) 895 foreach (SolutionNode sol in kernel.Solutions)
896 { 896 {
897 WriteSolution(sol, true); 897 WriteSolution(sol, true);
898 } 898 }
899 kernel = null; 899 kernel = null;
900 } 900 }
901 901
902 /// <summary> 902 /// <summary>
903 /// Cleans the specified kern. 903 /// Cleans the specified kern.
904 /// </summary> 904 /// </summary>
905 /// <param name="kern">The kern.</param> 905 /// <param name="kern">The kern.</param>
906 public virtual void Clean(Kernel kern) 906 public virtual void Clean(Kernel kern)
907 { 907 {
908 if (kern == null) 908 if (kern == null)
909 { 909 {
910 throw new ArgumentNullException("kern"); 910 throw new ArgumentNullException("kern");
911 } 911 }
912 kernel = kern; 912 kernel = kern;
913 foreach (SolutionNode sol in kernel.Solutions) 913 foreach (SolutionNode sol in kernel.Solutions)
914 { 914 {
915 CleanSolution(sol); 915 CleanSolution(sol);
916 } 916 }
917 kernel = null; 917 kernel = null;
918 } 918 }
919 919
920 #endregion 920 #endregion
921 } 921 }
922} 922}