0
|
1 import argparse
|
|
2 import logging
|
|
3 from logutil import setup_logging
|
|
4 from vsutil import SolutionCache
|
|
5
|
|
6
|
|
7 logger = logging.getLogger(__name__)
|
|
8
|
|
9
|
|
10 def main(args=None):
|
|
11 parser = argparse.ArgumentParser()
|
|
12 parser.add_argument('solution',
|
|
13 help="The path to the Visual Studio solution file.")
|
|
14 parser.add_argument('-c', '--cache',
|
|
15 help="The path to the solution cache.")
|
|
16 parser.add_argument('-f', '--full-names',
|
|
17 action='store_true',
|
|
18 help="Print full names for nested projects.")
|
|
19 parser.add_argument('-v', '--verbose',
|
|
20 action='store_true',
|
|
21 help="Show verbose information.")
|
|
22 args = parser.parse_args(args)
|
|
23 setup_logging(args.verbose)
|
|
24
|
|
25 cache, _ = SolutionCache.load_or_rebuild(args.solution, args.cache)
|
|
26 slnobj = cache.slnobj
|
|
27 logger.debug("Found {0} projects:".format(len(slnobj.projects)))
|
|
28
|
|
29 non_folder_projs = list(filter(lambda p: not p.is_folder,
|
|
30 slnobj.projects))
|
|
31 if args.full_names:
|
|
32 parenting = {}
|
|
33 nesting_sec = slnobj.globalsection("NestedProjects")
|
|
34 if nesting_sec:
|
|
35 for entry in nesting_sec.entries:
|
|
36 child_guid, parent_guid = (entry.name.strip('{}'),
|
|
37 entry.value.strip('{}'))
|
|
38 child = slnobj.find_project_by_guid(child_guid, False)
|
|
39 parent = slnobj.find_project_by_guid(parent_guid, False)
|
|
40 parenting[child] = parent
|
|
41
|
|
42 for p in non_folder_projs:
|
|
43 full_name = p.name
|
|
44 cur_p = p
|
|
45 while True:
|
|
46 cur_p = parenting.get(cur_p)
|
|
47 if not cur_p:
|
|
48 break
|
|
49 full_name = cur_p.name + "\\" + full_name
|
|
50 print(full_name)
|
|
51 else:
|
|
52 for p in non_folder_projs:
|
|
53 print(p.name)
|
|
54
|
|
55
|
|
56 if __name__ == '__main__':
|
|
57 main()
|
|
58
|