Skip to content

Commit a890b8c

Browse files
committedSep 22, 2024·
Changed default toolchain for .Net Framework to CsProjClassicNetToolchain.
1 parent adf8e6d commit a890b8c

File tree

3 files changed

+6
-19
lines changed

3 files changed

+6
-19
lines changed
 

‎src/BenchmarkDotNet/Toolchains/CsProj/CsProjClassicNetToolchain.cs

-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99

1010
namespace BenchmarkDotNet.Toolchains.CsProj
1111
{
12-
/// <summary>
13-
/// this toolchain is designed for the new .csprojs, to build .NET 4.x benchmarks from the context of .NET Core host process
14-
/// it does not work with the old .csprojs or project.json!
15-
/// </summary>
1612
[PublicAPI]
1713
public class CsProjClassicNetToolchain : Toolchain
1814
{

‎src/BenchmarkDotNet/Toolchains/ToolchainExtensions.cs

+6-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@ internal static IToolchain GetToolchain(this Runtime runtime, Descriptor? descri
3737
{
3838
case ClrRuntime clrRuntime:
3939
if (!preferMsBuildToolchains && RuntimeInformation.IsFullFramework
40-
&& RuntimeInformation.GetCurrentRuntime().MsBuildMoniker == runtime.MsBuildMoniker)
40+
&& RuntimeInformation.GetCurrentRuntime().MsBuildMoniker == runtime.MsBuildMoniker
41+
// If dotnet SDK is installed, we use CsProjClassicNetToolchain.
42+
&& (!HostEnvironmentInfo.GetCurrent().IsDotNetCliInstalled()
43+
// Integration tests take too much time, because each benchmark run rebuilds the test suite and BenchmarkDotNet itself.
44+
// To reduce the total duration of the CI workflows, we just use RoslynToolchain.
45+
|| XUnitHelper.IsIntegrationTest.Value))
4146
{
4247
return RoslynToolchain.Instance;
4348
}

‎tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/MultipleFrameworksTest.cs

-14
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,6 @@ public class MultipleFrameworksTest : BenchmarkTestExecutor
1919
[InlineData(RuntimeMoniker.Net80)]
2020
public void EachFrameworkIsRebuilt(RuntimeMoniker runtime)
2121
{
22-
#if NET462
23-
// We cannot detect what target framework version the host was compiled for on full Framework,
24-
// which causes the RoslynToolchain to be used instead of CsProjClassicNetToolchain when the host is full Framework
25-
// (because full Framework always uses the version that's installed on the machine, unlike Core),
26-
// which means if the machine has net48 installed (not net481), the net461 host with net48 runtime moniker
27-
// will not be recompiled, causing the test to fail.
28-
29-
// If we ever change the default toolchain to CsProjClassicNetToolchain instead of RoslynToolchain, we can remove this check.
30-
if (runtime == RuntimeMoniker.Net48)
31-
{
32-
// XUnit doesn't provide Assert.Skip API yet.
33-
return;
34-
}
35-
#endif
3622
var config = ManualConfig.CreateEmpty().AddJob(Job.Dry.WithRuntime(runtime.GetRuntime()).WithEnvironmentVariable(TfmEnvVarName, runtime.ToString()));
3723
CanExecute<ValuePerTfm>(config);
3824
}

0 commit comments

Comments
 (0)
Please sign in to comment.