I have a .NET 7 solution with multiple projects. I would now like to pack a Nuget of one project that will serve as a proxy for another application to call some API's. My project structure is similar to:
I would like to pack a Nuget for Project 2 which basically contains services calling the API's available in Project 4. My services return the output models coming from Project 3 after having done the required HTTP call.
Unfortunately when I pack Project 2 and implemented it in another application, I got the error saying Unable to load one or more of the requested types.\r\nCould not load file or assembly 'xxx.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
which of course is because there are some enum values referenced in the API contracts project.
Initially I had the same issue with the reference to Project 3 and I could fix it by exposing that project as a Nuget as well. And now I have the feeling I should do the same for Project 1, but I am a bit wary of doing so because eventually I will need to expose my entire solution in Nuget packages and they would never have any value as a stand-alone package.
So is there a way to expose just one single Nuget that encapsulates Project 2 + the required external dependencies (such as the relevant API contracts or the Enums) rather than packing one with 2 other Nuget dependencies?
Usually what do we do is this kind of scenarios :
Infrastructure
as independent nuget
package.Proxy
and publish your project as a nuget
.There are other ways to include your dlls
as resources and Nuget
will just pack them - but in my opinion that is bad practice.