Repository: dotnet/BenchmarkDotNet

Issue:
Add support for `runtimeconfig.template.json`
If I add RuntimeHostConfigurationOption to the benchmark project like this:
```xml
<ItemGroup>
    <RuntimeHostConfigurationOption Include="System.Runtime.Loader.UseRidGraph" Value="true" />
  </ItemGroup>
```
The built project will have this added to [appname].runtimeconfig.json:
```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.


Hints:

Patch:
diff --git a/src/BenchmarkDotNet/Toolchains/CsProj/CsProjGenerator.cs b/src/BenchmarkDotNet/Toolchains/CsProj/CsProjGenerator.cs
index af12d018b5..eaf1da4683 100644
--- a/src/BenchmarkDotNet/Toolchains/CsProj/CsProjGenerator.cs
+++ b/src/BenchmarkDotNet/Toolchains/CsProj/CsProjGenerator.cs
@@ -34,7 +34,8 @@ public class CsProjGenerator : DotNetCliGenerator, IEquatable<CsProjGenerator>
             "CopyLocalLockFileAssemblies",
             "PreserveCompilationContext",
             "UserSecretsId",
-            "EnablePreviewFeatures"
+            "EnablePreviewFeatures",
+            "RuntimeHostConfigurationOption",
         }.ToImmutableArray();
 
         public string RuntimeFrameworkVersion { get; }


Test patch:
diff --git a/tests/BenchmarkDotNet.Tests/CsProjGeneratorTests.cs b/tests/BenchmarkDotNet.Tests/CsProjGeneratorTests.cs
index 715d7dad64..323da8ddba 100644
--- a/tests/BenchmarkDotNet.Tests/CsProjGeneratorTests.cs
+++ b/tests/BenchmarkDotNet.Tests/CsProjGeneratorTests.cs
@@ -18,6 +18,11 @@ namespace BenchmarkDotNet.Tests
     public class CsProjGeneratorTests
     {
         private FileInfo TestAssemblyFileInfo = new FileInfo(typeof(CsProjGeneratorTests).Assembly.Location);
+        private const string runtimeHostConfigurationOptionChunk = """
+<ItemGroup>
+  <RuntimeHostConfigurationOption Include="System.Runtime.Loader.UseRidGraph" Value="true" />
+</ItemGroup>
+""";
 
         [Theory]
         [InlineData("net471", false)]
@@ -68,7 +73,7 @@ private void AssertParsedSdkName(string csProjContent, string targetFrameworkMon
 
         private static void AssertCustomProperties(string expected, string actual)
         {
-            Assert.Equal(expected.Replace(Environment.NewLine, "\n").Replace("\n", Environment.NewLine), actual);
+            Assert.Equal(expected.Replace("\r", "").Replace("\n", Environment.NewLine), actual);
         }
 
         [Fact]
@@ -158,6 +163,24 @@ public void SettingsFromPropsFileImportedUsingRelativePathGetCopies()
             File.Delete(propsFilePath);
         }
 
+        [Fact]
+        public void RuntimeHostConfigurationOptionIsCopied()
+        {
+            string source = $@"
+<Project Sdk=""Microsoft.NET.Sdk"">
+{runtimeHostConfigurationOptionChunk}
+</Project>";
+
+            var sut = new CsProjGenerator("netcoreapp3.0", null, null, null, true);
+
+            var xmlDoc = new XmlDocument();
+            xmlDoc.LoadXml(source);
+            var (customProperties, sdkName) = sut.GetSettingsThatNeedToBeCopied(xmlDoc, TestAssemblyFileInfo);
+
+            AssertCustomProperties(runtimeHostConfigurationOptionChunk, customProperties);
+            Assert.Equal("Microsoft.NET.Sdk", sdkName);
+        }
+
         [Fact]
         public void TheDefaultFilePathShouldBeUsedWhenAnAssemblyLocationIsEmpty()
         {