Multiple dotnet runtimes for build

My build runs parts on different runtimes of .NET. I install 5.0.100 but require 3.1 in order to complete my build. How do I install it as well for both Linux and macOS?