Skip to content

Failed to benchmark .NET 7 in release mode #1900

@Symbai

Description

@Symbai

BenchmarkDotNet: 0.13.1
Visual Studio 2022 Preview 2
.NET 7.0-master

I've installed .NET 7 master SDK. My benchmark project runs fine with .NET 6. But with .NET 7 I get a build error:

// Build Error: Standard output:

 Standard error:
   Restored C:\Users\Peter\Documents\TestProject\TestProject.Benchmark\TestProject.Benchmark.csproj (in 250 ms).
  Restored C:\Users\Peter\Documents\TestProject\TestProject\TestProject.csproj (in 228 ms).
  Failed to restore C:\Users\Peter\Documents\TestProject\TestProject.Benchmark\bin\Release\net7.0-windows\1d81826c-9275-4f41-bf97-6b046a535809\BenchmarkDotNet.Autogenerated.csproj (in 108 ms).
C:\Users\Peter\Documents\TestProject\TestProject.Benchmark\bin\Release\net7.0-windows\1d81826c-9275-4f41-bf97-6b046a535809\BenchmarkDotNet.Autogenerated.csproj : error NU1201: Project TestProject.Benchmark is not compatible with net7.0 (.NETCoreApp,Version=v7.0). Project TestProject.Benchmark supports: net7.0-windows7.0 (.NETCoreApp,Version=v7.0)
  Determining projects to restore...

// BenchmarkDotNet has failed to build the auto-generated boilerplate code.
// It can be found in C:\Users\Peter\Documents\TestProject\TestProject.Benchmark\bin\Release\net7.0-windows\1d81826c-9275-4f41-bf97-6b046a535809
// Please follow the troubleshooting guide: https://benchmarkdotnet.org/articles/guides/troubleshooting.html

The most interesting sentence here is probably this one: Project TestProject.Benchmark is not compatible with net7.0 (.NETCoreApp,Version=v7.0). Project TestProject.Benchmark supports: net7.0-windows7.0 (.NETCoreApp,Version=v7.0)

Which is actually funny because my benchmark project is set to .NET 7 AND debugging it works fine. Even all my tests run in DEBUG mode in VS following the troubleshooting guide. Its only the release mode where the benchmark fails.

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net7.0-windows</TargetFramework>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <PlatformTarget>x64</PlatformTarget>
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
    <PlatformTarget>x64</PlatformTarget>
  </PropertyGroup>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions