question

MagneRyholt-7495 avatar image
0 Votes"
MagneRyholt-7495 asked MagneRyholt-7495 edited

Nuget reference from unreferenced class library

I have a .Net 5 WPF project and a few .Net 5 class library projects.
The class library projects are not referenced directly from the WPF assembly because the class libraries are meant to be loaded in runtime by the wpf app.
This works fine by using interfaces defined in a common lib (referred to from both wpf assembly and relevant class libraries.

If I then add a nuget dependency to one of the class library projects, the assembly in the nuget package is not copied anywhere.
I expected that to be copied to the same directory as the respective class library dll file is written to (where-ever this is set to be by the OutputPath property of the csproj file)

Something I misunderstand or is this a bug?
Is the only possibility (a quite "dirty" one, but it works) to copy the referenced assembly from the nuget package to the output folder by post build event?

(To be a bit specific, I am using Prism and DirectoryModuleCatalog for loading the class libraries)

dotnet-csharpdotnet-runtimedotnet-package-management
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi, @MagneRyholt-7495
I found this thread that may be useful to you. Prism is a third-party framework, I suggest you can start a new thread in Stackoverflow.


0 Votes 0 ·
MagneRyholt-7495 avatar image
0 Votes"
MagneRyholt-7495 answered

Ok, more searches and found this: https://docs.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props#copylocallockfileassemblies

Have a look at the CopyLocalLockFileAssemblies property which solved the problem for me (could remove the specific xcopy in post-build actions)
Note that this property (and probably a bunch of others) is not available at the page when right clicking the project and select Properties, you must edit the project file.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

MagneRyholt-7495 avatar image
0 Votes"
MagneRyholt-7495 answered

Thanks, however I don't see how your link relates to my problem at all.

Further Prism was just mentioned as a side-note, the problem has nothing to do with Prism or any other 3rd part libraries, but in general to the concept of run-time loading of assemblies (Prism with DirectoryModuleCatalog just happens to do this)

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Bruce-SqlWork avatar image
0 Votes"
Bruce-SqlWork answered MagneRyholt-7495 edited

It may be a bug with the nuget package internal configuration. The builder of the nuget package controls what dlls are copied local by default.

Maybe the package has optional dlls and you are expect to add a reference.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I answered my own question (above) and I think actually this behaviour is by design (thats why the build property mentioned exists I assume).
I am sorry for the strange order of answers (of which the first, mentioned last above should be a comment)

0 Votes 0 ·