Docker Image for net6 API

HI,

Building a docker image for the first time and getting a blocker i.e. using net6 sdk to build my project but that project have references to some other projects which are in net4.8. So while building the main project, it’s throwing me the error that “The reference assemblies for .NETFramework,Version=v4.8 were not found”. Is it possible to use two sdks in the same image in same stage. Because building the main project automatically building the referenced projects. Suggest me something that I can do in this case.

Thanks

Thanks Buddy,

But what actually the problem I’m facing in that in the solution there are no. Of projects, and among them I want to build only one. That major project is in net6 and the referenced project for that are in net4.8. And while building the main project, it will automatically build the referenced projects and throw that error of missing 4.8 framework.
I can’t build those 4.8 one separately because they can vary in number for each main project and are hundreds in count. So waste of resources and time to build them all. Isn’t there something like I can make a image containing both sdks and use that as base in main image…?

Any suggestions is welcomed.

Thanks

I see you responded to an email, but by that time I have already deleted the post and the user as it contained a spamlink and the post was probably AI generated. I had to note this because other visitors would not understand what “buddy” you are referring to :slight_smile:

Regarding your question, since the image is just a layered filesystem and metadata, if you can install multiple .NET SDKs on Linux without containers, you can do it in a Docker image as well. How that has to be done requires .NET experience but it would probably mean either downloading binaries into different directories or compiling the SDKs from source code.

On the other hand, not everything is done the same way in Docker containers as outside containers. Maybe there is a known solution for your problem in the .NET community. Sometimes when something works automatically outside containers, you need to do multiple steps separately in containers and maybe indeed build the components in separate stages (as the deleted post sugested), if it is possible.

If it is not possible, then maybe the application was not meant to be built in a container. Working with containers can require changing our methods.

Since I have not enough experience with .NET, I can’t tell you which is the preferred way.

Based on your previous post I would say the application was indeed not meant to be built in a containerized environment, so you will need to choose a less optimal solution and somehow install multiple SDKs in a single image and you will most likely need to ask about that in a .NET community or wait for someone who works with .NET here and already had the same problem.