diff --git a/samples/BenchmarkDotNet.Samples/BenchmarkDotNet.Samples.csproj b/samples/BenchmarkDotNet.Samples/BenchmarkDotNet.Samples.csproj index e5180664ef..729895ed5b 100644 --- a/samples/BenchmarkDotNet.Samples/BenchmarkDotNet.Samples.csproj +++ b/samples/BenchmarkDotNet.Samples/BenchmarkDotNet.Samples.csproj @@ -16,11 +16,10 @@ - - - + + diff --git a/samples/BenchmarkDotNet.Samples/IntroNuGet.cs b/samples/BenchmarkDotNet.Samples/IntroNuGet.cs index 6034699612..a368b62b56 100644 --- a/samples/BenchmarkDotNet.Samples/IntroNuGet.cs +++ b/samples/BenchmarkDotNet.Samples/IntroNuGet.cs @@ -27,15 +27,15 @@ public Config() var baseJob = Job.MediumRun; string[] targetVersions = [ + "9.0.0", "9.0.3", - "9.0.4", "9.0.5", ]; foreach (var version in targetVersions) { AddJob(baseJob.WithNuGet("System.Collections.Immutable", version) - .WithId("v"+version)); + .WithId($"v{version}")); } } } diff --git a/src/BenchmarkDotNet.TestAdapter/BenchmarkEnumerator.cs b/src/BenchmarkDotNet.TestAdapter/BenchmarkEnumerator.cs index daf3e2222e..d49c3d24e1 100644 --- a/src/BenchmarkDotNet.TestAdapter/BenchmarkEnumerator.cs +++ b/src/BenchmarkDotNet.TestAdapter/BenchmarkEnumerator.cs @@ -3,7 +3,7 @@ using BenchmarkDotNet.Running; using BenchmarkDotNet.Toolchains; using System; -using System.Collections.Generic; +using System.IO; using System.Linq; using System.Reflection; @@ -21,6 +21,28 @@ internal static class BenchmarkEnumerator /// The benchmarks inside the assembly. public static BenchmarkRunInfo[] GetBenchmarksFromAssemblyPath(string assemblyPath) { +#if NET462 + // Temporary workaround for BenchmarkDotNet assembly loading issue that occurred under the following conditions: + // 1. Run BenchmarkDotNet.Samples project with following command. + // > dotnet test -c Release --list-tests --framework net462 -tl:off + // 2. When using `BenchmarkDotNet.TestAdapter` package and targeting .NET Framework. + AppDomain.CurrentDomain.AssemblyResolve += (sender, eventArgs) => + { + if (eventArgs.Name.StartsWith("BenchmarkDotNet, Version=")) + { + var baseDir = Path.GetDirectoryName(assemblyPath); + var path = Path.Combine(baseDir, "BenchmarkDotNet.dll"); + if (File.Exists(path)) + { + return Assembly.LoadFrom(path); + } + } + + // Fallback to default assembly resolver + return null; + }; +#endif + var assembly = Assembly.LoadFrom(assemblyPath); var isDebugAssembly = assembly.IsJitOptimizationDisabled() ?? false; diff --git a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks.csproj b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks.csproj index 4b4325f319..37dfe950f7 100644 --- a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks.csproj +++ b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks.csproj @@ -30,7 +30,6 @@ - diff --git a/tests/BenchmarkDotNet.IntegrationTests/BenchmarkDotNet.IntegrationTests.csproj b/tests/BenchmarkDotNet.IntegrationTests/BenchmarkDotNet.IntegrationTests.csproj index d063998304..8c0cb40557 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/BenchmarkDotNet.IntegrationTests.csproj +++ b/tests/BenchmarkDotNet.IntegrationTests/BenchmarkDotNet.IntegrationTests.csproj @@ -35,8 +35,8 @@ - - + + all diff --git a/tests/BenchmarkDotNet.Tests/BenchmarkDotNet.Tests.csproj b/tests/BenchmarkDotNet.Tests/BenchmarkDotNet.Tests.csproj index 1d653e20a2..b37e22deda 100755 --- a/tests/BenchmarkDotNet.Tests/BenchmarkDotNet.Tests.csproj +++ b/tests/BenchmarkDotNet.Tests/BenchmarkDotNet.Tests.csproj @@ -26,7 +26,6 @@ -