You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[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
0 commit comments