I am building an Azure Function project, so I cannot target .NET 5. Instead, my project is a netcoreapp3.1.
However, when my project is built, anytime there is some information printed, I see dotnet 5 being mentioned. Example:
##[warning]/usr/share/dotnet/sdk/5.0.101/Microsoft.Common.CurrentVersion.targets(2123,5): Warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.Text.Json, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
(The issue that I'm having with System.Text.Json is a problem of its own, in this post I'd like to understand how .NET 5 can build netcoreapp3.1).
I have .NET Core 3.1 installed on my system next to .NET 5. Why doesn't the build system use 3.1? I believe that .NET 5 has some breaking changes in comparison to 3.1, so I am not sure if this is OK to use .NET 5 to build the project.
The same thing happens both in Azure DevOps Pipeline builds, and locally. Locally, in Rider, I see also this when I Build:
CONSOLE: Use build tool: /usr/share/dotnet/sdk/5.0.102/MSBuild.dll
Here's the result of ll /usr/share/dotnet/sdk:
drwxr-xr-x 28 root root 12K sty 13 08:24 3.1.405/
drwxr-xr-x 28 root root 12K sty 13 08:24 5.0.102/
As you can see, I have both 3.1 and 5.