Skip to content

Commit 39c4b9a

Browse files
committed
Use RoslynToolchain if dotnet SDK is not installed.
1 parent 28b671b commit 39c4b9a

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/BenchmarkDotNet/Toolchains/CsProj/CsProjClassicNetToolchain.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,9 @@ public override IEnumerable<ValidationError> Validate(BenchmarkCase benchmarkCas
4747
$"Classic .NET toolchain is supported only for Windows, benchmark '{benchmarkCase.DisplayInfo}' will not be executed",
4848
benchmarkCase);
4949
}
50-
else if (IsCliPathInvalid(customDotNetCliPath: null, benchmarkCase, out _))
50+
else if (IsCliPathInvalid(customDotNetCliPath: null, benchmarkCase, out var invalidCliError))
5151
{
52-
yield return new ValidationError(true,
53-
"CsProjClassicNetToolchain requires dotnet SDK to be installed or path to local dotnet cli provided in explicit way using `--cli` argument." +
54-
$" You may also use RoslynToolchain instead. Benchmark '{benchmarkCase.DisplayInfo}' will not be executed",
55-
benchmarkCase);
52+
yield return invalidCliError;
5653
}
5754
}
5855
}

src/BenchmarkDotNet/Toolchains/ToolchainExtensions.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,14 @@ internal static IToolchain GetToolchain(this Runtime runtime, Descriptor descrip
3434
switch (runtime)
3535
{
3636
case ClrRuntime clrRuntime:
37-
// Integration tests take too much time, because each benchmark run rebuilds the test suite and BenchmarkDotNet itself.
38-
// To reduce the total duration of the CI workflows, we just use RoslynToolchain.
39-
if (RuntimeInformation.IsFullFramework && XUnitHelper.IsIntegrationTest.Value)
37+
if (RuntimeInformation.IsFullFramework &&
38+
// If dotnet SDK is not installed, we use RoslynToolchain (CsProjClassicNetToolchain currently does not support custom cli path).
39+
(!HostEnvironmentInfo.GetCurrent().IsDotNetCliInstalled()
40+
// Integration tests take too much time, because each benchmark run rebuilds the test suite and BenchmarkDotNet itself.
41+
// To reduce the total duration of the CI workflows, we just use RoslynToolchain.
42+
|| XUnitHelper.IsIntegrationTest.Value))
4043
return RoslynToolchain.Instance;
4144

42-
// Default to CsProjClassicNetToolchain, even if the host is Full Framework.
43-
// If it doesn't work because the user doesn't have dotnet SDK installed, they can manually use RoslynToolchain in their config.
4445
return clrRuntime.RuntimeMoniker != RuntimeMoniker.NotRecognized
4546
? GetToolchain(clrRuntime.RuntimeMoniker)
4647
: CsProjClassicNetToolchain.From(clrRuntime.MsBuildMoniker);

0 commit comments

Comments
 (0)