Start and dispose the generic application host in ImageBuilder#2134
Open
Copilot wants to merge 6 commits into
Open
Start and dispose the generic application host in ImageBuilder#2134Copilot wants to merge 6 commits into
Copilot wants to merge 6 commits into
Conversation
Copilot
AI
changed the title
[WIP] Fix ImageBuilder to start and manage application host
Start and dispose the generic application host in ImageBuilder
Jun 1, 2026
Replace the static `Lazy<IHost>` on `ImageBuilder` with a `CreateAppHost()` factory so the composition root (`Program`) unambiguously builds, owns, and disposes the host. Resolve commands directly via `GetServices<ICommand>()` and drop the static `Services`/`Commands` accessors. `StandaloneLoggerFactory` now owns a settable `ILoggerFactory` (defaulting to `NullLoggerFactory.Instance`) that `Program` wires from the host, instead of reaching into a static service provider. Convert `McrTagsMetadataGenerator`'s type-load-time static logger field to a property so it no longer captures the default factory before `Program` configures logging. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
mthalman
reviewed
Jun 4, 2026
mthalman
left a comment
Member
There was a problem hiding this comment.
Also consider updating the PR description to reflect the evolved approach.
…uilder-host-management
lbussell
approved these changes
Jun 8, 2026
mthalman
approved these changes
Jun 9, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
ImageBuilderbuilt aMicrosoft.Extensions.Hostinghost only to expose itsIServiceProvider, discarding theIHost. The container was never started, stopped, or disposed, so DI-owned disposable singletons were never released deterministically.ImageBuilder.ServicesandImageBuilder.Commandswith a newImageBuilder.CreateAppHost()method that builds and returns anIHostProgram.csentry point to use the host for resolving services and commands, and to manage application startup/shutdown lifecycle withStartAsyncandStopAsyncFixes #2124