BDN workaround for netcoreapp5.0->net5.0 moniker rebranding (#23000)

This commit is contained in:
Adam Sitnik 2020-06-17 03:43:40 +02:00 committed by GitHub
parent 29bbf06c77
commit 580a6cce0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 1 deletions

View File

@ -9,7 +9,10 @@ using System.Reflection;
using System.Text;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Running;
using BenchmarkDotNet.Toolchains.CsProj;
using BenchmarkDotNet.Toolchains.DotNetCli;
namespace Microsoft.AspNetCore.BenchmarkDotNet.Runner
{
@ -26,7 +29,7 @@ namespace Microsoft.AspNetCore.BenchmarkDotNet.Runner
AssignConfiguration(ref args);
var summaries = BenchmarkSwitcher.FromAssembly(typeof(Program).GetTypeInfo().Assembly)
.Run(args, ManualConfig.CreateEmpty());
.Run(args, GetConfig());
foreach (var summary in summaries)
{
@ -57,6 +60,24 @@ namespace Microsoft.AspNetCore.BenchmarkDotNet.Runner
return 0;
}
private static IConfig GetConfig()
{
#if NET5_0 || NETCOREAPP5_0
return ManualConfig.CreateEmpty()
.AddJob(Job.Default
.WithToolchain(CsProjCoreToolchain.From(new NetCoreAppSettings
(
// not using "net5.0", a workaround for https://github.com/dotnet/BenchmarkDotNet/pull/1479
targetFrameworkMoniker: "netcoreapp5.0",
runtimeFrameworkVersion: default,
name: ".NET Core 5.0"
)))
.AsDefault());
#else
return ManualConfig.CreateEmpty();
#endif
}
private static int Fail(object o, string message)
{
_standardOutput?.WriteLine(_standardOutputText.ToString());