From 077e4f366335721cabe0f8e5831c0be3b550ee87 Mon Sep 17 00:00:00 2001 From: Tim Date: Sat, 3 Feb 2024 21:14:59 -0500 Subject: [PATCH] Changed default toolchain for .Net Framework to `CsProjClassicNetToolchain`. Removed check in test. --- .../Toolchains/ToolchainExtensions.cs | 7 ++++++- .../MultipleFrameworksTest.cs | 14 -------------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/BenchmarkDotNet/Toolchains/ToolchainExtensions.cs b/src/BenchmarkDotNet/Toolchains/ToolchainExtensions.cs index c2872810fc..319ce86e80 100644 --- a/src/BenchmarkDotNet/Toolchains/ToolchainExtensions.cs +++ b/src/BenchmarkDotNet/Toolchains/ToolchainExtensions.cs @@ -36,7 +36,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 0e9eb6f80d..bf52f08ba5 100644 --- a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/MultipleFrameworksTest.cs +++ b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/MultipleFrameworksTest.cs @@ -22,20 +22,6 @@ public class MultipleFrameworksTest : BenchmarkTestExecutor [InlineData(RuntimeMoniker.Net80)] public void EachFrameworkIsRebuilt(RuntimeMoniker runtime) { -#if NET461 - // 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); }