In Visual Studio 2013 I have a project that depends on both the MonoGame.Binaries NuGet package and the OpenTK.GLControl package. The OpenTK.GLControl package itself is dependent on the OpenTK package.
MonoGame.Binaries includes its own copy of OpenTK.dll instead of depending on the OpenTK package. As a result, that OpenTK.dll is overwriting the OpenTK.dll from the OpenTK package in the output folder on build. This is breaking the application because OpenTK.GLControl needs the different version of OpenTK provided by the package rather than whatever version of the assembly MonoGame.Binaries provides.
How can I get both dependencies to play nice with each other and at least just use their own copies of OpenTK.dll if that's what they need?
Here are the parts of the .csproj involving references:
<ItemGroup>
<Reference Include="OpenTK, Version=1.1.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
<HintPath>..\packages\OpenTK.1.1.1589.5942\lib\NET40\OpenTK.dll</HintPath>
</Reference>
<Reference Include="OpenTK.GLControl, Version=1.1.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\OpenTK.GLControl.1.1.1589.5942\lib\NET40\OpenTK.GLControl.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\MonoGame.Binaries.3.2.0\build\net40\MonoGame.Binaries.targets" Condition="Exists('..\packages\MonoGame.Binaries.3.2.0\build\net40\MonoGame.Binaries.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\MonoGame.Binaries.3.2.0\build\net40\MonoGame.Binaries.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MonoGame.Binaries.3.2.0\build\net40\MonoGame.Binaries.targets'))" />
</Target>
The MonoGame.Binaries NuGet package adds a reference to OpenTK.dll from its MonoGame.Binaries.targets that it adds to your project. This .targets file is in one of the packages\MonoGame.Binaries.3.2.0\build subdirectories depending on the project's target framework which in your case is net40.
If you remove the following section from the MonoGame.Binaries.targets file then the OpenTK.dll from the OpenTK NuGet package will be copied to your bin directory.
<Reference Include="OpenTK">
<HintPath>$(MSBuildThisFileDirectory)\OpenTK.dll</HintPath>
</Reference>
OpenTK referenced by MonoGame.Binaries has an assembly version of 1.1 and an assembly file version of 1.1.940.3125. Using the assembly version of 1.1 suggests they will be compatible but you will have to test to see if your application still works with MonoGame using a different version of the OpenTK.dll. If MonoGame.Binaries only works with the version of OpenTK that it includes then you will have to remove the OpenTK.Control and OpenTK NuGet package and find a compatible version of OpenTK.Control.
I think the best fix is for the MonoGame.Binaries NuGet package to use the OpenTK NuGet package and not include its own.