I'm trying to create a managed library and package it with Nuget. The managed library consumes another DLL written in C and makes the calls through [DllImport] P/Invoke calls. In the root of the project I have a folder structure like:
- root/runtimes/win-x86/native/file.dll
- root/runtimes/win-x64/native/file.dll
I am not using a .nuspec file but instead generating the Nuget package from the .csproj file from a .NET STandard 2.0 project. I'm including those files with this in the .csproj file.
<ItemGroup>
<Content Include="runtimes\**" PackagePath="runtimes" Visible="true" />
</ItemGroup>
The nuget package has the managed DLL in the lib/netstandard2.0 directory and even has the unmanaged DLL in root/runtimes/RID/native directory. The project that is consuming this nuget package installs perfectly and builds without error.
The managed DLL the consumer will interface with is trying to use that native DLL like this
[DllImport("file_name.dll")]
private static extern IntPtr CscanHOpen(string connectionString);
//...
public void Open(string connectionString, int port) {
_handle = CscanHOpen(connectionString, port);
}
I'm getting the "file cannot be found" error from the project installing the nuget package and when I look in the build directory I don't see that unmanaged DLL there. I've tried using a targets file to copy the unmanaged DLL to the output directory of the consuming project but it never shows up.