Skip to content

Fix Windows service test cleanup masking startup errors - #136696

Merged
svick merged 2 commits into
dotnet:mainfrom
rosebyte:rosebyte-windows-service-failure
Nov 12, 2026
Merged

svick merged 2 commits into
dotnet:mainfrom
rosebyte:rosebyte-windows-service-failure

Conversation

@rosebyte

Copy link
Copy Markdown
Member

WindowsServiceTester uses RemoteExecutor with Start = false to 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.

@azure-pipelines

Copy link
Copy Markdown
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.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-extensions-hosting
See info in area-owners.md if you want to be subscribed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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
svick merged commit 23729a1 into dotnet:main Nov 12, 2026
82 of 84 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants