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

Can't benchmark a netstandard2.0 project #537

Closed
CheloXL opened this Issue Sep 1, 2017 · 3 comments

Comments

Projects
None yet
3 participants
@CheloXL

CheloXL commented Sep 1, 2017

I'm getting the following error when trying to run the benchmark under .net core:

BenchmarkDotNet.Autogenerated.csproj : error NU1201: Project Memoizer.Benchmark.Dotnet is not compatible with netcoreapp1.1 (.NETCoreApp,Version=v1.1). Project Memoizer.Benchmark.Dotnet supports:
   - net462 (.NETFramework,Version=v4.6.2)
   - netcoreapp2.0 (.NETCoreApp,Version=v2.0)

The project is configured as following:

<TargetFrameworks>netcoreapp2.0;net462</TargetFrameworks> <RuntimeIdentifier>win7-x64</RuntimeIdentifier>

Please note that this very same project was working fine until I upgraded it to netstandard2.0

@adamsitnik

This comment has been minimized.

Show comment
Hide comment
@adamsitnik

adamsitnik Sep 2, 2017

Member

Hi @CheloXL

In BenchmarkDotNet we generate, build and run new project per every benchmark.

At some point of time we need to choose the target framework moniker (TFM).

When you are running your app with benchmark as .NET Core app, we just check the version of System.Runtime.dll which allows us to decide which version of .NET Core the user is using.

But when you are running your project as classic .NET (.NET 4.6.2 for example), we don't know which TFM to choose, so we use the default - netcoreapp1.1.

My question to you is following: does this problem occur when you run your benchmarks as .NET 4.6.2 only (dotnet run -c Release -f net462)? Or also when you run dotnet run -c Release -f netcoreapp2.0?

It should work fine with dotnet run -c Release -f netcoreapp2.0. For running .NET Core 2.0 benchmarks from .NET 4.6.2 context you have to use custom config:

public class MyConfig : ManualConfig
    {
        public MyConfig()
        {
            Add(Job.Default.With(CsProjCoreToolchain.NetCoreApp20)); // .NET Core 2.0

            Add(Job.Default.With(CsProjClassicNetToolchain.Net462)); // NET 4.6.2
        }
    }

If you use such config all your benchmarks are always going to be executed for .NET 4.6.2 and .NET Core 2.0

Member

adamsitnik commented Sep 2, 2017

Hi @CheloXL

In BenchmarkDotNet we generate, build and run new project per every benchmark.

At some point of time we need to choose the target framework moniker (TFM).

When you are running your app with benchmark as .NET Core app, we just check the version of System.Runtime.dll which allows us to decide which version of .NET Core the user is using.

But when you are running your project as classic .NET (.NET 4.6.2 for example), we don't know which TFM to choose, so we use the default - netcoreapp1.1.

My question to you is following: does this problem occur when you run your benchmarks as .NET 4.6.2 only (dotnet run -c Release -f net462)? Or also when you run dotnet run -c Release -f netcoreapp2.0?

It should work fine with dotnet run -c Release -f netcoreapp2.0. For running .NET Core 2.0 benchmarks from .NET 4.6.2 context you have to use custom config:

public class MyConfig : ManualConfig
    {
        public MyConfig()
        {
            Add(Job.Default.With(CsProjCoreToolchain.NetCoreApp20)); // .NET Core 2.0

            Add(Job.Default.With(CsProjClassicNetToolchain.Net462)); // NET 4.6.2
        }
    }

If you use such config all your benchmarks are always going to be executed for .NET 4.6.2 and .NET Core 2.0

@adamsitnik adamsitnik self-assigned this Sep 2, 2017

@adamsitnik adamsitnik closed this in ba7489f Sep 2, 2017

@adamsitnik

This comment has been minimized.

Show comment
Hide comment
@adamsitnik

adamsitnik Sep 2, 2017

Member

@CheloXL I added full explanation to our docs. If specifying the toolchain in an explicit way does not help please feel free to reopen this issue.

Member

adamsitnik commented Sep 2, 2017

@CheloXL I added full explanation to our docs. If specifying the toolchain in an explicit way does not help please feel free to reopen this issue.

@CheloXL

This comment has been minimized.

Show comment
Hide comment
@CheloXL

CheloXL Sep 2, 2017

@adamsitnik Excellent!, thanks. Yes, that works!.

CheloXL commented Sep 2, 2017

@adamsitnik Excellent!, thanks. Yes, that works!.

@AndreyAkinshin AndreyAkinshin added this to the v0.10.10 milestone Oct 29, 2017

alinasmirnova added a commit to alinasmirnova/BenchmarkDotNet that referenced this issue Sep 22, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment