Multi build target projects in single Docker file

We have a complex solution which contains about a dozen projects (everything is in C#). VS 2022 will allow the build for these projects to occur even if some projects use net Core 3.1 and net6. But when attempting to build the same code base via the docker commands; each project may have it’s own Docker file. When this happens, the Docker file used to “kick off” the build does not have all the SDKs for building all the downstream projects. The file in question would have:

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build

But another project has:

FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build

So, it is just that easy? to include both statements so the two SDKs are downloaded into the working directory?

I may also be looking for some best practices when dealing with these “mixed” targets, so in the future it is easier to integrate into our CI/CD pipelines.

Thanks for anything y’all can share.