feature: add support for Visual Studio as external tool (#648)

* feature: support Visual Studio external tool on Windows
* feature: when opening in Visual Studio, try to locate solution file
This commit is contained in:
Dmitrij D. Czarkoff 2024-11-04 01:22:16 +00:00 committed by GitHub
parent fba84c8297
commit 1d0098703e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 55 additions and 6 deletions

View file

@ -134,6 +134,7 @@ namespace SourceGit.Native
finder.Fleet(() => $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}\\Programs\\Fleet\\Fleet.exe");
finder.FindJetBrainsFromToolbox(() => $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}\\JetBrains\\Toolbox");
finder.SublimeText(FindSublimeText);
finder.VisualStudio(FindVisualStudio);
return finder.Founded;
}
@ -313,6 +314,25 @@ namespace SourceGit.Native
return string.Empty;
}
private string FindVisualStudio()
{
var localMachine = Microsoft.Win32.RegistryKey.OpenBaseKey(
Microsoft.Win32.RegistryHive.LocalMachine,
Microsoft.Win32.RegistryView.Registry64);
// Get default class for VisualStudio.Launcher.sln - the handler for *.sln files
if (localMachine.OpenSubKey(@"SOFTWARE\Classes\VisualStudio.Launcher.sln\CLSID") is Microsoft.Win32.RegistryKey launcher)
{
// Get actual path to the executable
if (launcher.GetValue(string.Empty) is string CLSID && localMachine.OpenSubKey(@$"SOFTWARE\Classes\CLSID\{CLSID}\LocalServer32") is Microsoft.Win32.RegistryKey devenv && devenv.GetValue(string.Empty) is string localServer32)
{
return localServer32!.Trim('\"');
}
}
return string.Empty;
}
#endregion
private void OpenFolderAndSelectFile(string folderPath)