-
Notifications
You must be signed in to change notification settings - Fork 5.1k
[Android][CoreCLR] Use runtimeconfig.bin for runtime configuration lookup in ApkBuilder #118674
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: davidnguyen-tech <[email protected]>
…-specific runtimeconfig.json Co-authored-by: davidnguyen-tech <[email protected]>
…timeConfigProperties Co-authored-by: davidnguyen-tech <[email protected]>
…ection.Metadata Co-authored-by: davidnguyen-tech <[email protected]>
Co-authored-by: davidnguyen-tech <[email protected]>
/azp run runtime-android,runtime-androidemulator |
Azure Pipelines successfully started running 2 pipeline(s). |
/azp run runtime-android,runtime-androidemulator |
Azure Pipelines successfully started running 2 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this 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 fixes a critical bug in the AndroidAppBuilder where it was incorrectly looking for {ProjectName}.runtimeconfig.json
instead of the actual generated file {AssemblyName}.runtimeconfig.json
, causing test failures. The solution switches to using the standardized runtimeconfig.bin
binary format for runtime configuration lookup.
Key Changes:
- Modified
ParseRuntimeConfigProperties
method to read fromruntimeconfig.bin
instead of guessing JSON filenames - Implemented binary format parsing using
BlobReader
fromSystem.Reflection.Metadata
- Added unsafe code support to enable direct memory access for efficient binary reading
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
src/tasks/AndroidAppBuilder/ApkBuilder.cs | Replaced JSON-based runtime config parsing with binary format reading using BlobReader |
src/tasks/AndroidAppBuilder/AndroidAppBuilder.csproj | Added AllowUnsafeBlocks property to enable unsafe code for binary reading |
src/tasks/TestExclusionListTasks/TestExclusionListTasks.csproj | Added AllowUnsafeBlocks property (appears unrelated to main changes) |
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
Tagging subscribers to this area: @hoyosjs |
The AndroidAppBuilder was incorrectly looking for
{ProjectName}.runtimeconfig.json
when the actual generated file is named{AssemblyName}.runtimeconfig.json
, causing the CoreCLR Android test host to fail finding the runtime configuration file.Problem
When building Android apps and especially when running tests:
mainLibraryFileName
is set toAndroidTestRunner.dll
AndroidTestRunner.runtimeconfig.json
for all tests is incorrect as each test project has its own configurationCould not find file 'HelloAndroid.runtimeconfig.json'
Solution
Modified the
ParseRuntimeConfigProperties
method to use the standardizedruntimeconfig.bin
file instead of trying to guess the correct JSON filename. This binary file is created by MSBuild'sRuntimeConfigParserTask
and contains the same configuration properties in a binary format.The implementation uses the existing
BlobReader
fromSystem.Reflection.Metadata
to read the binary format, which provides the necessaryReadCompressedInteger()
andReadSerializedString()
methods that mirror theBlobBuilder
write operations.Before:
After:
The solution maintains the same functionality of extracting configProperties for the CoreCLR Android template while working reliably for both apps and test scenarios.
Fixes #118162.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.