From 7caaf4163247016ee3eb673dab9abce1b76b029f Mon Sep 17 00:00:00 2001 From: Saif Alaqqad Date: Fri, 26 Jul 2024 08:54:10 +0300 Subject: [PATCH] Remove RuntimeVersion option Since the option doesnt actually affect which runtime is used when running the dashboard and only affected the downloader, it should probably be added later as a downloader option --- .../AspireDashboardManager.cs | 35 +++++-------------- .../AspireDashboardOptions.cs | 8 ----- src/AspireRunner.Tool/Arguments.cs | 3 -- src/AspireRunner.Tool/Program.cs | 4 +-- 4 files changed, 9 insertions(+), 41 deletions(-) diff --git a/src/AspireRunner.Core/AspireDashboardManager.cs b/src/AspireRunner.Core/AspireDashboardManager.cs index 3f879e0..9eef0ca 100644 --- a/src/AspireRunner.Core/AspireDashboardManager.cs +++ b/src/AspireRunner.Core/AspireDashboardManager.cs @@ -62,13 +62,6 @@ public async Task GetDashboardAsync(AspireDashboardOptions opti throw new ApplicationException($"The dashboard requires version '{AspireDashboard.MinimumRuntimeVersion}' or newer of the '{AspireDashboard.AspRuntimeName}' runtime"); } - var preferredVersion = Version.TryParse(options.Runner.RuntimeVersion, out var rv) ? rv : null; - if (preferredVersion != null && !installedRuntimes.Any(v => v.IsCompatibleWith(preferredVersion))) - { - _logger.LogWarning("The specified runtime version '{RuntimeVersion}' is either not installed or incompatible with the dashboard, falling back to the latest installed version", preferredVersion); - preferredVersion = null; - } - var (isInstalled, isWorkload) = await IsInstalledAsync(); if (!isInstalled) { @@ -78,7 +71,7 @@ public async Task GetDashboardAsync(AspireDashboardOptions opti } _logger.LogWarning("The Aspire Dashboard is not installed, downloading the latest compatible version..."); - var latestVersion = await FetchLatestVersionAsync(installedRuntimes, preferredVersion); + var latestVersion = await FetchLatestVersionAsync(installedRuntimes); var downloadedVersion = await InstallAsync(installedRuntimes, latestVersion); if (downloadedVersion == null) @@ -91,11 +84,11 @@ public async Task GetDashboardAsync(AspireDashboardOptions opti else if (!isWorkload && options.Runner.AutoDownload) { // We are using the runner-managed dashboards, so we can try to update - await TryUpdateAsync(installedRuntimes, preferredVersion); + await TryUpdateAsync(installedRuntimes); } _logger.LogTrace("Aspire Installation Source: {Source}", isWorkload ? "Workload" : "NuGet"); - var installedDashboard = GetLatestInstalledVersion(isWorkload, preferredVersion); + var installedDashboard = GetLatestInstalledVersion(isWorkload); if (installedDashboard == null) { throw new ApplicationException("Failed to locate the Aspire Dashboard installation path"); @@ -139,7 +132,7 @@ public async Task GetDashboardAsync(AspireDashboardOptions opti if (version == null) { - version = await FetchLatestVersionAsync(installedRuntimes, null); + version = await FetchLatestVersionAsync(installedRuntimes); } var downloadSucceesful = await _nugetHelper.DownloadPackageAsync(_nugetPackageName, version, Path.Combine(_runnerFolder, AspireDashboard.DownloadFolder, version.ToString())); @@ -202,7 +195,7 @@ public async Task TryUpdateAsync(Version[] installedRuntimes, Version? preferred } } - private (Version Version, string Path)? GetLatestInstalledVersion(bool workload, Version? preferredVersion) + private (Version Version, string Path)? GetLatestInstalledVersion(bool workload) { try { @@ -221,15 +214,6 @@ public async Task TryUpdateAsync(Version[] installedRuntimes, Version? preferred .OrderByDescending(v => v.Version) .ToArray(); - if (preferredVersion != null) - { - var preferredDashboard = installedVersions.FirstOrDefault(v => v.Version.IsCompatibleWith(preferredVersion)); - if (preferredDashboard.Path != null) - { - return (preferredDashboard.Version, Path.Combine(preferredDashboard.Path, "tools")); - } - } - // If a version is already installed, we probably already have a compatible runtime (no need to check) var newestVersion = installedVersions .MaxBy(d => d.Version); @@ -242,7 +226,7 @@ public async Task TryUpdateAsync(Version[] installedRuntimes, Version? preferred } } - private async Task FetchLatestVersionAsync(Version[] installedRuntimes, Version? preferredVersion) + private async Task FetchLatestVersionAsync(Version[] installedRuntimes) { var availableVersions = await _nugetHelper.GetPackageVersionsAsync(_nugetPackageName); if (availableVersions.Length == 0) @@ -250,12 +234,9 @@ private async Task FetchLatestVersionAsync(Version[] installedRuntimes, throw new ApplicationException("No versions of the Aspire Dashboard are available"); } - var latestRuntimeVersion = preferredVersion != null - ? installedRuntimes.Where(v => v.IsCompatibleWith(preferredVersion)).Max() - : installedRuntimes.Max(); - + var latestRuntimeVersion = installedRuntimes.Max(); var versionToDownload = availableVersions - .Where(preferredVersion != null ? preferredVersion.IsCompatibleWith : v => v.Major == latestRuntimeVersion!.Major) + .Where(v => v.Major == latestRuntimeVersion!.Major) .DefaultIfEmpty() .Max() ?? availableVersions.First(); // Fallback to the latest version diff --git a/src/AspireRunner.Core/AspireDashboardOptions.cs b/src/AspireRunner.Core/AspireDashboardOptions.cs index d2af4e0..a36a8fb 100644 --- a/src/AspireRunner.Core/AspireDashboardOptions.cs +++ b/src/AspireRunner.Core/AspireDashboardOptions.cs @@ -105,14 +105,6 @@ public sealed class RunnerOptions /// Automatically download the dashboard if the workload is not found. /// public bool AutoDownload { get; set; } - - /// - /// The version of the dotnet runtime to use when downloading/running the dashboard. - /// - /// - /// When setting the runtime version to 8.0, the latest 8.x version of the dashboard will be downloaded/used. - /// - public string? RuntimeVersion { get; set; } } public enum FrontendAuthMode diff --git a/src/AspireRunner.Tool/Arguments.cs b/src/AspireRunner.Tool/Arguments.cs index fb74c25..299e91b 100644 --- a/src/AspireRunner.Tool/Arguments.cs +++ b/src/AspireRunner.Tool/Arguments.cs @@ -25,9 +25,6 @@ public record Arguments [Option('m', "multiple", HelpText = "Allow running multiple instances of the dashboard, if this isn't passed, existing instances will be replaced")] public bool AllowMultipleInstances { get; set; } - [Option('r', "runtime-version", HelpText = "The version of the .NET runtime to use")] - public string? RuntimeVersion { get; set; } - [Option('d', "auto-download", HelpText = "Automatically download the dashboard if it's not installed")] public bool? AutoDownload { get; set; } diff --git a/src/AspireRunner.Tool/Program.cs b/src/AspireRunner.Tool/Program.cs index 7a6aed1..064d3f4 100644 --- a/src/AspireRunner.Tool/Program.cs +++ b/src/AspireRunner.Tool/Program.cs @@ -50,10 +50,8 @@ }, Runner = new RunnerOptions { - PipeOutput = false, - AutoDownload = arguments.AutoDownload ?? true, LaunchBrowser = arguments.LaunchBrowser, - RuntimeVersion = arguments.RuntimeVersion, + AutoDownload = arguments.AutoDownload ?? true, SingleInstanceHandling = arguments.AllowMultipleInstances ? SingleInstanceHandling.Ignore : SingleInstanceHandling.ReplaceExisting } };