The Azure pipeline stopped working on Friday afternoon for no reason. It even stopped on the main branch although it was working before and the pull request build was green. I got the following error message with random packages.
##[error]The nuget command failed with exit code(1) and error(NU1202: Package <Random Package> x.y.z is not compatible with net70 (.NETFramework,Version=v7.0). <Random Package> x.y.z supports: netcoreapp3.1 (.NETCoreApp,Version=v3.1)
Hence it fails on branches, main, tags, and everything else, it must be related to the pipeline itself and not the code. After checking the pipeline it turned out that the NuGetCommand failed.
But wait, what is this? It is using NuGet version 4.9.6, an quite old version. Did this ever worked in the past? So let us check on old but working build pipeline.
It seems that it is using a newer version of the NuGetCommand but an older version of the nuget tool itself. This explains a lot and especially the missing net70 support.
NuGetCommand 2.220.2 uses NuGet 5.8.0 but
NuGetCommand 2.221.2 uses NuGet 188.8.131.52
The fix was a explicit installation of NuGet 5.x before the restore. After the manual installation of the right tool in the Azure pipeline, it works.
- task: NuGetToolInstaller@1 inputs: versionSpec: 5.x
And here is the new output of the NuGet restore. Newer version of the command and now Nuget 5.11.3 -even newer than in NuGetCommand 2.220.2.