Tests not run on aspnet core 3.0 test project compiled by Azure Devops

Viewed 505

I have the following repository https://github.com/Mech0z/Foosball Where I have the following project file I would like the test step in pipelines to run

https://github.com/Mech0z/Foosball/blob/master/Integrationstest/Integrationstest.csproj

It has the following packages

<PackageReference Include="nunit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />

And my yaml file is like this

- task: VSTest@2
  inputs:
    projects: '**/*/Integrationstest.csproj'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

But when it runs I get

Test run will use DLL(s) built for framework .NETFramework,Version=v4.0 and platform X86. Following DLL(s) do not match framework/platform settings. Integrationstest.dll is built for Framework .NETCoreApp,Version=v3.0 and Platform AnyCPU.

How do I change the .NET framework in my yaml file?

2 Answers

Instead of using the VSTest task, use the DotNetCore task to run your tests e.g.

- task: DotNetCoreCLI@2
    inputs:
      command: "test"
      projects: "**/*/Integrationstest.csproj"
    displayName: Run the server-side tests

I had this problem in Azure DevOps and I had to add this to Other Console Options:

/Framework:.NETCoreApp,Version=v3.1

and specify the concrete .dll where tests are compiled. It was UnitTests.dll in my case, so in Test files I wrote:

**\bin\$(BuildConfiguration)\**\UnitTests.dll

and it fixed the issue.

Related