Repository navigation
Fix Windows service test cleanup masking startup errors - #136696
Merged
Merged
Conversation
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @dotnet/area-extensions-hosting |
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
Privileged Windows validation is needed to confirm SCM deletion visibility and repeated disposal after RemoteExecutionException on both target frameworks, as these behaviors cannot be verified from the available source snapshot.
No open issues 🎉
What changed in this PR
This PR fixes cleanup in the Windows service test infrastructure so an unstarted placeholder process does not mask startup errors. It does not change production behavior or address the underlying service-start failure.
Changes:
- Dispose and detach the placeholder process after extracting its command line.
- Ensure service deletion, handle cleanup, and base-controller disposal run even when remote-process validation throws.
- Add three regression cases covering disposal before startup, startup exceptions, and unexpected remote-process exit codes.
| File | Description |
|---|---|
src/libraries/Microsoft.Extensions.Hosting.WindowsServices/tests/WindowsServiceTester.cs |
Detaches the placeholder process and makes cleanup exception-safe while supporting repeated disposal. |
src/libraries/Microsoft.Extensions.Hosting.WindowsServices/tests/UseWindowsServiceTests.cs |
Adds cleanup regression cases that check service deletion and base disposal. |
Review effort: Balanced
svick
approved these changes
Nov 2, 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.
WindowsServiceTesterusesRemoteExecutorwithStart = falseto construct the service command line. If service startup throws, cleanup attempts to wait on the unstarted placeholder process. This replaces the original exception with “No process is associated with this object” and skips service deletion.Dispose and detach the placeholder immediately after extracting its command line. Ensure service deletion, handle cleanup and base-controller disposal run even when remote-process validation throws, while allowing repeated disposal.
Add three regression cases covering disposal without starting, failed startup and an unexpected remote-process exit code. These also check service deletion and base disposal.
This changes test infrastructure only. It fixes exception masking and cleanup; the underlying cause of the original service-start failure remains unknown.