Skip to content

Running benchmark fails when targeting netcoreapp2.2 #995

@jasper-d

Description

@jasper-d

Running a benchmark fails when targeting netcoreapp2.2. That is because the *.Autogenerated.csproj. targets netcoreapp2.1 and references the original benchmark project that targets a higher netcoreapp version.

Repro:

  1. Create a new netcore CLI application that targets netcoreapp2.2
  2. Add a reference to BenchmarkDotNet v0.11.3
  3. Add any Benchmark w/o explicit configuration (the Md5VsSha256 example from the docs will do)
  4. Build the benchmark project: dotnet build -f netcoreapp2.2 -c Release -r win-x64 --no-incremental --force
  5. Run the benchmark like so: .\bin\Release\netcoreapp2.2\win-x64\Target22.exe

Expected:
The benchmark completes without errors.

Actual:
Running the benchmark (repro step 5) fails early when building the autogenerated code because the autogenerated csproj targets netcoreapp2.1 and references the original projects which targets 2.2.

Workaround:
Use an explicit configuration like so;

    private class DotNetCore22Config : ManualConfig
    {
        public DotNetCore22Config()
        {
            Add(Job.Default.With(CsProjCoreToolchain.NetCoreApp22));
        }
    }

Let me know if you need a complete sample project to reproduce.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions