1: class Program
2:
3: {
4:
5: static void Main(string[] args)
6:
7: {
8:
9: string Text = Utilities.IO.FileManager.GetFileContents(@"Utilities project location");
10:
11: XmlDocument Doc = new XmlDocument();
12:
13:
14:
15: Doc.LoadXml(Text);
16:
17: XmlNamespaceManager Manager = new XmlNamespaceManager(Doc.NameTable);
18:
19: Manager.AddNamespace("Util", "http://schemas.microsoft.com/developer/msbuild/2003");
20:
21: XmlNodeList Nodes = Doc.DocumentElement.SelectNodes("//Util:ItemGroup/Util:Compile", Manager);
22:
23: List<Project> Projects = new List<Project>();
24:
25: foreach (XmlNode Node in Nodes)
26:
27: {
28:
29: string Path = Node.Attributes["Include"].InnerText;
30:
31: string[] Splitter = new string[] { "\\" };
32:
33: string[] PathItems = Path.Split(Splitter, StringSplitOptions.None);
34:
35: if (Projects.Find(x => x.Name == PathItems[0]) != null)
36:
37: {
38:
39: Projects.Find(x => x.Name == PathItems[0]).Includes.Add(Path);
40:
41: }
42:
43: else if (PathItems[0] != "Properties")
44:
45: {
46:
47: Project Temp = new Project();
48:
49: Temp.Includes = new List<string>();
50:
51: Temp.Name = PathItems[0];
52:
53: Temp.Includes.Add(Path);
54:
55: Projects.Add(Temp);
56:
57: }
58:
59: }
60:
61: foreach (Project Project in Projects)
62:
63: {
64:
65: Utilities.IO.FileManager.CopyDirectory("Utilities directory" + Project.Name, "Utilities directory"+"." + Project.Name + "\\" + Project.Name, true, Utilities.IO.CopyOptions.CopyIfNewer);
66:
67: }
68:
69: foreach (Project Project in Projects)
70:
71: {
72:
73: if (Utilities.IO.FileManager.FileExists("Utilities directory"+"." + Project.Name + "\\Utilities." + Project.Name + ".csproj"))
74:
75: {
76:
77: bool Changed = false;
78:
79: string ProjectText = Utilities.IO.FileManager.GetFileContents("Utilities directory"+"." + Project.Name + "\\Utilities." + Project.Name + ".csproj");
80:
81: XmlDocument ProjectDoc = new XmlDocument();
82:
83:
84:
85: ProjectDoc.LoadXml(ProjectText);
86:
87: XmlNamespaceManager Manager2 = new XmlNamespaceManager(ProjectDoc.NameTable);
88:
89: Manager2.AddNamespace("Util", "http://schemas.microsoft.com/developer/msbuild/2003");
90:
91: Nodes = ProjectDoc.DocumentElement.SelectNodes("//Util:ItemGroup/Util:Compile", Manager2);
92:
93: foreach (XmlNode Node in Nodes)
94:
95: {
96:
97: string Path = Node.Attributes["Include"].InnerText;
98:
99: if (Project.Includes.Contains(Path))
100:
101: {
102:
103: Project.Includes.Remove(Path);
104:
105: }
106:
107: else if (!Path.StartsWith("Properties"))
108:
109: {
110:
111: Node.ParentNode.RemoveChild(Node);
112:
113: Utilities.IO.FileManager.Delete("Utilities directory"+"." + Project.Name + "\\" + Path);
114:
115: Changed = true;
116:
117: }
118:
119: }
120:
121:
122:
123: XmlNode Parent = Nodes[0].ParentNode;
124:
125: foreach (string Path in Project.Includes)
126:
127: {
128:
129: XmlElement Node = ProjectDoc.CreateElement("Compile", "http://schemas.microsoft.com/developer/msbuild/2003");
130:
131: Node.RemoveAllAttributes();
132:
133: XmlAttribute Attribute = ProjectDoc.CreateAttribute("Include");
134:
135: Node.Attributes.Append(Attribute);
136:
137: Attribute.InnerText = Path;
138:
139: Parent.AppendChild(Node);
140:
141: Changed = true;
142:
143: }
144:
145: if (Changed)
146:
147: {
148:
149: ProjectDoc.Save("Utilities directory"+"." + Project.Name + "\\Utilities." + Project.Name + ".csproj");
150:
151: }
152:
153: }
154:
155: }
156:
157: }
158:
159: }
160:
161:
162:
163: public class Project
164:
165: {
166:
167: public string Name { get; set; }
168:
169: public List<string> Includes { get; set; }
170:
171: }