Add-on components that enhance and customize the Visual Studio integrated development environment
As you don’t know where the user installed the official dot sdk, you would need to do a path search.
public static string FindDotNetPath()
{
// Search for 'dotnet.exe' in the directories listed in the PATH environment variable
var pathEnv = Environment.GetEnvironmentVariable("PATH");
var paths = pathEnv?.Split(Path.PathSeparator);
return paths?.Select(p => Path.Combine(p, "dotnet.exe"))
.FirstOrDefault(File.Exists);
}
But this is no better than letting the os find the .exe. If you really need to know the users official install, then your extension needs a setting that the user enters the path to sdk.