Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 0 additions & 64 deletions extension/schemas/aspire-global-settings.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,70 +109,6 @@
"description": "Enable or disable experimental Rust language support for polyglot Aspire applications",
"default": false
},
"minimumSdkCheckEnabled": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "string",
"enum": [
"true",
"false"
]
}
],
"description": "Enable or disable minimum .NET SDK version checking before running Aspire applications",
"default": true
},
"orphanDetectionWithTimestampEnabled": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "string",
"enum": [
"true",
"false"
]
}
],
"description": "Enable or disable timestamp-based orphan process detection to clean up stale Aspire processes",
"default": true
},
"packageSearchDiskCachingEnabled": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "string",
"enum": [
"true",
"false"
]
}
],
"description": "Enable or disable disk caching for package search results to improve performance",
"default": true
},
"runningInstanceDetectionEnabled": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "string",
"enum": [
"true",
"false"
]
}
],
"description": "Enable or disable detection of already running Aspire instances to prevent conflicts",
"default": true
},
"showAllTemplates": {
"anyOf": [
{
Expand Down
64 changes: 0 additions & 64 deletions extension/schemas/aspire-settings.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,70 +113,6 @@
"description": "Enable or disable experimental Rust language support for polyglot Aspire applications",
"default": false
},
"minimumSdkCheckEnabled": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "string",
"enum": [
"true",
"false"
]
}
],
"description": "Enable or disable minimum .NET SDK version checking before running Aspire applications",
"default": true
},
"orphanDetectionWithTimestampEnabled": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "string",
"enum": [
"true",
"false"
]
}
],
"description": "Enable or disable timestamp-based orphan process detection to clean up stale Aspire processes",
"default": true
},
"packageSearchDiskCachingEnabled": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "string",
"enum": [
"true",
"false"
]
}
],
"description": "Enable or disable disk caching for package search results to improve performance",
"default": true
},
"runningInstanceDetectionEnabled": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "string",
"enum": [
"true",
"false"
]
}
],
"description": "Enable or disable detection of already running Aspire instances to prevent conflicts",
"default": true
},
"showAllTemplates": {
"anyOf": [
{
Expand Down
29 changes: 12 additions & 17 deletions src/Aspire.Cli/Commands/AddCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ internal sealed class AddCommand : BaseCommand
private readonly IAddCommandPrompter _prompter;
private readonly IDotNetSdkInstaller _sdkInstaller;
private readonly ICliHostEnvironment _hostEnvironment;
private readonly IFeatures _features;
private readonly IAppHostProjectFactory _projectFactory;

private static readonly Argument<string> s_integrationArgument = new("integration")
Expand All @@ -52,7 +51,6 @@ public AddCommand(IPackagingService packagingService, IInteractionService intera
_prompter = prompter;
_sdkInstaller = sdkInstaller;
_hostEnvironment = hostEnvironment;
_features = features;
_projectFactory = projectFactory;

Arguments.Add(s_integrationArgument);
Expand Down Expand Up @@ -210,22 +208,19 @@ await Parallel.ForEachAsync(channels, cancellationToken, async (channel, ct) =>
// Stop any running AppHost instance before adding the package.
// A running AppHost (especially in detach mode) locks project files,
// which prevents 'dotnet add package' from modifying the project.
if (_features.IsFeatureEnabled(KnownFeatures.RunningInstanceDetectionEnabled, defaultValue: true))
{
var runningInstanceResult = await project.FindAndStopRunningInstanceAsync(
effectiveAppHostProjectFile,
ExecutionContext.HomeDirectory,
cancellationToken);
var runningInstanceResult = await project.FindAndStopRunningInstanceAsync(
effectiveAppHostProjectFile,
ExecutionContext.HomeDirectory,
cancellationToken);

if (runningInstanceResult == RunningInstanceResult.InstanceStopped)
{
InteractionService.DisplayMessage(KnownEmojis.Information, AddCommandStrings.StoppedRunningInstance);
}
else if (runningInstanceResult == RunningInstanceResult.StopFailed)
{
InteractionService.DisplayError(AddCommandStrings.UnableToStopRunningInstances);
return ExitCodeConstants.FailedToAddPackage;
}
if (runningInstanceResult == RunningInstanceResult.InstanceStopped)
{
InteractionService.DisplayMessage(KnownEmojis.Information, AddCommandStrings.StoppedRunningInstance);
}
else if (runningInstanceResult == RunningInstanceResult.StopFailed)
{
InteractionService.DisplayError(AddCommandStrings.UnableToStopRunningInstances);
return ExitCodeConstants.FailedToAddPackage;
}

var success = await InteractionService.ShowStatusAsync(
Expand Down
5 changes: 1 addition & 4 deletions src/Aspire.Cli/Commands/AppHostLauncher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Globalization;
using System.Text.Json;
using Aspire.Cli.Backchannel;
using Aspire.Cli.Configuration;
using Aspire.Cli.Interaction;
using Aspire.Cli.Processes;
using Aspire.Cli.Projects;
Expand All @@ -24,7 +23,6 @@ namespace Aspire.Cli.Commands;
internal sealed class AppHostLauncher(
IProjectLocator projectLocator,
CliExecutionContext executionContext,
IFeatures features,
IInteractionService interactionService,
IAuxiliaryBackchannelMonitor backchannelMonitor,
ILogger<AppHostLauncher> logger,
Expand Down Expand Up @@ -150,12 +148,11 @@ public async Task<int> LaunchDetachedAsync(

private async Task StopExistingInstancesAsync(FileInfo effectiveAppHostFile, CancellationToken cancellationToken)
{
var runningInstanceDetectionEnabled = features.IsFeatureEnabled(KnownFeatures.RunningInstanceDetectionEnabled, defaultValue: true);
var existingSockets = AppHostHelper.FindMatchingSockets(
effectiveAppHostFile.FullName,
executionContext.HomeDirectory.FullName);

if (runningInstanceDetectionEnabled && existingSockets.Length > 0)
if (existingSockets.Length > 0)
{
logger.LogDebug("Found {Count} running instance(s) for this AppHost, stopping them first.", existingSockets.Length);
var manager = new RunningInstanceManager(logger, interactionService, timeProvider);
Expand Down
23 changes: 8 additions & 15 deletions src/Aspire.Cli/Commands/RunCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,6 @@ protected override async Task<int> ExecuteAsync(ParseResult parseResult, Cancell
Debug.Assert(_startDebugSessionOption is not null);
startDebugSession = parseResult.GetValue(_startDebugSessionOption);
}
var runningInstanceDetectionEnabled = _features.IsFeatureEnabled(KnownFeatures.RunningInstanceDetectionEnabled, defaultValue: true);
// Force option kept for backward compatibility but no longer used since prompt was removed
// var force = runningInstanceDetectionEnabled && parseResult.GetValue<bool>("--force");

// Validate that --format is only used with --detach
if (format == OutputFormat.Json && !detach)
Expand Down Expand Up @@ -198,19 +195,15 @@ protected override async Task<int> ExecuteAsync(ParseResult parseResult, Cancell
return ExitCodeConstants.FailedToFindProject;
}

// Check for running instance if feature is enabled
if (runningInstanceDetectionEnabled)
{
// Even if we fail to stop we won't block the apphost starting
// to make sure we don't ever break flow. It should mostly stop
// just fine though.
var runningInstanceResult = await project.FindAndStopRunningInstanceAsync(effectiveAppHostFile, ExecutionContext.HomeDirectory, cancellationToken);
// Check for running instance — even if we fail to stop we won't
// block the apphost starting to make sure we don't ever break flow.
// It should mostly stop just fine though.
var runningInstanceResult = await project.FindAndStopRunningInstanceAsync(effectiveAppHostFile, ExecutionContext.HomeDirectory, cancellationToken);

// If in isolated mode and a running instance was stopped, warn the user
if (isolated && runningInstanceResult == RunningInstanceResult.InstanceStopped)
{
InteractionService.DisplayMessage(KnownEmojis.Warning, RunCommandStrings.IsolatedModeRunningInstanceWarning);
}
// If in isolated mode and a running instance was stopped, warn the user
if (isolated && runningInstanceResult == RunningInstanceResult.InstanceStopped)
{
InteractionService.DisplayMessage(KnownEmojis.Warning, RunCommandStrings.IsolatedModeRunningInstanceWarning);
}

// The completion sources are the contract between RunCommand and IAppHostProject
Expand Down
7 changes: 1 addition & 6 deletions src/Aspire.Cli/DotNet/DotNetCliExecutionFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Diagnostics;
using System.Globalization;
using System.Runtime.InteropServices;
using Aspire.Cli.Configuration;
using Aspire.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
Expand All @@ -14,7 +13,6 @@ namespace Aspire.Cli.DotNet;
internal sealed class DotNetCliExecutionFactory(
ILogger<DotNetCliExecutionFactory> logger,
IConfiguration configuration,
IFeatures features,
CliExecutionContext executionContext) : IDotNetCliExecutionFactory
{
internal static int GetCurrentProcessId() => Environment.ProcessId;
Expand Down Expand Up @@ -73,10 +71,7 @@ public IDotNetCliExecution CreateExecution(string[] args, IDictionary<string, st

// Set the CLI process start time for robust orphan detection to prevent PID reuse issues.
// The AppHost will verify both PID and start time to ensure it's monitoring the correct process.
if (features.IsFeatureEnabled(KnownFeatures.OrphanDetectionWithTimestampEnabled, true))
{
startInfo.EnvironmentVariables[KnownConfigNames.CliProcessStarted] = GetCurrentProcessStartTimeUnixSeconds().ToString(CultureInfo.InvariantCulture);
}
startInfo.EnvironmentVariables[KnownConfigNames.CliProcessStarted] = GetCurrentProcessStartTimeUnixSeconds().ToString(CultureInfo.InvariantCulture);

// Always set MSBUILDTERMINALLOGGER=false for all dotnet command executions to ensure consistent terminal logger behavior
startInfo.EnvironmentVariables[KnownConfigNames.MsBuildTerminalLogger] = "false";
Expand Down
4 changes: 2 additions & 2 deletions src/Aspire.Cli/DotNet/DotNetCliRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -919,8 +919,8 @@ public async Task<string> ComputeNuGetConfigHierarchySha256Async(DirectoryInfo w
using var activity = telemetry.StartDiagnosticActivity();

string? rawKey = null;
bool cacheEnabled = useCache && features.IsFeatureEnabled(KnownFeatures.PackageSearchDiskCachingEnabled, defaultValue: true);
if (cacheEnabled)
var cacheEnabled = useCache;
if (useCache)
{
try
{
Expand Down
9 changes: 1 addition & 8 deletions src/Aspire.Cli/DotNet/DotNetSdkInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using System.Diagnostics;
using System.Runtime.InteropServices;
using Aspire.Cli.Configuration;
using Microsoft.Extensions.Configuration;
using Semver;

Expand All @@ -12,7 +11,7 @@ namespace Aspire.Cli.DotNet;
/// <summary>
/// Default implementation of <see cref="IDotNetSdkInstaller"/> that checks for dotnet on the system PATH.
/// </summary>
internal sealed class DotNetSdkInstaller(IFeatures features, IConfiguration configuration) : IDotNetSdkInstaller
internal sealed class DotNetSdkInstaller(IConfiguration configuration) : IDotNetSdkInstaller
{
/// <summary>
/// The minimum .NET SDK version required for Aspire.
Expand All @@ -24,12 +23,6 @@ internal sealed class DotNetSdkInstaller(IFeatures features, IConfiguration conf
{
var minimumVersion = GetEffectiveMinimumSdkVersion(configuration);

if (!features.IsFeatureEnabled(KnownFeatures.MinimumSdkCheckEnabled, true))
{
// If the feature is disabled, we assume the SDK is available
return (true, null, minimumVersion);
}

try
{
// Add --arch flag to ensure we only get SDKs that match the current architecture
Expand Down
26 changes: 1 addition & 25 deletions src/Aspire.Cli/KnownFeatures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,15 @@ internal static class KnownFeatures
{
public static string FeaturePrefix => "features";
public static string UpdateNotificationsEnabled => "updateNotificationsEnabled";
public static string MinimumSdkCheckEnabled => "minimumSdkCheckEnabled";
public static string ExecCommandEnabled => "execCommandEnabled";
public static string OrphanDetectionWithTimestampEnabled => "orphanDetectionWithTimestampEnabled";
public static string ShowDeprecatedPackages => "showDeprecatedPackages";
public static string PackageSearchDiskCachingEnabled => "packageSearchDiskCachingEnabled";
public static string StagingChannelEnabled => "stagingChannelEnabled";
public static string DefaultWatchEnabled => "defaultWatchEnabled";
public static string ShowAllTemplates => "showAllTemplates";
public static string ExperimentalPolyglotRust => "experimentalPolyglot:rust";
public static string ExperimentalPolyglotJava => "experimentalPolyglot:java";
public static string ExperimentalPolyglotGo => "experimentalPolyglot:go";
public static string ExperimentalPolyglotPython => "experimentalPolyglot:python";
public static string RunningInstanceDetectionEnabled => "runningInstanceDetectionEnabled";

private static readonly Dictionary<string, FeatureMetadata> s_featureMetadata = new()
{
Expand All @@ -37,31 +33,16 @@ internal static class KnownFeatures
"Check if update notifications are disabled and set version check environment variable",
DefaultValue: true),

[MinimumSdkCheckEnabled] = new(
MinimumSdkCheckEnabled,
"Enable or disable minimum .NET SDK version checking before running Aspire applications",
DefaultValue: true),

[ExecCommandEnabled] = new(
ExecCommandEnabled,
"Enable or disable the 'aspire exec' command for executing commands inside running resources",
DefaultValue: false),

[OrphanDetectionWithTimestampEnabled] = new(
OrphanDetectionWithTimestampEnabled,
"Enable or disable timestamp-based orphan process detection to clean up stale Aspire processes",
DefaultValue: true),

[ShowDeprecatedPackages] = new(
ShowDeprecatedPackages,
"Show or hide deprecated packages in 'aspire add' search results",
DefaultValue: false),

[PackageSearchDiskCachingEnabled] = new(
PackageSearchDiskCachingEnabled,
"Enable or disable disk caching for package search results to improve performance",
DefaultValue: true),

[StagingChannelEnabled] = new(
StagingChannelEnabled,
"Enable or disable access to the staging channel for early access to preview features and packages",
Expand Down Expand Up @@ -95,12 +76,7 @@ internal static class KnownFeatures
[ExperimentalPolyglotPython] = new(
ExperimentalPolyglotPython,
"Enable or disable experimental Python language support for polyglot Aspire applications",
DefaultValue: false),

[RunningInstanceDetectionEnabled] = new(
RunningInstanceDetectionEnabled,
"Enable or disable detection of already running Aspire instances to prevent conflicts",
DefaultValue: true)
DefaultValue: false)
};

/// <summary>
Expand Down
Loading
Loading