Index: tools/gn/visual_studio_writer.cc |
diff --git a/tools/gn/visual_studio_writer.cc b/tools/gn/visual_studio_writer.cc |
index 968e046b72fb129979ea276b5fe8cb0f5cc0aabb..951b81dc2e4ee90dc5b084cd2b152163de00a314 100644 |
--- a/tools/gn/visual_studio_writer.cc |
+++ b/tools/gn/visual_studio_writer.cc |
@@ -236,6 +236,13 @@ bool VisualStudioWriter::RunAndWriteFiles(const BuildSettings* build_settings, |
return false; |
} |
+ // Sort projects so they appear always in the same order in solution file. |
+ // Otherwise solution file is rewritten and reloaded by Visual Studio. |
+ std::sort(writer.projects_.begin(), writer.projects_.end(), |
+ [](const SolutionEntry* a, const SolutionEntry* b) { |
+ return a->path < b->path; |
+ }); |
+ |
writer.ResolveSolutionFolders(); |
return writer.WriteSolutionFile(err); |
} |