Skip to content

Commit 1d099e7

Browse files
[tests] use @(RuntimeHostConfigurationOption) (#9890)
NativeAOT doesn't support `runtimeconfig.template.json` and it emits the build warning: D:\.nuget\packages\microsoft.dotnet.ilcompiler\10.0.0-preview.3.25152.2\build\Microsoft.NETCore.Native.Publish.targets(46,5): The published project has a runtimeconfig.template.json that is not supported by PublishAot. Move the configuration to the project file using RuntimeHostConfigurationOption. So, instead of using `runtimeconfig.template.json` with contents: { "configProperties": { "test_bool": true, "test_integer": 42, "test_string": "foo" } } You can simply define them in your `.csproj` with the [`@(RuntimeHostConfigurationOption)` item group][0] <ItemGroup> <RuntimeHostConfigurationOption Include="test_bool" Value="true" /> <RuntimeHostConfigurationOption Include="test_integer" Value="42" /> <RuntimeHostConfigurationOption Include="test_string" Value="foo" /> </ItemGroup> Honestly, I think I prefer the MSBuild item group. We don't necessarily care how the values are defined, just that these values at build time are set at runtime, and we can assert them in `AppContextTests.cs`. [0]: https://learn.microsoft.com/en-us/dotnet/core/runtime-config/#msbuild-properties
1 parent 684ede6 commit 1d099e7

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj

+7
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,13 @@
206206
<AndroidNativeLibrary Include="..\libs\x86_64\libreuse-threads.so" />
207207
</ItemGroup>
208208

209+
<!-- Used by AppContextTests.cs -->
210+
<ItemGroup>
211+
<RuntimeHostConfigurationOption Include="test_bool" Value="true" />
212+
<RuntimeHostConfigurationOption Include="test_integer" Value="42" />
213+
<RuntimeHostConfigurationOption Include="test_string" Value="foo" />
214+
</ItemGroup>
215+
209216
<ItemGroup Condition=" '$(AndroidPackageFormat)' != 'aab' ">
210217
<TestApk Include="$(OutputPath)$(_MonoAndroidTestPackage)-Signed.apk">
211218
<Package>$(_MonoAndroidTestPackage)</Package>

tests/Mono.Android-Tests/Mono.Android-Tests/runtimeconfig.template.json

-7
This file was deleted.

0 commit comments

Comments
 (0)