I am working on a C# library (LLamaSharp) which wraps a C++ library (llama.cpp).
As part of the nuget package we’re including DLLs compiled with all the various types of hardware support (CUDA, OpenCL, Vulkan, AVX/AVX2/AVX512 etc). At runtime the best possible backend is selected for the hardware available.
You can see the current folder hierarchy with all of the backends in it here. Automatic selection depends on this exact layout to be able to find the relevant DLLs. The nuspec file used to build the package is here.
However, with the current setup this fails when publishing a “Self Contained” build. It will produce this error:
Found multiple publish output files with the same relative path:
- llamasharp.backend.cpu.11.1runtimeswin-x64nativeavxllama.dll,
- llamasharp.backend.cpu.11.1runtimeswin-x64nativeavx2llama.dll,
- llamasharp.backend.cpu.11.1runtimeswin-x64nativeavx512llama.dll,
- llamasharp.backend.cpu.11.1runtimeswin-x64nativellama.dll
It seems that the entire folder hierarchy is flattened by the build process. This causes an immediate build error (multiple files going to the same place) and would also cause runtime selection to fail (files are not being placed in the correct folders).
What is the correct way to distribute a folder hierarchy of DLLs through nuget and preserve the structure in the final build?