Enable Hot Reload on CoreCLR for Android#11239
Closed
kotlarmilos wants to merge 1 commit intodotnet:mainfrom
Closed
Enable Hot Reload on CoreCLR for Android#11239kotlarmilos wants to merge 1 commit intodotnet:mainfrom
kotlarmilos wants to merge 1 commit intodotnet:mainfrom
Conversation
Route the Hot Reload settings through runtimeconfig.json configProperties so they reach CoreCLR at host init on Android. In Microsoft.Android.Sdk.HotReload.targets the STARTUP_HOOKS RuntimeHostConfigurationOption is no longer gated on UseMonoRuntime=true, and for CoreCLR debug builds two additional options are emitted: ModifiableAssemblies=debug and System.Reflection.Metadata.MetadataUpdater.IsSupported=true. Today these settings only reach Mono via __environment__.txt, which libmonodroid.so consumes before runtime init; CoreCLR's PAL snapshots the OS environment at startup and never reads that file, so the existing Mono path was a no-op for CoreCLR. The Mono path is unchanged. With this change, end-to-end dotnet watch Hot Reload works on the Android emulator with RuntimeFlavor=CoreCLR. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enables Hot Reload for Android apps running on CoreCLR by flowing dotnet-watch Hot Reload settings through runtimeconfig.json configProperties, ensuring CoreCLR receives them at host initialization (unlike the existing __environment__.txt path which CoreCLR doesn’t consume).
Changes:
- Emit
STARTUP_HOOKSviaRuntimeHostConfigurationOptionfor both MonoVM and CoreCLR so the Hot Reload agent is discoverable fromruntimeconfig.json. - For CoreCLR debug-symbol builds, also emit
ModifiableAssemblies=debugandSystem.Reflection.Metadata.MetadataUpdater.IsSupported=truevia runtimeconfig. - Update inline documentation/comments in
Microsoft.Android.Sdk.HotReload.targetsto reflect the CoreCLR behavior.
Show a summary per file
| File | Description |
|---|---|
src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.HotReload.targets |
Routes Hot Reload startup hooks and CoreCLR modifiable-assemblies settings through runtimeconfig so CoreCLR can pick them up at host init. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 1
Comment on lines
+66
to
+70
| which is required on Android where the DOTNET_STARTUP_HOOKS env var written | ||
| to __environment__.txt is only consumed by Mono via libmonodroid.so; | ||
| CoreCLR's PAL snapshots the OS environment at startup and never reads it. | ||
| --> | ||
| <RuntimeHostConfigurationOption Include="STARTUP_HOOKS" Value="$(_AndroidHotReloadAgentAssemblyName)" /> |
Member
Author
|
Closing this in favor of #11240 |
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.
Description
This PR routes the Hot Reload settings through
runtimeconfig.jsonconfigPropertiesso they reach CoreCLR at host init on Android. InMicrosoft.Android.Sdk.HotReload.targetstheSTARTUP_HOOKSRuntimeHostConfigurationOptionis no longer gated onUseMonoRuntime=true, and for CoreCLR debug builds two additional options are emitted:ModifiableAssemblies=debugandSystem.Reflection.Metadata.MetadataUpdater.IsSupported=true. Today these settings only reach Mono via__environment__.txt, whichlibmonodroid.soconsumes before runtime init; CoreCLR's PAL snapshots the OS environment at startup and never reads that file, so the existing Mono path was a no-op for CoreCLR. The Mono path is unchanged.With this PR, end-to-end
dotnet watchHot Reload works on the Android emulator withRuntimeFlavor=CoreCLR.