title: NuGet Package with managed wrapper dll that references bit-ted native dlls
body: <p>Need some help making a NuGet package.<br/>
  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.<br/><br/></p>
  
  <p>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:</p>
  
  <ul>
  <li>bin
  
  <ul>
  <li>debug
  
  <ul>
  <li>Managed.dll</li>
  <li>x86
  
  <ul>
  <li>Unmanaged.dll</li>
  </ul></li>
  <li>x64
  
  <ul>
  <li>Unmanaged.dll</li>
  </ul></li>
  </ul></li>
  </ul></li>
  </ul>
  
  <p>I can make a package like:</p>
  
  <ul>
  <li>lib
  
  <ul>
  <li>Managed.dll</li>
  <li>x86
  
  <ul>
  <li>Unmanaged.dll</li>
  </ul></li>
  <li>x64
  
  <ul>
  <li>Unmanaged.dll<br></li>
  </ul></li>
  </ul></li>
  </ul>
  
  <p>Opening the package, I can see the files are in the right places, so they're being included.</p>
  
  <p>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.</p>
  
  <p>However, if I try to install using NuGet Package Manager, it gags trying to find Unmanaged.dll.  The output of the PM install is:<br><br>
  Attempting to gather dependency information for package 'MyPackage.3.0.0' with respect to project 'MyProject', targeting '.NETFramework,Version=v4.5.2'<br>
  Gathering dependency information took 3.51 ms<br>
  Attempting to resolve dependencies for package 'MyPackage.3.0.0' with DependencyBehavior 'Lowest'<br>
  Resolving dependency information took 0 ms<br>
  Resolving actions to install package 'MyPackage.3.0.0'<br>
  Resolved actions to install package 'MyPackage.3.0.0'<br>
  Retrieving package 'MyPackage3.0.0' from 'MySource'.
  Adding package 'MyPackage.3.0.0' to folder 'C:\MyProject\packages'<br>
  Added package 'MyPackage.3.0.0' to folder 'C:\MyProject\packages'<br>
  Install failed. Rolling back...<br>
  Package 'MyPackage.3.0.0' does not exist in project 'MyProject'<br>
  Removing package 'MyPackage.3.0.0' from folder 'C:\MyProject\packages'<br>
  Removed package 'MyPackage.3.0.0' from folder 'C:\MyProject\packages'<br>
  Executing nuget actions took 895.64 ms<br>
  Install-Package : Failed to add reference to 'Unmanaged'.<br>
    Please make sure that the file is accessible, and that it is a valid assembly or COM component.<br>
  At line:1 char:1<br>
  + Install-Package MyPackage -source MySource<br>
  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
      + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception<br>
      + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand<br><br></p>
  
  <p>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.<br><br></p>
  
  <p>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?<br><br></p>
  
  <p>I'm using VS2015 and NuGet 3.5<br><br>
  Is <a href="https://stackoverflow.com/questions/37878853/nuget-package-with-multiple-dlls">this still the case</a>?  If so, can someone explain how to make the 2 packages play together?</p>
  
  <p><a href="https://codedump.io/share/wRDgspMf2UR0/1/automatic-native-and-managed-dlls-extracting-from-nuget-package-to-aspnet-core-project-targeting-net-framework" rel="nofollow noreferrer">This link</a> seems to say that managed and unmanaged can be in the same package.<br></p>
  
  <p>Thanks</p>