-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgram.cs
More file actions
158 lines (145 loc) · 5.28 KB
/
Program.cs
File metadata and controls
158 lines (145 loc) · 5.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Diagnostics;
using System.Reflection;
using System.Xml.Linq;
using MSBuildTools;
namespace SolutionBuilder
{
/// <summary>
/// This creates a solution file.
/// This tool searches for all project files in a given directory and then
/// parses each file examining dependencies. It then generates a solution file
/// with those dependencies spelled out.
/// This does 100% of the work of finding the dependencies, and there is no need to edit anything afterwards.
/// </summary>
class Program
{
static void PrintHelp()
{
Console.WriteLine("SolutionBuilder <directory> <xml build list> <output_solution_file> <configuration> <platform> [xml build list] [ProjectItemsName]");
Console.WriteLine("<directory> - The directory to search for .vcxproj and .csproj files. This will search recursively.");
Console.WriteLine("<output_solution_file> - The full path to save the solution file that is generated");
Console.WriteLine("<configuration> - The configuration needed to build against");
Console.WriteLine("<platform> - The platform needed to build against");
Console.WriteLine("[xml build list] - Optional: The full path to an MSBuild file containing an official list of projects to build.");
Console.WriteLine("[ProjectItemsName] - Optional: Required if the xml build list option is specified. The item in the itemgroup for which to pull the official build list from");
}
static void Main(string[] args)
{
DirectoryInfo search_dir;
FileInfo output_solution_file;
String Configuration;
String Platform;
bool build_parallel = false;
if ((args.Length == 2) && (String.Compare(args[1], "ProjectRefConvert", StringComparison.OrdinalIgnoreCase) == 0))
{
search_dir = new DirectoryInfo(args[0]);
if (!search_dir.Exists)
{
PrintHelp();
return;
}
var sb = new MSBuildTools.SolutionBuilder(search_dir, "AnyCPU", "Debug", build_parallel);
sb.WriteProjectReferences(OperationType.SearchDirectory, "Reference");
}
else if (String.Compare(args[0], "ProjectRefConvert", StringComparison.OrdinalIgnoreCase) == 0)
{
if (args.Length == 3)
{
var itemsFile = new FileInfo(args[1]);
string itemsName = args[2];
if (itemsFile.Exists)
{
var sb = new MSBuildTools.SolutionBuilder("AnyCPU", "Debug", itemsFile, itemsName);
sb.WriteProjectReferencesForFile();
}
}
}
else if ((args.Length >= 2) && (String.Compare(args[0], "FindOrphans", StringComparison.OrdinalIgnoreCase) == 0))
{
search_dir = new DirectoryInfo(args[1]);
if (!search_dir.Exists)
{
PrintHelp();
return;
}
var finder = new MSBuildTools.FindOrphans(search_dir);
int count = finder.Find();
Console.WriteLine("Found {0} orphaned files", count);
if ((args.Length == 3) && (String.Compare(args[2], "fix", StringComparison.OrdinalIgnoreCase) == 0))
{
finder.FixItemLists();
}
}
else if (args.Length == 4)
{
search_dir = new DirectoryInfo(args[0]);
if (!search_dir.Exists)
{
PrintHelp();
return;
}
output_solution_file = new FileInfo(args[1]);
Configuration = args[2];
Platform = args[3];
var sb = new MSBuildTools.SolutionBuilder(search_dir, Platform, Configuration, build_parallel);
sb.WriteSolution(output_solution_file.FullName, false);
sb.WriteDGML(search_dir.FullName, Path.GetFileNameWithoutExtension(output_solution_file.FullName));
}
else if (args.Length == 5)
{
search_dir = new DirectoryInfo(args[0]);
if (!search_dir.Exists)
{
PrintHelp();
return;
}
output_solution_file = new FileInfo(args[1]);
Configuration = args[2];
Platform = args[3];
FileInfo build_list = new FileInfo(args[4]);
if (!build_list.Exists)
{
Console.WriteLine("Error! The file {0} does NOT exist.", build_list.FullName);
PrintHelp();
return;
}
var sb = new MSBuildTools.SolutionBuilder(search_dir, Platform, Configuration, build_list);
sb.WriteSolution(output_solution_file.FullName, false);
sb.WriteDGML(search_dir.FullName, Path.GetFileNameWithoutExtension(output_solution_file.FullName));
}
else if (args.Length == 6)
{
search_dir = new DirectoryInfo(args[0]);
if (!search_dir.Exists)
{
PrintHelp();
return;
}
output_solution_file = new FileInfo(args[1]);
Configuration = args[2];
Platform = args[3];
FileInfo xml_build_list = new FileInfo(args[4]);
String ProjectsItemName = args[5];
if (!xml_build_list.Exists)
{
Console.WriteLine("Error! The file {0} does NOT exist.", xml_build_list.FullName);
PrintHelp();
return;
}
var sb = new MSBuildTools.SolutionBuilder(search_dir, Platform, Configuration, xml_build_list, ProjectsItemName, build_parallel);
sb.WriteSolution(output_solution_file.FullName, false);
sb.WriteDGML(search_dir.FullName, Path.GetFileNameWithoutExtension(output_solution_file.FullName));
}
else
{
PrintHelp();
return;
}
}
}
}