From a890b8cb7f33cc9f981777dd6963d5830c96a4c3 Mon Sep 17 00:00:00 2001 From: Tim Date: Sat, 3 Feb 2024 21:14:59 -0500 Subject: [PATCH] =?UTF-8?q?=EF=BB=BFChanged=20default=20toolchain=20for=20?= =?UTF-8?q?.Net=20Framework=20to=20`CsProjClassicNetToolchain`.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Toolchains/CsProj/CsProjClassicNetToolchain.cs | 4 ---- .../Toolchains/ToolchainExtensions.cs | 7 ++++++- .../MultipleFrameworksTest.cs | 14 -------------- 3 files changed, 6 insertions(+), 19 deletions(-) diff --git a/src/BenchmarkDotNet/Toolchains/CsProj/CsProjClassicNetToolchain.cs b/src/BenchmarkDotNet/Toolchains/CsProj/CsProjClassicNetToolchain.cs index 2761bd7c2c..ffe69eaed0 100644 --- a/src/BenchmarkDotNet/Toolchains/CsProj/CsProjClassicNetToolchain.cs +++ b/src/BenchmarkDotNet/Toolchains/CsProj/CsProjClassicNetToolchain.cs @@ -9,10 +9,6 @@ namespace BenchmarkDotNet.Toolchains.CsProj { - /// - /// this toolchain is designed for the new .csprojs, to build .NET 4.x benchmarks from the context of .NET Core host process - /// it does not work with the old .csprojs or project.json! - /// [PublicAPI] public class CsProjClassicNetToolchain : Toolchain { diff --git a/src/BenchmarkDotNet/Toolchains/ToolchainExtensions.cs b/src/BenchmarkDotNet/Toolchains/ToolchainExtensions.cs index 75d2898d0a..c628069a9f 100644 --- a/src/BenchmarkDotNet/Toolchains/ToolchainExtensions.cs +++ b/src/BenchmarkDotNet/Toolchains/ToolchainExtensions.cs @@ -37,7 +37,12 @@ internal static IToolchain GetToolchain(this Runtime runtime, Descriptor? descri { case ClrRuntime clrRuntime: if (!preferMsBuildToolchains && RuntimeInformation.IsFullFramework - && RuntimeInformation.GetCurrentRuntime().MsBuildMoniker == runtime.MsBuildMoniker) + && RuntimeInformation.GetCurrentRuntime().MsBuildMoniker == runtime.MsBuildMoniker + // If dotnet SDK is installed, we use CsProjClassicNetToolchain. + && (!HostEnvironmentInfo.GetCurrent().IsDotNetCliInstalled() + // Integration tests take too much time, because each benchmark run rebuilds the test suite and BenchmarkDotNet itself. + // To reduce the total duration of the CI workflows, we just use RoslynToolchain. + || XUnitHelper.IsIntegrationTest.Value)) { return RoslynToolchain.Instance; } diff --git a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/MultipleFrameworksTest.cs b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/MultipleFrameworksTest.cs index a73a47e7c2..53cde7d75a 100644 --- a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/MultipleFrameworksTest.cs +++ b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/MultipleFrameworksTest.cs @@ -19,20 +19,6 @@ public class MultipleFrameworksTest : BenchmarkTestExecutor [InlineData(RuntimeMoniker.Net80)] public void EachFrameworkIsRebuilt(RuntimeMoniker runtime) { -#if NET462 - // We cannot detect what target framework version the host was compiled for on full Framework, - // which causes the RoslynToolchain to be used instead of CsProjClassicNetToolchain when the host is full Framework - // (because full Framework always uses the version that's installed on the machine, unlike Core), - // which means if the machine has net48 installed (not net481), the net461 host with net48 runtime moniker - // will not be recompiled, causing the test to fail. - - // If we ever change the default toolchain to CsProjClassicNetToolchain instead of RoslynToolchain, we can remove this check. - if (runtime == RuntimeMoniker.Net48) - { - // XUnit doesn't provide Assert.Skip API yet. - return; - } -#endif var config = ManualConfig.CreateEmpty().AddJob(Job.Dry.WithRuntime(runtime.GetRuntime()).WithEnvironmentVariable(TfmEnvVarName, runtime.ToString())); CanExecute(config); }