Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use CsProjClassicNetToolchain as default toolchain in .Net Framework #2515

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@

namespace BenchmarkDotNet.Toolchains.CsProj
{
/// <summary>
/// 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!
/// </summary>
[PublicAPI]
public class CsProjClassicNetToolchain : Toolchain
{
Expand Down
7 changes: 6 additions & 1 deletion src/BenchmarkDotNet/Toolchains/ToolchainExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ValuePerTfm>(config);
}
Expand Down