Skip to content

Setting LangVersion to Latest Causes an Error #1452

Closed
@JasonBock

Description

@JasonBock

To reproduce this:

Create a new .NET Core console app with this in the .csproj file:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <LangVersion>latest</LangVersion>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.1</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="BenchmarkDotNet" Version="0.12.1" />
  </ItemGroup>
</Project>

Set the Program.cs file to have the same code as shown in the "Getting Started" page: https://benchmarkdotnet.org/articles/guides/getting-started.html.

The key is the setting for <LangVersion>. If I set it to a specific value, like 8.0, the tests run as expected. If I set it to latest, I get this error:

 Standard error:
 C:\Users\JasonB\source\repos\ConsoleApp35\ConsoleApp35\bin\Release\netcoreapp3.1\0192f748-6e76-46a0-a2b2-8204fb24ddc7\BenchmarkDotNet.Autogenerated.csproj(20,18): error MSB4086: A numeric comparison was attempted on "$(LangVersion)" that evaluates to "latest" instead of a number, in condition "'$(LangVersion)' == '' Or '$(LangVersion)' < '7.3'".

latest and preview values are valid, so this should not cause a problem.

Activity

adamsitnik

adamsitnik commented on May 11, 2020

@adamsitnik
Member

Hello @JasonBock

It's a bug that I've introduced in 0.12.1 and it was fixed in #1420 which is going to be part of next release.

For now please set the <LangVersion> to a number or downgrade to 0.12.0.

Thanks,
Adam

added this to the v0.12.2 milestone on Sep 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @JasonBock@AndreyAkinshin@adamsitnik

        Issue actions

          Setting LangVersion to Latest Causes an Error · Issue #1452 · dotnet/BenchmarkDotNet