diff --git a/src/Aspire.Hosting/Dashboard/DcpDataSource.cs b/src/Aspire.Hosting/Dashboard/DcpDataSource.cs index 6d869892cab..9adfce4c1b7 100644 --- a/src/Aspire.Hosting/Dashboard/DcpDataSource.cs +++ b/src/Aspire.Hosting/Dashboard/DcpDataSource.cs @@ -115,22 +115,18 @@ bool IsFilteredResource(T resource) where T : CustomResource } } - private async Task ProcessInitialResourceAsync(IResource resource, CancellationToken cancellationToken) + private Task ProcessInitialResourceAsync(IResource resource, CancellationToken cancellationToken) { // The initial snapshots are all generic resources until we get the real state from DCP (for projects, containers and executables). - if (resource.IsContainer()) { var snapshot = CreateResourceSnapshot(resource, DateTime.UtcNow, new CustomResourceSnapshot { ResourceType = KnownResourceTypes.Container, Properties = [], - State = "Starting" }); _placeHolderResources.TryAdd(resource.Name, snapshot); - - await _onResourceChanged(snapshot, ResourceSnapshotChangeType.Upsert).ConfigureAwait(false); } else if (resource is ProjectResource) { @@ -138,12 +134,9 @@ private async Task ProcessInitialResourceAsync(IResource resource, CancellationT { ResourceType = KnownResourceTypes.Project, Properties = [], - State = "Starting" }); _placeHolderResources.TryAdd(resource.Name, snapshot); - - await _onResourceChanged(snapshot, ResourceSnapshotChangeType.Upsert).ConfigureAwait(false); } else if (resource is ExecutableResource) { @@ -151,14 +144,11 @@ private async Task ProcessInitialResourceAsync(IResource resource, CancellationT { ResourceType = KnownResourceTypes.Executable, Properties = [], - State = "Starting" }); _placeHolderResources.TryAdd(resource.Name, snapshot); - - await _onResourceChanged(snapshot, ResourceSnapshotChangeType.Upsert).ConfigureAwait(false); } - + var creationTimestamp = DateTime.UtcNow; _ = Task.Run(async () => @@ -178,6 +168,8 @@ private async Task ProcessInitialResourceAsync(IResource resource, CancellationT } }, cancellationToken); + + return Task.CompletedTask; } private static GenericResourceSnapshot CreateResourceSnapshot(IResource resource, DateTime creationTimestamp, CustomResourceSnapshot snapshot) diff --git a/src/Aspire.Hosting/Dcp/ApplicationExecutor.cs b/src/Aspire.Hosting/Dcp/ApplicationExecutor.cs index a9203672d89..8d22406ce9e 100644 --- a/src/Aspire.Hosting/Dcp/ApplicationExecutor.cs +++ b/src/Aspire.Hosting/Dcp/ApplicationExecutor.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Net.Sockets; +using Aspire.Dashboard.Model; using Aspire.Hosting.ApplicationModel; using Aspire.Hosting.Dcp.Model; using Aspire.Hosting.Lifecycle; @@ -521,6 +522,14 @@ async Task CreateExecutableAsyncCore(AppResource cr, CancellationToken cancellat { var logger = loggerService.GetLogger(cr.ModelResource); + await notificationService.PublishUpdateAsync(cr.ModelResource, s => s with + { + ResourceType = cr.ModelResource is ProjectResource ? KnownResourceTypes.Project : KnownResourceTypes.Executable, + Properties = [], + State = "Starting" + }) + .ConfigureAwait(false); + try { await CreateExecutableAsync(cr, cancellationToken).ConfigureAwait(false); @@ -773,6 +782,14 @@ async Task CreateContainerAsyncCore(AppResource cr, CancellationToken cancellati { var logger = loggerService.GetLogger(cr.ModelResource); + await notificationService.PublishUpdateAsync(cr.ModelResource, s => s with + { + State = "Starting", + Properties = [], // TODO: Add image name + ResourceType = KnownResourceTypes.Container + }) + .ConfigureAwait(false); + try { await CreateContainerAsync(cr, cancellationToken).ConfigureAwait(false);