Need some help making a NuGet package.
We have a 3rd party C# managed dll (call it 'Managed.dll') that somehow uses/references/wraps 3rd party x86 and x64 native dlls (call them both 'Unmanaged.dll') depending on the runtime machine.
The Managed.dll knows how to find the appropriate Unmanaged.dll as long as the the x86 and x64 folders are in the same directory, like:
- bin
- debug
- Managed.dll
- x86
- Unmanaged.dll
- x64
- Unmanaged.dll
- debug
I can make a package like:
- lib
- Managed.dll
- x86
- Unmanaged.dll
- x64
- Unmanaged.dll
- Unmanaged.dll
Opening the package, I can see the files are in the right places, so they're being included.
I can also manually "install" it by putting the package in the packages directory, adding a reference to the Managed.dll to the csproj and then a pre-build event copies the bitted directories and dlls to the appropriate places when the project is built and it all runs etc. But now we're trying to make the dlls more easily distributable using NuGet. Further, if I add a line for the package to the packages.config file, and delete the packages folder, the package is re-pulled and it still all works.
However, if I try to install using NuGet Package Manager, it gags trying to find Unmanaged.dll. The output of the PM install is:
Attempting to gather dependency information for package 'MyPackage.3.0.0' with respect to project 'MyProject', targeting '.NETFramework,Version=v4.5.2'
Gathering dependency information took 3.51 ms
Attempting to resolve dependencies for package 'MyPackage.3.0.0' with DependencyBehavior 'Lowest'
Resolving dependency information took 0 ms
Resolving actions to install package 'MyPackage.3.0.0'
Resolved actions to install package 'MyPackage.3.0.0'
Retrieving package 'MyPackage3.0.0' from 'MySource'.Adding package 'MyPackage.3.0.0' to folder 'C:\MyProject\packages'
Added package 'MyPackage.3.0.0' to folder 'C:\MyProject\packages'
Install failed. Rolling back...
Package 'MyPackage.3.0.0' does not exist in project 'MyProject'
Removing package 'MyPackage.3.0.0' from folder 'C:\MyProject\packages'
Removed package 'MyPackage.3.0.0' from folder 'C:\MyProject\packages'
Executing nuget actions took 895.64 ms
Install-Package : Failed to add reference to 'Unmanaged'.
Please make sure that the file is accessible, and that it is a valid assembly or COM component.
At line:1 char:1
+ Install-Package MyPackage -source MySource
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
I've tried adding a build dir to the package with an 'Unmanaged.props' file but the same error occurs. I've tried putting an 'Unmanaged.dll' at the same level as the 'Managed.dll' in the package.
So, please tell me why it can't find the 'Unmanaged.dll' (for my own edification) and what I need to do for it work correctly (might need some hand-holding to walk me through it). Do I need a .targets? A custom install.ps1?
I'm using VS2015 and NuGet 3.5
Is this still the case? If so, can someone explain how to make the 2 packages play together?
This link seems to say that managed and unmanaged can be in the same package.
Thanks