title: Dependent DLLs of a NuGet package not copied to output folder
body: <p>I got an issue with a custom Nuget package I've created. Let's call it MyCompany.Library.nupkg. It is hosted on an corporate Artifactory Nuget repo. This package depends on Newtonsoft.Json. For some reason the dependent DLL is not copied to the output folder of my project, if I reference a project that uses that Nuget package. The weird thing is, that when I use another package (e.g. Moq, instead of my own) the dependent DLLs are copied.</p>
  
  <p>I've created test solution to reproduce the issue:</p>
  
  <p>Solution ReferenceTest:</p>
  
  <ul>
  <li>Project: SomeLib.dll; references: 
  
  <ul>
  <li>MyCompany.Library Nupkg  (depends on Newtonsoft.Json, so that's added too)</li>
  <li>Moq Nupkg (depends on Castle.Core, added too)</li>
  </ul></li>
  <li>Project: MyWinFormsApp.exe; project-reference:
  
  <ul>
  <li>SomeLib.csproj</li>
  </ul></li>
  </ul>
  
  <p>When I look at the output folder of SomeLib, I see:</p>
  
  <ul>
  <li>SomeLib.dll</li>
  <li>Moq.dll</li>
  <li>Castle.Core.dll</li>
  <li>MyCompany.Library.dll</li>
  <li>Newtonsoft.Json.dll</li>
  </ul>
  
  <p>That looks good.</p>
  
  <p>But when I look at the output folder of MyWinFormsApp, Newtonsoft.Json.dll is missing and when running the application, it throws exceptions that the Newtonsoft.Json dll is not found. However, the Castle.Core.dll IS in the output folder of MyWinFormsApp.</p>
  
  <p>I've compared the nuspecs of Moq and MyCompany.Library and I can't really find any significant difference.</p>
  
  <p>I could change all of the project that use my SomeLib to reference Newtonsoft.Json, but that's a lot of projects and I don't want to bother the other developers with that. They shouldn't have to know that SomeLib uses that assembly.</p>
  
  <p>The references in the SomeLib.csproj are like this:</p>
  
  <pre><code>  &lt;ItemGroup&gt;
      &lt;Reference Include="MyCompany.Library, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"&gt;
        &lt;HintPath&gt;..\packages\MyCompany.Library.1.0.0\lib\net461\MyCompany.Library.dll&lt;/HintPath&gt;
        &lt;Private&gt;True&lt;/Private&gt;
      &lt;/Reference&gt;
      &lt;Reference Include="Castle.Core, Version=3.3.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL"&gt;
        &lt;HintPath&gt;..\packages\Castle.Core.3.3.3\lib\net45\Castle.Core.dll&lt;/HintPath&gt;
        &lt;Private&gt;True&lt;/Private&gt;
      &lt;/Reference&gt;
      &lt;Reference Include="Moq, Version=4.5.28.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL"&gt;
        &lt;HintPath&gt;..\packages\Moq.4.5.28\lib\net45\Moq.dll&lt;/HintPath&gt;
        &lt;Private&gt;True&lt;/Private&gt;
      &lt;/Reference&gt;
      &lt;Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"&gt;
        &lt;HintPath&gt;..\packages\Newtonsoft.Json.8.0.1\lib\net45\Newtonsoft.Json.dll&lt;/HintPath&gt;
        &lt;Private&gt;True&lt;/Private&gt;
      &lt;/Reference&gt;
      &lt;Reference Include="System" /&gt;
      &lt;Reference Include="System.Core" /&gt;
      &lt;Reference Include="System.Xml.Linq" /&gt;
      &lt;Reference Include="System.Data.DataSetExtensions" /&gt;
      &lt;Reference Include="Microsoft.CSharp" /&gt;
      &lt;Reference Include="System.Data" /&gt;
      &lt;Reference Include="System.Net.Http" /&gt;
      &lt;Reference Include="System.Xml" /&gt;
    &lt;/ItemGroup&gt;
  </code></pre>
  
  <p>My Nuspec looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"&gt;
    &lt;metadata&gt;
      &lt;id&gt;MyCompany.Library&lt;/id&gt;
      &lt;version&gt;0.0.0&lt;/version&gt;
      &lt;description&gt;MyCompany Core library&lt;/description&gt;
      &lt;authors&gt;MyCompany&lt;/authors&gt;
      &lt;references&gt;
        &lt;reference file="MyCompany.Library.dll" /&gt;
      &lt;/references&gt;
      &lt;dependencies&gt;
        &lt;dependency id="Newtonsoft.Json" version="[8.0,9.0.1]" /&gt;
      &lt;/dependencies&gt;    
    &lt;/metadata&gt;
    &lt;files&gt;
      &lt;file src="MyCompany.Library\bin\Release\MyCompany.Library.dll" target="lib\net461"/&gt;
      &lt;file src="MyCompany.Library\bin\Release\MyCompany.Library.pdb" target="lib\net461"/&gt;
      &lt;file src="MyCompany.Library\bin\Release\MyCompany.Library.xml" target="lib\net461"/&gt;
    &lt;/files&gt;
  &lt;/package&gt;
  </code></pre>
  
  <p>I'm using Visual Studio 2015 Professional.</p>
  
  <p>My questions:</p>
  
  <ol>
  <li>Why is Visual Studio not copying my dependent dll?</li>
  <li>Why is it copying the dependencies of Moq? What's the difference?</li>
  </ol>
  
  <p>Thanks for any help.</p>
  
  <p>Quido</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I've been comparing the NUSPEC of Moq and my own package and (completely desperate) I found one diffence. The Moq Nuspec contains:</p>
  
  <pre><code>&lt;dependencies&gt;
    &lt;group targetFramework=".NETFramework4.5"&gt;
      &lt;dependency id="Castle.Core" version="3.3.3" /&gt;
    &lt;/group&gt;
  &lt;/dependencies&gt;
  </code></pre>
  
  <p>and my own package contains:</p>
  
  <pre><code>&lt;dependencies&gt; 
    &lt;dependency id="Newtonsoft.Json" version="[8.0,9.0.1]" /&gt; 
  &lt;/dependencies&gt;     
  </code></pre>
  
  <p>I changed my dependency to specify a targetFramework and now VisualStudio DOES copy my dependency!</p>
  
  <p>That NuSpec is the only thing I changed and this really solves it. I've been going back and forth to a situation with and without that targetFramework and the results are consistent (failure without the targetFramework and success with the targetFramework).</p>
  
  <p>So: problem solved, but I have no idea why...</p>