Discovering nuget.exe Versions with tools.json

While updating my build failed with an upgrade from ASP.NET Core from 2.2 to 3.1. I was using Azure DevOps for my build.

I was getting a funny error:

##[error]The nuget command failed with exit code(1) and error(C:\Program Files\dotnet\sdk\2.2.110\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(137,5): error NETSDK1045: The current .NET SDK does not support targeting .NET Core 3.1.  Either target .NET Core 2.2 or lower, or use a version of the .NET SDK that supports .NET Core 3.1.)
##[error]Packages failed to restore
Finishing: NuGet restore

It turned out my build was set to an old version of NuGet, which has seen several updates for .NET Core.

I also learned Microsoft''s NuGet team publishes a json file detailing release history and preview releases at https://dist.nuget.org/tools.json. More detail on the contents of the file at docs.microsoft.com.