Skip to content

Conversation

@jonathanpeppers
Copy link
Member

Context: https://github.com/dotnet/runtime/blob/741b7157472b9a5c83a78f781ccfa8cd39707763/docs/design/features/host-startup-hook.md
Context: dotnet/android#10755

Mono does not appear to read the $DOTNET_STARTUP_HOOKS env var when calling System.StartupHookProvider.ProcessStartupHooks() and only passes in "".

So, to get the same behavior as other runtimes, you would need to workaround with something like:

<RuntimeHostConfigurationOption Include="STARTUP_HOOKS" Value="MyStartupHook" Condition=" '$(UseMonoRuntime)' == 'true' " />

Let's read the env var in Mono so that it works the same way as other runtimes.

Context: https://github.com/dotnet/runtime/blob/741b7157472b9a5c83a78f781ccfa8cd39707763/docs/design/features/host-startup-hook.md
Context: dotnet/android#10755

Mono does not appear to read the `$DOTNET_STARTUP_HOOKS` env var when
calling `System.StartupHookProvider.ProcessStartupHooks()` and only
passes in `""`.

So, to get the same behavior as other runtimes, you would need to
workaround with something like:

    <RuntimeHostConfigurationOption Include="STARTUP_HOOKS" Value="MyStartupHook" Condition=" '$(UseMonoRuntime)' == 'true' " />

Let's read the env var in Mono so that it works the same way as other
runtimes.
Copilot AI review requested due to automatic review settings February 3, 2026 21:13
@github-actions github-actions bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Feb 3, 2026
@jonathanpeppers jonathanpeppers added the area-EnC-mono Hot Reload for WebAssembly, iOS/Android, etc label Feb 3, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for reading the DOTNET_STARTUP_HOOKS environment variable in Mono runtime to match the behavior of CoreCLR and NativeAOT runtimes. Previously, Mono only passed an empty string to System.StartupHookProvider.ProcessStartupHooks(), ignoring the environment variable.

Changes:

  • Mono now reads DOTNET_STARTUP_HOOKS environment variable and passes its value to the startup hook processor
  • This aligns Mono's behavior with CoreCLR and NativeAOT implementations
  • Eliminates the need for workarounds using STARTUP_HOOKS runtime configuration option when using Mono

@jonathanpeppers jonathanpeppers marked this pull request as ready for review February 4, 2026 18:18
Copilot AI review requested due to automatic review settings February 4, 2026 18:18
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@steveisok steveisok requested a review from lewing February 4, 2026 20:03
@lewing lewing merged commit c8e2a61 into dotnet:main Feb 5, 2026
77 checks passed
lewing pushed a commit to lewing/runtime that referenced this pull request Feb 9, 2026
Context:
https://github.com/dotnet/runtime/blob/741b7157472b9a5c83a78f781ccfa8cd39707763/docs/design/features/host-startup-hook.md
Context: dotnet/android#10755

Mono does not appear to read the `$DOTNET_STARTUP_HOOKS` env var when
calling `System.StartupHookProvider.ProcessStartupHooks()` and only
passes in `""`.

So, to get the same behavior as other runtimes, you would need to
workaround with something like:

<RuntimeHostConfigurationOption Include="STARTUP_HOOKS"
Value="MyStartupHook" Condition=" '$(UseMonoRuntime)' == 'true' " />

Let's read the env var in Mono so that it works the same way as other
runtimes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-EnC-mono Hot Reload for WebAssembly, iOS/Android, etc needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants