- 
                Notifications
    
You must be signed in to change notification settings  - Fork 133
 
Remove deprecated IDistributedApplicationLifecycleHook interface #915
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
          
     Merged
      
      
            aaronpowell
  merged 8 commits into
  aspire-13
from
copilot/remove-deprecated-lifecycle-hook
  
      
      
   
  Oct 24, 2025 
      
    
  
     Merged
                    Changes from 7 commits
      Commits
    
    
            Show all changes
          
          
            8 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      32efe61
              
                Initial plan
              
              
                Copilot 0d3ab6c
              
                Replace IDistributedApplicationLifecycleHook with event-based patterns
              
              
                Copilot 414747e
              
                Add tests for installer resources and update Dapr tests
              
              
                Copilot 69ebc86
              
                Refactor Dapr to use IDistributedApplicationEventingSubscriber
              
              
                Copilot 47f3b1a
              
                Merge branch 'aspire-13' into copilot/remove-deprecated-lifecycle-hook
              
              
                aaronpowell 3fe64f9
              
                Fixing build issue
              
              
                aaronpowell d500b03
              
                Updating the endpoint port
              
              
                aaronpowell 3daa28c
              
                Disabling some tests so we can move forward in other parts of the Asp…
              
              
                aaronpowell File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
        
          
          
            2 changes: 0 additions & 2 deletions
          
          2 
        
  examples/deno/CommunityToolkit.Aspire.Hosting.Deno.AppHost/Program.cs
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              
        
          
          
            9 changes: 9 additions & 0 deletions
          
          9 
        
  src/CommunityToolkit.Aspire.Hosting.Bun/BunInstallerResource.cs
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| namespace Aspire.Hosting.ApplicationModel; | ||
| 
     | 
||
| /// <summary> | ||
| /// A resource that represents a Bun package installer. | ||
| /// </summary> | ||
| /// <param name="name">The name of the resource.</param> | ||
| /// <param name="workingDirectory">The working directory to use for the command.</param> | ||
| public class BunInstallerResource(string name, string workingDirectory) | ||
| : ExecutableResource(name, "bun", workingDirectory); | 
        
          
          
            126 changes: 0 additions & 126 deletions
          
          126 
        
  src/CommunityToolkit.Aspire.Hosting.Bun/BunPackageInstallerLifecycleHook.cs
  
  
      
      
   
        
      
      
    This file was deleted.
      
      Oops, something went wrong.
      
    
  
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,8 +1,6 @@ | ||
| using Aspire.Hosting.ApplicationModel; | ||
| using Aspire.Hosting.Lifecycle; | ||
| using Microsoft.Extensions.Hosting; | ||
| using CommunityToolkit.Aspire.Utils; | ||
| using CommunityToolkit.Aspire.Hosting.Deno; | ||
| 
     | 
||
| namespace Aspire.Hosting; | ||
| /// <summary> | ||
| 
          
            
          
           | 
    @@ -73,10 +71,27 @@ public static IResourceBuilder<DenoAppResource> AddDenoTask(this IDistributedApp | |
| /// Ensures the Deno packages are installed before the application starts using Deno as the package manager. | ||
| /// </summary> | ||
| /// <param name="resource">The Deno app resource.</param> | ||
| /// <param name="configureInstaller">Configure the Deno installer resource.</param> | ||
| /// <returns>A reference to the <see cref="IResourceBuilder{T}"/>.</returns> | ||
| public static IResourceBuilder<DenoAppResource> WithDenoPackageInstallation(this IResourceBuilder<DenoAppResource> resource) | ||
| public static IResourceBuilder<DenoAppResource> WithDenoPackageInstallation(this IResourceBuilder<DenoAppResource> resource, Action<IResourceBuilder<DenoInstallerResource>>? configureInstaller = null) | ||
| { | ||
| resource.ApplicationBuilder.Services.TryAddLifecycleHook<DenoPackageInstallerLifecycleHook>(); | ||
| // Only install packages during development, not in publish mode | ||
| if (!resource.ApplicationBuilder.ExecutionContext.IsPublishMode) | ||
| { | ||
| var installerName = $"{resource.Resource.Name}-deno-install"; | ||
| var installer = new DenoInstallerResource(installerName, resource.Resource.WorkingDirectory); | ||
| 
         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. Same comment as above.  | 
||
| 
     | 
||
| var installerBuilder = resource.ApplicationBuilder.AddResource(installer) | ||
| .WithArgs("install") | ||
| .WithParentRelationship(resource.Resource) | ||
| .ExcludeFromManifest(); | ||
| 
     | 
||
| // Make the parent resource wait for the installer to complete | ||
| resource.WaitForCompletion(installerBuilder); | ||
| 
     | 
||
| configureInstaller?.Invoke(installerBuilder); | ||
| } | ||
| 
     | 
||
| return resource; | ||
| } | ||
| 
     | 
||
| 
          
            
          
           | 
    ||
        
          
          
            9 changes: 9 additions & 0 deletions
          
          9 
        
  src/CommunityToolkit.Aspire.Hosting.Deno/DenoInstallerResource.cs
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| namespace Aspire.Hosting.ApplicationModel; | ||
| 
     | 
||
| /// <summary> | ||
| /// A resource that represents a Deno package installer. | ||
| /// </summary> | ||
| /// <param name="name">The name of the resource.</param> | ||
| /// <param name="workingDirectory">The working directory to use for the command.</param> | ||
| public class DenoInstallerResource(string name, string workingDirectory) | ||
| : ExecutableResource(name, "deno", workingDirectory); | 
      
      Oops, something went wrong.
        
    
  
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This call isn't idempotent. There's a new helper here https://github.com/dotnet/aspire/blob/5a87acfdb041ce3f89189a8af379fa24df4f3d44/src/Aspire.Hosting/DistributedApplicationBuilderExtensions.cs#L91.
You can use it like so https://github.com/dotnet/aspire/blob/5a87acfdb041ce3f89189a8af379fa24df4f3d44/src/Aspire.Hosting/ProjectResourceBuilderExtensions.cs#L822-L829
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this is moving away from the event model for doing this to the same model used for npm/pnpm/etc. installing.