'azure xamarin (android) - restore nuget - Project is not compatible with net5.0 (.NETCoreApp,Version=v5.0)

I am trying to build an android application using azure devops, but unfortunately I get an error during the task "NuGetCommand@2".I am using dotnet 6 in a project.

The nuget command failed with exit code(1) and error(NU1201: Project XXXXXXXX is not compatible with net5.0 (.NETCoreApp,Version=v5.0). Project XXXXXXXX supports: net6.0 (.NETCoreApp,Version=v6.0)

My pipeline:

trigger:
- master

pool:
   vmImage: 'windows-2022' 
variables:
  buildConfiguration: 'Debug'
  outputDirectory: '$(build.binariesDirectory)/$(buildConfiguration)'

steps:
- task: NuGetToolInstaller@1

- task: UseDotNet@2
   displayName: 'Use .NET Core sdk'
   inputs:
     packageType: sdk
     version: 6.0.201
     performMultiLevelLookup: true
    
- task: NuGetCommand@2
  inputs:
   command: 'restore'
   feedsToUse: config
   nugetConfigPath: nuget.config


- task: XamarinAndroid@1
  inputs:
    projectFile: '*.csproj'
    outputDirectory: '$(outputDirectory)'
    configuration: '$(buildConfiguration)'


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source