MSBuild Ignore absent <TargetFrameworks> for every .csproj in .sln?

Solution 1:

See documentation on TargetFrameworks: it is ignored when TargetFramework (singular) is specified hence you can build with the framework of choice using

msbuild my.sln /p:TargetFramework=netcoreapp3.1

(argueably, just specifying a bunch of possible frameworks hardcoded in the project files is not super user-friendly, would be better if the authors did that conditionally somehow)