From 68ff6f13b2bf16a5ef9047299b3718bc69b3fdbe Mon Sep 17 00:00:00 2001 From: Erik Parker Date: Fri, 12 Mar 2021 10:26:06 -0600 Subject: [PATCH] msvs: Update project sorting in visual studio solution file In order to correctly set a default project in visual studio any folders must be listed at the top of the solution file. This change ensures that any folders included in generated solutions sort to the top of the .sln file. The default project, if one exists, will be located after the folders. Note that it should also be correct to place the default at the top of the file, followed by any folders. --- waflib/extras/msvs.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/waflib/extras/msvs.py b/waflib/extras/msvs.py index 8aa2db0b..03b739f8 100644 --- a/waflib/extras/msvs.py +++ b/waflib/extras/msvs.py @@ -787,8 +787,12 @@ class msvs_generator(BuildContext): self.collect_dirs() default_project = getattr(self, 'default_project', None) def sortfun(x): - if x.name == default_project: + # folders should sort to the top + if getattr(x, 'VS_GUID_SOLUTIONFOLDER', None): return '' + # followed by the default project + elif x.name == default_project: + return ' ' return getattr(x, 'path', None) and x.path.win32path() or x.name self.all_projects.sort(key=sortfun)