Skip to content

[Android][CoreCLR] Test host has trouble finding runtimeconfig.json #118162

@davidnguyen-tech

Description

@davidnguyen-tech

Description

When building the sample Android app at src/mono/sample/Android/AndroidSampleApp.csproj, our test host for CoreCLR Android has trouble finding the runtimeconfig.json file, but in some test projects like Invariant.Tests.csproj or those enabled in #117980, it works.

The problem most probably lies in src/tasks/AndroidAppBuilder/ApkBuilder.cs, line 689. Here, we try to look for [appname].runtimeconfig.json, following the docs.

In some cases, this works well, but in other cases, like in the sample, the generated .json file name has the format of [assemblyname].runtimeconfig.json.

E.g. for the sample app, the assembly name is AndroidSampleApp and the app name is HelloAndroid. Then, AndroidSampleApp.runtimeconfig.json is generated, but we're looking for HelloAndroid.runtimeconfig.json, which doesn't exist.

Options

  • Look for [assemblyname].runtimeconfig.json as a fallback if [appname].runtimeconfig.json isn't found. Not sure if this behaviour is correct, as the docs say it should be [appname].runtimeconfig.json - I might have misunderstood the docs, though.
  • Load runtimeconfig.bin instead of .json - evades the naming problem completely. Source code of generating this file can be found in src/tasks/MonoTargetsTasks/RuntimeConfigParser/RuntimeConfigParser.cs.

Reproduction Steps

  1. Build the runtime
build.sh --os android -a x64 -s clr.runtime+clr.alljits+clr.corelib+clr.nativecorelib+clr.tools+clr.packages+libs+libs.tests+host+packs -c Release /p:ArchiveTests=true /p:RunSmokeTestsOnly=True
  1. Build the sample app
make BUILD_CONFIG=Release TARGET_ARCH=x64 RUNTIME_FLAVOR=CoreCLR DEPLOY_AND_RUN=false run -C src/mono/sample/Android

Expected behavior

The HelloAndroid.runtimeconfig.json file IS found.

Actual behavior

The HelloAndroid.runtimeconfig.json is NOT found with error message in terminal looking approximately like this (it will show the local absolute path instead of relative):

Error while parsing runtime config at `artifacts/bin/AndroidSampleApp/x64/Release/android-x64/publish/HelloAndroid.runtimeconfig.json`: Could not find file `artifacts/bin/AndroidSampleApp/x64/Release/android-x64/publish/HelloAndroid.runtimeconfig.json` 

Metadata

Metadata

Type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions