BenchmarkDotNet icon indicating copy to clipboard operation
BenchmarkDotNet copied to clipboard

Add support for `runtimeconfig.template.json`

Open dotMorten opened this issue 2 years ago • 3 comments

If I add RuntimeHostConfigurationOption to the benchmark project like this:

<ItemGroup>
    <RuntimeHostConfigurationOption Include="System.Runtime.Loader.UseRidGraph" Value="true" />
  </ItemGroup>

The built project will have this added to [appname].runtimeconfig.json:

{
  "runtimeOptions": {
     "configProperties": {
        "System.Runtime.Loader.UseRidGraph": true
     }
  }
}

This is important to be able to deal with this breaking change in .NET 8:

https://learn.microsoft.com/en-us/dotnet/core/compatibility/deployment/8.0/rid-asset-list#recommended-action

However, the generated project does not copy this setting over, so the resulting project will not get the correct value injected into its runtimeconfig.json. An alternative way is to add a runtimeconfig.template.json file with the above json, but again, the generated project will not pick this up.

Perhaps https://github.com/dotnet/BenchmarkDotNet/blob/ece5ccfc91d92b610338b05da73d2a91508e2837/src/BenchmarkDotNet/Toolchains/CsProj/CsProjGenerator.cs#L26 needs RuntimeHostConfigurationOption added, and also a way to make sure runtimeconfig.template.json files are copied as well.

dotMorten avatar Sep 12 '23 03:09 dotMorten

Reopening for someone to add support for runtimeconfig.template.json.

timcassell avatar Oct 27 '23 01:10 timcassell