Skip to content
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

Building reference assemblies for projects which include project references #117

Open
qmfrederik opened this issue Sep 7, 2018 · 2 comments

Comments

@qmfrederik
Copy link

I have a class library which P/Invokes into a native library. The native library has different names on different platforms, so I'm trying to create a NuGet package with per-runtime identifier targets (one for win and one for unix) and reference assemblies. (*)

My projects include P2P references; the setup is like this:
LibUsbDotNet.LibUsb -> LibUsbDotNet -> LibUsb.Common

LibUsbDotNet.LibUsb is the project which I want to multi-target and for which I want to create the reference libraries.

Unfortunately, it appears that when building, the P2P reference is not resolved and I get lots of compiler errors, like this:

/home/travis/build/LibUsbDotNet/LibUsbDotNet/src/LibUsbDotNet.LibUsb/Descriptors/MonoUsbAltInterfaceDescriptor.cs(25,20): error CS0234: The type or namespace name 'Descriptors' does not exist in the namespace 'LibUsbDotNet' (are you missing an assembly reference?) [/home/travis/build/LibUsbDotNet/LibUsbDotNet/src/refs/LibUsbDotNet.LibUsb.refs.csproj]

LibUsbDotNet.Descriptors is defined in the LibUsbDotNet project, which is referenced using a P2P reference.

Running dotnet build on the .ref.csproj file itself works fine.

Is there anything I can do to get the reference assemblies to compile?

Useful links:

(*) As to "why", the name of the native library is libusb-1.0.dll on Windows, libusb-1.0.so on Linux, etc. I can rename the Windows assembly to usb-1.0.dll but I cannot change the names on Unix. I attempted to do [DllImport("libusb-1.0")] but it appears that CoreCLR will not attempt to suffix the library name if it contains a ., see https://github.com/dotnet/coreclr/blob/master/src/vm/dllimport.cpp#L6213:L6229

@qmfrederik
Copy link
Author

Ah, this is probably related to #95

@clairernovotny
Copy link
Collaborator

I can take a look closer at this sometime in the next couple weeks. Just been pretty busy lately. It should be possible to get this working though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants