-
Notifications
You must be signed in to change notification settings - Fork 850
Fix CLI bundle extraction to use ~/.aspire/ for non-standard install paths #15563
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: release/13.2
Are you sure you want to change the base?
Changes from all commits
be46306
c2007ab
d8fc956
7e055d4
c9ac433
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,16 +36,18 @@ public interface ILayoutDiscovery | |
| public sealed class LayoutDiscovery : ILayoutDiscovery | ||
| { | ||
| private readonly ILogger<LayoutDiscovery> _logger; | ||
| private readonly CliExecutionContext _executionContext; | ||
|
|
||
| public LayoutDiscovery(ILogger<LayoutDiscovery> logger) | ||
| internal LayoutDiscovery(CliExecutionContext executionContext, ILogger<LayoutDiscovery> logger) | ||
| { | ||
| _executionContext = executionContext; | ||
JamesNK marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| _logger = logger; | ||
| } | ||
|
|
||
| public LayoutConfiguration? DiscoverLayout(string? projectDirectory = null) | ||
| { | ||
| // 1. Try environment variable for layout path | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't matter because this is the CLI. But LayoutDiscovery class itself should be internal. If it's changed to internal then I think the constructor can then be made public and then you don't need to manually create the type with its resolved dependencies in a DI callback. |
||
| var envLayoutPath = Environment.GetEnvironmentVariable(BundleDiscovery.LayoutPathEnvVar); | ||
| var envLayoutPath = _executionContext.GetEnvironmentVariable(BundleDiscovery.LayoutPathEnvVar); | ||
| if (!string.IsNullOrEmpty(envLayoutPath)) | ||
| { | ||
| _logger.LogDebug("Found ASPIRE_LAYOUT_PATH: {Path}", envLayoutPath); | ||
|
|
@@ -64,6 +66,16 @@ public LayoutDiscovery(ILogger<LayoutDiscovery> logger) | |
| return LogEnvironmentOverrides(relativeLayout); | ||
| } | ||
|
|
||
| // 3. Try the well-known ~/.aspire/ directory. | ||
| // When the CLI is installed outside the standard layout (e.g., via Homebrew or Winget), | ||
| // the bundle is extracted to ~/.aspire/ instead of adjacent to the binary. | ||
| var wellKnownLayout = TryDiscoverWellKnownLayout(); | ||
| if (wellKnownLayout is not null) | ||
| { | ||
| _logger.LogDebug("Discovered layout at well-known path: {Path}", wellKnownLayout.LayoutPath); | ||
| return LogEnvironmentOverrides(wellKnownLayout); | ||
| } | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This still reads This makes Consider adding a |
||
| _logger.LogDebug("No bundle layout discovered"); | ||
| return null; | ||
| } | ||
|
|
@@ -73,8 +85,8 @@ public LayoutDiscovery(ILogger<LayoutDiscovery> logger) | |
| // Check environment variable overrides first | ||
| var envPath = component switch | ||
| { | ||
| LayoutComponent.Dcp => Environment.GetEnvironmentVariable(BundleDiscovery.DcpPathEnvVar), | ||
| LayoutComponent.Managed => Environment.GetEnvironmentVariable(BundleDiscovery.ManagedPathEnvVar), | ||
| LayoutComponent.Dcp => _executionContext.GetEnvironmentVariable(BundleDiscovery.DcpPathEnvVar), | ||
| LayoutComponent.Managed => _executionContext.GetEnvironmentVariable(BundleDiscovery.ManagedPathEnvVar), | ||
| _ => null | ||
| }; | ||
|
|
||
|
|
@@ -91,7 +103,7 @@ public LayoutDiscovery(ILogger<LayoutDiscovery> logger) | |
| public bool IsBundleModeAvailable(string? projectDirectory = null) | ||
| { | ||
| // Check if user explicitly wants SDK mode | ||
| var useSdk = Environment.GetEnvironmentVariable(BundleDiscovery.UseGlobalDotNetEnvVar); | ||
| var useSdk = _executionContext.GetEnvironmentVariable(BundleDiscovery.UseGlobalDotNetEnvVar); | ||
| if (string.Equals(useSdk, "true", StringComparison.OrdinalIgnoreCase) || | ||
| string.Equals(useSdk, "1", StringComparison.OrdinalIgnoreCase)) | ||
| { | ||
|
|
@@ -180,6 +192,15 @@ public bool IsBundleModeAvailable(string? projectDirectory = null) | |
| return null; | ||
| } | ||
|
|
||
| private LayoutConfiguration? TryDiscoverWellKnownLayout() | ||
| { | ||
| var wellKnownPath = _executionContext.AspireDirectory.FullName; | ||
|
|
||
| _logger.LogDebug("TryDiscoverWellKnownLayout: Checking well-known path {Path}...", wellKnownPath); | ||
|
|
||
| return TryInferLayout(wellKnownPath); | ||
| } | ||
|
|
||
| private LayoutConfiguration? TryInferLayout(string layoutPath) | ||
| { | ||
| // Check for essential directories | ||
|
|
@@ -222,11 +243,11 @@ private LayoutConfiguration LogEnvironmentOverrides(LayoutConfiguration config) | |
| // Environment variables for specific components take precedence | ||
| // These will be checked at GetComponentPath time, but we note them here for logging | ||
|
|
||
| if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable(BundleDiscovery.DcpPathEnvVar))) | ||
| if (!string.IsNullOrEmpty(_executionContext.GetEnvironmentVariable(BundleDiscovery.DcpPathEnvVar))) | ||
| { | ||
| _logger.LogDebug("DCP path override from {EnvVar}", BundleDiscovery.DcpPathEnvVar); | ||
| } | ||
| if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable(BundleDiscovery.ManagedPathEnvVar))) | ||
| if (!string.IsNullOrEmpty(_executionContext.GetEnvironmentVariable(BundleDiscovery.ManagedPathEnvVar))) | ||
| { | ||
| _logger.LogDebug("Managed path override from {EnvVar}", BundleDiscovery.ManagedPathEnvVar); | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.