mercredi 3 avril 2019

Unable to build / test a .NET Core test project on Azure DevOps - invalid langversion

I'm trying to run a dotnet test in Azure DevOps but I keep getting this error:

ControllerTests/v1Tests/FooTests/DetailsAsyncTests.cs(241,64): error CS8107: Feature 'default literal' is not available in C# 7.0. Please use language version 7.1 or greater.

This is the start of my .csproj file..

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <LangVersion>7.3</LangVersion>
    <PackageId><snipped></PackageId>
    <Version>0.0.0</Version>
  </PropertyGroup>

...

and this is the start of my .yml file..

name: $(Year:yyyy).$(Month).$(DayOfMonth).$(Rev:r)
pool:
  vmImage: 'Ubuntu 16.04'

variables:
  buildConfiguration: 'Release'
....

steps

<snip>

- script: |
    dotnet test tests/snip/foo1.csproj --configuration $(buildConfiguration) -p:Version=$(Build.BuildNumber)
    dotnet test tests/snip/foo2.csproj --configuration $(buildConfiguration) -p:Version=$(Build.BuildNumber)
    dotnet test tests/snip/foo3.csproj --configuration $(buildConfiguration) -p:Version=$(Build.BuildNumber)
  displayName: 'dotnet test'

...

I've also tried <LangVersion>latest</LangVersion> in the .csproj.

I've tripped checked that the project file is has that <LangVersion> in it .. where the test is getting tested.

Can anyone suggest anything, please?

Aucun commentaire:

Enregistrer un commentaire