Title: NuGet package installation fails with unspecified error
Tags: c#;c++;nuget
Question: I've created a NuGet package that contains a C# (MyLibIF.dll) DLL that is a wrapper around a C++ DLL (MyLib.dll). They must be deployed next to each other.
This is NuSpec:
<?xml version="1.0"?&gt;
<package&gt;
<metadata&gt;
<id&gt;MyLibIF.dll_x86</id&gt;
<version&gt;151.154.11.224</version&gt;
<title&gt;MyLib library for 32-bits</title&gt;
<authors&gt;J.Doe</authors&gt;
<owners&gt;Our Company</owners&gt;
<licenseUrl&gt;https://localhost/license.html</licenseUrl&gt;
<projectUrl&gt;https://localhost/GitWeb/MyLibIF.git</projectUrl&gt;
<iconUrl&gt;http://localhost/images/favicon.ico</iconUrl&gt;
<requireLicenseAcceptance&gt;false</requireLicenseAcceptance&gt;
<description&gt;Library for some functionality and a type of integration</description&gt;
<releaseNotes&gt;</releaseNotes&gt;
<copyright&gt;Copyright 2016</copyright&gt;
<tags&gt;MyLib MyLibIF 32-bits</tags&gt;
</metadata&gt;
<files&gt;
<file src="bin\release\MyLibIF.dll" target="lib\net45"/&gt;
<file src="..\MyLib\Release\MyLib.dll" target="lib\net45"/&gt; <!-- It's not a .NET dll, but should be alongside MyLibIF.dll in deployment --&gt;
</files&gt;
</package&gt;
This build the package just fine. When I deploy it used PowerShell for extra info I get this:
PM&gt; install-package mylibif.dll_x86
Installing 'MyLibIF.dll_x86 151.154.11.224'.
Successfully installed 'MyLibIF.dll_x86 151.154.11.224'.
Adding 'MyLibIF.dll_x86 151.154.11.224' to ConsoleApplication1.
Uninstalling 'MyLibIF.dll_x86 151.154.11.224'.
Successfully uninstalled 'MyLibIF.dll_x86 151.154.11.224'.
Install failed. Rolling back...
install-package : Failed to add reference to 'MyLib'.
At line:1 char:1
+ install-package mylibif.dll_x86
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [Install-Package], InvalidOperationException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
PM&gt;
The dreaded NotSpecified, this means absolutely nothing to me.
I think the MyLibIF.dll is installing, but the MyLib.dll (the C++ one) is refused. I don't have enough NuGet knowledge to tackle this.
Does anyone know what is happening here?
And on a side-note, how do you deploy when you don't care about the version of the .NET framework?
UPDATE:
I've updated the nuspec to contain references.
<references&gt;
<reference file="MyLib.dll" /&gt;
<reference file="MyLibIF.dll" /&gt;
</references&gt;
But it still fails with the same error. I can get it to work if I specify the target for MyLib.dll to lib. Ignoring the warning that NuGet gives it'll load the package into the following folder structure.
.\packages\MyLibIF.dll_x151.154.11.224.1\lib\MyLib.dll
.\packages\MyLibIF.dll_x151.154.11.224.1\lib\net45\MyLibIF.dll
So there is some intelligence that decides the MyLib.dll is not allowed inside net45...
Comment: @Renzo: Unfortunately it doesn't provide extra meaningful info. The stack trace shows that the `NuGet.VisualStudio.VsProjectSystem.AddReference` fails. That I knew :).

Comment: You should be review this: http://stackoverflow.com/questions/31672164/where-does-nuget-log-detailed-error-message

Here is the accepted answer: Try embedding your C++ dll inside your .Net dll, this way you'll have only your .Net dll to deploy.
Costura.Fody may help you do that.
Talking about references : you shouldn't have to add reference to your c++ dll. There may be a cause for your issue.
read few lines above the "notspecified" : "Failed to add reference to 'MyLib'."
Go get a .Net project in VS and try to manually add a reference to your C++ lib : it shoud fail, and that's what your wrapper is for.
Take a look at these few elements, it should help.
Comment for this answer: Thanks, I'll have look. One other way which will also work is creating a seperate NuGet package and have a dependency. This is how I got LM-X license library to work. Downside is the large number of packages (4) and the fact that the programmer has to choose the correct (32/64) version.
Comment for this answer: Yeah, large number of dependencies are a mess when trying to share work !
About the developper having to choose a specific version, developpers may be able to choose between 32/64, so that's not a really big issue to me :) ... But if you have a way to keep only one redist package that's still better


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 2, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2016:00:10/12/16', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<c#><c++><nuget>', 'Title': 'NuGet package installation fails with unspecified error', 'ViewCount': 185, 'id': 39998807, 'user_AboutMe': '', 'user_AccountId': 2333089.0, 'user_DisplayName': 'Frank Kaaijk', 'user_Reputation': 293.0, 'user_Views': 53.0, 'user_id': 2046004.0}}