nuget packages used in class library

lobsterTail

New member
Joined
Jun 3, 2023
Messages
4
Programming Experience
3-5
I am updating an existing class library alled from another application that i don't have control over. I need to add new nuget package in this class library. Can i use any nuget that is not reference by the main application ? how do i deploy it since usually i just deploy the compiled .dll file only?
 
In a normal situation, it is not a matter of adding NuGet packages to the main application. It is just matter of also deploying the other binaries that the NuGet packages brought along. If your main app owner is okay with you giving them more than just your assemblies (.DLLs), but other assemblies as well, then you should be good to go. The system should find the files at runtime.*

If the app owner won't let you give them extra files, there are tools for merging assemblies. You will need to merge those other assemblies into yours.

The situation that gets harder is if the other assemblies needs configuration information added into the configuration files of the main program. NuGet packages that need this kind of configuration will often quietly automatically do this kind of modification to your application configuration/settings files. But since you don't own the main app, obviously those changes cannot be automatically applied to it. For that you will have to talk to the app owner and tell them what modifications also need to be made.

* I am not sure regarding any tweaks that may need to be done to the .deps.json file.
 
* I am not sure regarding any tweaks that may need to be done to the .deps.json file.

My reading of these:
suggests that no tweaks need to be done to the .deps.json file assuming that any other assemblies can be put in the same directory as the main application.
 
Can you not create a NuGet package for your library and specify those other packages as dependencies? Any app using your library would then install that NuGet package instead of creating a reference explicitly.
 
Back
Top Bottom