diff --git a/src/Aspire.Dashboard/Components/Pages/Resources.razor.cs b/src/Aspire.Dashboard/Components/Pages/Resources.razor.cs index 9c6014913ee..57fa53778ae 100644 --- a/src/Aspire.Dashboard/Components/Pages/Resources.razor.cs +++ b/src/Aspire.Dashboard/Components/Pages/Resources.razor.cs @@ -309,9 +309,10 @@ private async Task ExecuteResourceCommandAsync(ResourceViewModel resource, Comma } } - var resourceName = resource.IsExecutable(allowSubtypes: true) - ? resource.DisplayName - : resource.Name; + //var resourceName = resource.IsExecutable(allowSubtypes: true) + // ? resource.DisplayName + // : resource.Name; + var resourceName = resource.Name; var response = await DashboardClient.ExecuteResourceCommandAsync(resourceName, resource.ResourceType, command, CancellationToken.None); diff --git a/src/Aspire.Hosting/Dcp/ApplicationExecutor.cs b/src/Aspire.Hosting/Dcp/ApplicationExecutor.cs index 9a884f64da5..ef8bc98e892 100644 --- a/src/Aspire.Hosting/Dcp/ApplicationExecutor.cs +++ b/src/Aspire.Hosting/Dcp/ApplicationExecutor.cs @@ -1041,84 +1041,88 @@ private void PrepareProjectExecutables() var replicas = project.GetReplicaCount(); - var ers = ExecutableReplicaSet.Create(GetObjectNameForResource(project), replicas, "dotnet"); - var exeSpec = ers.Spec.Template.Spec; - exeSpec.WorkingDirectory = Path.GetDirectoryName(projectMetadata.ProjectPath); + for (var i = 0; i < replicas; i++) + { + var nameSuffix = GetRandomNameSuffix(); + var exeName = GetObjectNameForResource(project, nameSuffix); - IAnnotationHolder annotationHolder = ers.Spec.Template; - annotationHolder.Annotate(CustomResource.OtelServiceNameAnnotation, (replicas > 1) ? ers.Metadata.Name : project.Name); - // The OTEL service instance ID annotation will be generated and applied automatically by DCP. - annotationHolder.Annotate(CustomResource.ResourceNameAnnotation, project.Name); + var exeSpec = Executable.Create(exeName, "dotnet"); + exeSpec.Spec.WorkingDirectory = Path.GetDirectoryName(projectMetadata.ProjectPath); - SetInitialResourceState(project, annotationHolder); + exeSpec.Annotate(CustomResource.OtelServiceNameAnnotation, project.Name); + exeSpec.Annotate(CustomResource.OtelServiceInstanceIdAnnotation, nameSuffix); + exeSpec.Annotate(CustomResource.ResourceNameAnnotation, project.Name); - var projectLaunchConfiguration = new ProjectLaunchConfiguration(); - projectLaunchConfiguration.ProjectPath = projectMetadata.ProjectPath; + SetInitialResourceState(project, exeSpec); - if (!string.IsNullOrEmpty(configuration[DebugSessionPortVar])) - { - exeSpec.ExecutionType = ExecutionType.IDE; + var projectLaunchConfiguration = new ProjectLaunchConfiguration(); + projectLaunchConfiguration.ProjectPath = projectMetadata.ProjectPath; - projectLaunchConfiguration.DisableLaunchProfile = project.TryGetLastAnnotation(out _); - if (!projectLaunchConfiguration.DisableLaunchProfile && project.TryGetLastAnnotation(out var lpa)) + if (!string.IsNullOrEmpty(configuration[DebugSessionPortVar])) { - projectLaunchConfiguration.LaunchProfile = lpa.LaunchProfileName; + exeSpec.Spec.ExecutionType = ExecutionType.IDE; + + projectLaunchConfiguration.DisableLaunchProfile = project.TryGetLastAnnotation(out _); + if (!projectLaunchConfiguration.DisableLaunchProfile && project.TryGetLastAnnotation(out var lpa)) + { + projectLaunchConfiguration.LaunchProfile = lpa.LaunchProfileName; + } } - } - else - { - exeSpec.ExecutionType = ExecutionType.Process; - if (configuration.GetBool("DOTNET_WATCH") is not true) + else { - exeSpec.Args = [ - "run", + exeSpec.Spec.ExecutionType = ExecutionType.Process; + if (configuration.GetBool("DOTNET_WATCH") is not true) + { + exeSpec.Spec.Args = [ + "run", "--no-build", "--project", projectMetadata.ProjectPath, ]; - } - else - { - exeSpec.Args = [ - "watch", + } + else + { + exeSpec.Spec.Args = [ + "watch", "--non-interactive", "--no-hot-reload", "--project", projectMetadata.ProjectPath - ]; - } + ]; + } - if (!string.IsNullOrEmpty(_distributedApplicationOptions.Configuration)) - { - exeSpec.Args.AddRange(new [] {"-c", _distributedApplicationOptions.Configuration}); - } + if (!string.IsNullOrEmpty(_distributedApplicationOptions.Configuration)) + { + exeSpec.Spec.Args.AddRange(new[] { "-c", _distributedApplicationOptions.Configuration }); + } - // We pretty much always want to suppress the normal launch profile handling - // because the settings from the profile will override the ambient environment settings, which is not what we want - // (the ambient environment settings for service processes come from the application model - // and should be HIGHER priority than the launch profile settings). - // This means we need to apply the launch profile settings manually--the invocation parameters here, - // and the environment variables/application URLs inside CreateExecutableAsync(). - exeSpec.Args.Add("--no-launch-profile"); + // We pretty much always want to suppress the normal launch profile handling + // because the settings from the profile will override the ambient environment settings, which is not what we want + // (the ambient environment settings for service processes come from the application model + // and should be HIGHER priority than the launch profile settings). + // This means we need to apply the launch profile settings manually--the invocation parameters here, + // and the environment variables/application URLs inside CreateExecutableAsync(). + exeSpec.Spec.Args.Add("--no-launch-profile"); - var launchProfile = project.GetEffectiveLaunchProfile()?.LaunchProfile; - if (launchProfile is not null && !string.IsNullOrWhiteSpace(launchProfile.CommandLineArgs)) - { - var cmdArgs = CommandLineArgsParser.Parse(launchProfile.CommandLineArgs); - if (cmdArgs.Count > 0) + var launchProfile = project.GetEffectiveLaunchProfile()?.LaunchProfile; + if (launchProfile is not null && !string.IsNullOrWhiteSpace(launchProfile.CommandLineArgs)) { - exeSpec.Args.Add("--"); - exeSpec.Args.AddRange(cmdArgs); + var cmdArgs = CommandLineArgsParser.Parse(launchProfile.CommandLineArgs); + if (cmdArgs.Count > 0) + { + exeSpec.Spec.Args.Add("--"); + exeSpec.Spec.Args.AddRange(cmdArgs); + } } } - } - // We want this annotation even if we are not using IDE execution; see ToSnapshot() for details. - annotationHolder.AnnotateAsObjectList(Executable.LaunchConfigurationsAnnotation, projectLaunchConfiguration); + // We want this annotation even if we are not using IDE execution; see ToSnapshot() for details. + exeSpec.AnnotateAsObjectList(Executable.LaunchConfigurationsAnnotation, projectLaunchConfiguration); - var exeAppResource = new AppResource(project, ers); - AddServicesProducedInfo(project, annotationHolder, exeAppResource); - _appResources.Add(exeAppResource); + var exeAppResource = new AppResource(project, exeSpec); + AddServicesProducedInfo(project, exeSpec, exeAppResource); + _appResources.Add(exeAppResource); + } } } diff --git a/src/Aspire.Hosting/Health/ResourceNotificationHealthCheckPublisher.cs b/src/Aspire.Hosting/Health/ResourceNotificationHealthCheckPublisher.cs index 7721e171e61..b7b0c1f5414 100644 --- a/src/Aspire.Hosting/Health/ResourceNotificationHealthCheckPublisher.cs +++ b/src/Aspire.Hosting/Health/ResourceNotificationHealthCheckPublisher.cs @@ -17,10 +17,12 @@ public async Task PublishAsync(HealthReport report, CancellationToken cancellati // Make sure every annotation is represented as health in the report, and if an entry is missing that means it is unhealthy. var status = annotations.All(a => report.Entries.TryGetValue(a.Key, out var entry) && entry.Status == HealthStatus.Healthy) ? HealthStatus.Healthy : HealthStatus.Unhealthy; - await resourceNotificationService.PublishUpdateAsync(resource, s => s with - { - HealthStatus = status - }).ConfigureAwait(false); + _ = resourceNotificationService; + await Task.Yield(); + //await resourceNotificationService.PublishUpdateAsync(resource, s => s with + //{ + // HealthStatus = status + //}).ConfigureAwait(false); } } }