Does MSBuild apply a sort to globbing?
Before moving forward with this, can we answer the question I had in the issue --
it's curious that this case turns out to be unstable, but things like globbing do not. Does MSBuild apply a sort to globbing?
I'd like to make sure we're be consistent in how we apply these fixes and we don't miss something about how things are supposed to be working. It's good that we found the source of where these items are raised from the file-system, but the lack of other uses of OrderBy wrapping calls to IFileSystem in this codebase makes me feel we are still missing something.
Originally posted by @ericstj in https://github.com/dotnet/msbuild/issues/12811#issuecomment-3572095435
Well my whole point of that question was that it must apply a sort of some kind if the only source of non-determinism in the build of the entire dotnet product was this one place in RAR that calls EnumerateDirectories. That tells me that we might be missing something by sprinkling a sort on the call to EnumerateDirectories. Either we need to do that to every Enumerate call, or we need to use a different approach (that matches what's done for globbing) to fix this consistently.
Be careful with adding sorts, since just sorting something burns cycles, and while it does give a stable result - it can give a different result than before the sort was added.