-
Notifications
You must be signed in to change notification settings - Fork 463
Fix issue #382 (multiple publish output files with same relative path) #1234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Thanks for looking into this. #382 has been a long standing issue that a few people (including me) have had a look at but failed to solve, I'm happy to see the fix turns out to be so simple! I'll find some time to test this out soon, I'd really like to get it into the next update if possible. Would you be interested in developing a followup PR with your suggested improvements? Removing the extra installation step and making it just work would be fantastic. |
Glad I could help, this issue had been around for a while, let’s see if the tests confirm the fix. One noteI’m not sure why, but the last time I worked on this bug I was able to pack the NuGets with the original paths. This time, however, I had to adjust them. In all the For example: I hope this doesn’t break the way you build the packages, if it does, please let me know and I’ll restore the src paths to their previous state. TestingAs before, I tested with a MAUI project using LLamaSharp.Backend.Cpu and LLamaSharp.Backend.Android. This time, I added the packages using the usual NuGet Package Manager GUI, and it was not necessary to use |
Hi @LucaMaccarini , does this PR need any additional changes? I'm not sure what you mean by that last note (have you found out if we need to start with Edit
After replacing all |
Hi @m0nsky, Thanks a lot for testing and for the detailed feedback I actually suspected that the path part should have remained Example of the command I used locally:
I’ll fix the initial path in this PR so that it uses Could you kindly share how you usually generate the NuGet packages on your side? (what script or command do you run). That would help me align with your workflow and avoid mismatches like this. Regarding the point you mentioned about the <dependencies>
<dependency id="LLamaSharp.Backend.Cpu" version="$version$" />
</dependencies> That dependency is the reason why the CPU backend is included when packing the CUDA12 backend. |
Yes, absolutely, here are my steps:
Basically, I put that What I meant by the CPU/CUDA12 issue, is that the CUDA12 runtimes seem to be completely missing when building my application. When I extract I'm using the following command to build/publish my application: |
Fixes #382: On Windows, runtime files from backend packages are currently flattened during copy. This means that all files from subfolders end up in the same output directory, causing conflicts when multiple files share the same name.
Proposed fix
Correct the file
LLamaSharpBackend.props
as shown in the changes included in this PR.When building for Windows, and after installing the Windows-specific backend packages, make sure to add
ExcludeAssets="Native"
to thePackageReference
in the.csproj
, as shown below:Although
ExcludeAssets="Native"
is strictly necessary only for Windows backends when building on Windows, it shouldn’t cause issues for other backends. To be safe, it can be applied to all imported backend packages. I have tested this with bothLLamaSharp.Backend.Cpu
andLLamaSharp.Backend.Android
installed in the same MAUI project. This attribute tells MSBuild not to copy the runtime files from the NuGet package to the output directory, because copying is already handled correctly in theLLamaSharpBackend.props
file updated in step 1.How to Apply this fix before it is merged
If you urgently need to fix this issue, you can temporarily apply this change by copying the corrected
LLamaSharpBackend.props
content (from step 1) into each backend package directory, e.g.:and then import the package as indicated in step 2.
Note: this modification will be lost if the package is updated.
Future improvements:
Avoid using the default
Runtimes
folder, since MSBuild always flattens its contents building for windows causing conflicts. Using a custom folder for runtime files would eliminate the need to setExcludeAssets="Native"
in the package reference, and then change theLLamaSharpBackend.props
file to correctly fetch runtime files from the custom folder.Tests
I tested this fix on a limited scenario with a MAUI project having both
LLamaSharp.Backend.Cpu
andLLamaSharp.Backend.Android
installed. The goal was to ensure the app works on both types of devices. Given the large heterogeneity of the backends, I hope this fix will work for other backends as well.