feature: ignore case when finding visual studio solution file

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2024-11-04 11:54:18 +08:00
parent 921b8599df
commit 310c786693
No known key found for this signature in database

View file

@ -353,23 +353,26 @@ namespace SourceGit.Native
private string GenerateCommandlineArgsForVisualStudio(string repo) private string GenerateCommandlineArgsForVisualStudio(string repo)
{ {
var sln = FindVSSolutionFile(repo, 4); var sln = FindVSSolutionFile(new DirectoryInfo(repo), 4);
return string.IsNullOrEmpty(sln) ? $"\"{repo}\"" : $"\"{sln}\""; return string.IsNullOrEmpty(sln) ? $"\"{repo}\"" : $"\"{sln}\"";
} }
private string FindVSSolutionFile(string path, int leftDepth) private string FindVSSolutionFile(DirectoryInfo dir, int leftDepth)
{ {
var found = Directory.GetFiles(path, "*.sln", SearchOption.TopDirectoryOnly); var files = dir.GetFiles();
if (found != null && found.Length > 0) foreach (var f in files)
return Path.GetFullPath(found[0]); {
if (f.Name.EndsWith(".sln", StringComparison.OrdinalIgnoreCase))
return f.FullName;
}
if (leftDepth <= 0) if (leftDepth <= 0)
return null; return null;
var subfolders = Directory.GetDirectories(path); var subDirs = dir.GetDirectories();
foreach (var subfolder in subfolders) foreach (var subDir in subDirs)
{ {
var first = FindVSSolutionFile(subfolder, leftDepth - 1); var first = FindVSSolutionFile(subDir, leftDepth - 1);
if (!string.IsNullOrEmpty(first)) if (!string.IsNullOrEmpty(first))
return first; return first;
} }