Fix VisualStudioInstance.GetInstances() to be sorted from newest to oldest
(cherry picked from commit 6eaecc8793)
This commit is contained in:
committed by
Wojtek Figat
parent
7539504a8c
commit
da08b18ec5
@@ -12,7 +12,7 @@ namespace Flax.Build.Projects.VisualStudio
|
||||
/// <summary>
|
||||
/// The Visual Studio instance utility.
|
||||
/// </summary>
|
||||
public sealed class VisualStudioInstance
|
||||
public sealed class VisualStudioInstance : IComparable<VisualStudioInstance>
|
||||
{
|
||||
private static List<VisualStudioInstance> _installDirs;
|
||||
private static int _hasFlaxVS;
|
||||
@@ -173,9 +173,32 @@ namespace Flax.Build.Projects.VisualStudio
|
||||
}
|
||||
}
|
||||
|
||||
// Sort from the latest to the oldest
|
||||
_installDirs.Sort();
|
||||
|
||||
foreach (var e in _installDirs)
|
||||
Log.Verbose($"Found {e.Version} at {e.Path}");
|
||||
return _installDirs;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public int CompareTo(VisualStudioInstance other)
|
||||
{
|
||||
if (Version == other.Version)
|
||||
return Path.CompareTo(other.Path);
|
||||
return (int)Version < (int)other.Version ? 1 : -1;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Path.GetHashCode();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{Version} at {Path}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user