Unit Tests in a .NET 6 project with Azure Pipelines DotNetCoreCLI@2

Today I migrated our project from .NET 5 to .NET 6.

An issue I stumbled upon was the Azure YAML Pipeline throwing an error in the DotNetCoreCLI@2 task with the ‘test’ command:

It was not possible to find any compatible framework version
The framework 'Microsoft.AspNetCore.App', version '5.0.0' (x64) was not found.
- The following frameworks were found:
6.0.0 at [C:\hostedtoolcache\windows\dotnet\shared\Microsoft.AspNetCore.App]

As described in this GitHub issue you have to add the UseDotNet@2 task and select version ‘6.0.x’ which was already the case. Also note that vmImage ‘windows-latest’ still targets 2019, so if you use a Windows vmImage, specify ‘windows-2022’. But I use ‘ubuntu latest’. So this didn’t solve my issue.

This StackOverflow answer did solve my issue. I included a ‘restore’ step and in the ‘test’ step added an argument not to restore.

> The solution that worked for me can be found in this GitHub gist.
Note the following parts:

GitHub Gist focus image

Integration Consultant with a focus on Microsoft Azure.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Access unsecured cams using these google strings.

Practice writing specific tests

Difference between a DIT and a SDET?

Missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun and Why.

Feature release

LIMIT 5 — How to Update Window Functions in Incremental Materializations with dbt and Snowflake

Become a professional Googler

From relational databases to Hadoop using Apache Sqoop

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jeroen VdB

Jeroen VdB

Integration Consultant with a focus on Microsoft Azure.

More from Medium

A Beginners Guideline to RabbitMq and MassTransit(Part 2): Implement RabbitMQ in Code with…

Jwt authentication for .Net5 WebApi project with RSA private/public keys

Part IV- Integrate Aspnetcore OData API Authentication with Swagger

ASP.Net Core WebAPI Dockerize and Deploy to Azure