-
Notifications
You must be signed in to change notification settings - Fork 255
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
[Bug]: Unable to install Linux shared libraries (with symlinks) into output folder #12136
Comments
Thank you for filing this issue. |
Thanks @erdembayar for the quick response. I do not care about package size, so this is not my problem. But when the libraries appear as duplicate files, I've tested and they do not load correctly if the symbolic links are missing, and also not when the symbolic links are replaced with the actual files. |
Sounds like you need the symlinks generated on the end user machine, as such we don't believe there's anything that needs to be done on the packaging side. In your targets authoring, you may choose to create symlinks for the files, but at packaging time you really only want to have 1 file. If the current MSBuild capabilities do not allow you to create symlinks feel free to create an issue on the MSBuild side. As far as, symlinks, within a package go, you can track #10734. |
@nkolev92 no, I think there is a misunderstanding here. Please read my description again. Here is the short summary, for reference: The Linux and MacOS shared libraries are treated as second class citizens by NuGet, compared to Windows Missing support for symlinks makes the problem worse because even the common workarounds fail. But the correct solution would be that Linux and MacOS shared libraries are just supported in the same way as |
Can you please elaborate on this? dlls are managed, CLR, they have exact same support on both platforms. NuGet is a transport vehicle that handles compatibility and that's handled the same on all platforms. The shared libraries are really native libraries and the support there is also equivalent for windows/linux.
What would that look like in your opinion? |
What should just work is this:
This already works for native shared libraries on Windows (
Therefore I consider Linux and MacOS to be "second class citizens" compare to Windows, where things "just work". |
why was this closed ? |
Dear @germgerm , I agree this was not fixed, and NuGet is treating Linux and MacOS as second class citizens, which is quite sad. There is a rather complicated workaround, where you would package your shared libraries into a zip archive before NuGet packaging, then include the zip archive in the NuGet in a subfolder of |
This was my resolution - based on the fact that all of our package are dependant upon one core package |
NuGet Product Used
dotnet.exe
Product Version
Version: 6.0.401
Worked before?
Never worked
Impact
I'm unable to use this version
Repro Steps & Context
I'm trying to build a package that includes a Linux shared library that is used via
P/Invoke
. The library resolved correctly when it is placed in the outputbin
folder together with the managed binaries.Now I'd like to create a NuGet package. I've created a
nuspec
file for that. But for a task that should be rather simple, I've spent more than 20 hours on this problem now and fail to get the Linux shared library into thebin
folder of a project that uses my NuGet package.Things I've tried and how they failed:
1) Simply including all files in the package
When I try to add all files into the package using something like
<file src="bin\**" target="lib\$TargetFramework$" />
, then the manageddll
s are correctly installed in the dependent project. The native libraries with extension*.so*
are also included in thenupkg
, but are missing from the outputbin
folder of the dependent project.2) Explicitly adding all files into the package
When I try to add the native shared library files explicitly into the package using something like
<file src="bin\*.so*" target="lib\$TargetFramework$" />
, then it fails in the same way as above.3) Store the native libraries in the
runtimes
directoryWhen I add the native shared library files in the
runtimes
directory, they are correctly installed in the dependent project, but in the sameruntimes
directory below the output directorybin
. This makes theP/Invoke
fail because they are not resolved from that directory.4) Using
contentFiles
I tried using
contentFiles
as outlined in https://devblogs.microsoft.com/nuget/nuget-contentfiles-demystified/, but that did not lead to a success.5) Using a
targets
file to copy librariesThe currently best solution is to package the native shared library files in the
build\native
directory, and then use a dedicated*.targets
file to copy them to the output folder. The*.targets
file contains:This achieves almost what I need, except that it does not preserve symbolic links! Therefore, the common Linux shared library structure is broken. I need to have (where
->
denotes a symbolic link):but instead I get three copies of the library file:
This breaks the
P/Invoke
dependency resolution, whenlibMyProject
is a dependency of another library that is opened withP/Invoke
.Verbose Logs
No response
The text was updated successfully, but these errors were encountered: