|
10 | 10 | using System.Linq; |
11 | 11 | using System.Runtime.InteropServices; |
12 | 12 | using Microsoft.Deployment.DotNet.Releases; |
| 13 | +using Microsoft.DotNet.NativeWrapper; |
13 | 14 |
|
14 | 15 | namespace Microsoft.Dotnet.Installation.Internal; |
15 | 16 |
|
@@ -401,47 +402,11 @@ public void Dispose() |
401 | 402 | } |
402 | 403 | } |
403 | 404 |
|
404 | | - // TODO: InstallerOrchestratorSingleton also checks existing installs via the manifest. Which should we use and where? |
405 | | - // This should be cached and more sophisticated based on vscode logic in the future |
| 405 | + // TODO: InstallerOrchestratorSingleton also checks existing installs via the manifest. Which should we use and where? |
406 | 406 | private IEnumerable<ReleaseVersion> GetExistingSdkVersions(DotnetInstallRoot installRoot) |
407 | 407 | { |
408 | | - if (installRoot.Path == null) |
409 | | - return Enumerable.Empty<ReleaseVersion>(); |
410 | | - |
411 | | - var dotnetExe = Path.Combine(installRoot.Path, DnupUtilities.GetDotnetExeName()); |
412 | | - if (!File.Exists(dotnetExe)) |
413 | | - return Enumerable.Empty<ReleaseVersion>(); |
414 | | - |
415 | | - try |
416 | | - { |
417 | | - var process = new System.Diagnostics.Process(); |
418 | | - process.StartInfo.FileName = dotnetExe; |
419 | | - process.StartInfo.Arguments = "--list-sdks"; |
420 | | - process.StartInfo.RedirectStandardOutput = true; |
421 | | - process.StartInfo.UseShellExecute = false; |
422 | | - process.StartInfo.CreateNoWindow = true; |
423 | | - process.Start(); |
424 | | - var output = process.StandardOutput.ReadToEnd(); |
425 | | - process.WaitForExit(); |
426 | | - |
427 | | - var versions = new List<ReleaseVersion>(); |
428 | | - foreach (var line in output.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)) |
429 | | - { |
430 | | - var parts = line.Split(' '); |
431 | | - if (parts.Length > 0) |
432 | | - { |
433 | | - var versionStr = parts[0]; |
434 | | - if (ReleaseVersion.TryParse(versionStr, out var version)) |
435 | | - { |
436 | | - versions.Add(version); |
437 | | - } |
438 | | - } |
439 | | - } |
440 | | - return versions; |
441 | | - } |
442 | | - catch |
443 | | - { |
444 | | - return []; |
445 | | - } |
| 408 | + var bundleProvider = new NETBundlesNativeWrapper(); |
| 409 | + NetEnvironmentInfo environmentInfo = bundleProvider.GetDotnetEnvironmentInfo(installRoot.Path); |
| 410 | + return environmentInfo.SdkInfo.Select(sdk => sdk.Version); |
446 | 411 | } |
447 | 412 | } |
0 commit comments