2
votes

I am trying to construct a nuget package that installs a portable class library that itself that has dependencies on a collection of portable class libraries. I can create the package and install it without a problem but when I run an app with the new package installed, a .NET 4.5. class library test project, I always get the following exception:

threw exception: 
 System.IO.FileNotFoundException: Could not load file or assembly 
  'Microsoft.Data.Services.Client.Portable, Version=5.6.1.0, Culture=neutral, ...

My nuspec file, contains the following dependencies section.

<dependencies>
  <group targetFramework="portable-net45+wp80+win">
    <dependency id="Microsoft.Bcl" version="1.1.6"  />
    <dependency id="Newtonsoft.Json" version="6.0.2" />
    <dependency id="Microsoft.Data.Services.Client" version="5.6.1" />
    <dependency id="Microsoft.AspNet.WebApi.Client" version="5.1.1" />
  </group>
</dependencies>

I have created numerous nuget packages in the past and have never seen this issue. I am guessing it has to do with referencing the PCL versions of each library within the PCL dll that I am creating but I am clueless how to get this nuget to work properly.

What am I missing?

1

1 Answers

0
votes

This looks like an issue with the Microsoft.Data.Services.Client NuGet package. It is using different assembly names for the portable version as for the .NET Framework and Silverlight versions. So your portable assembly is compiled against Microsoft.Data.Services.Client.Portable.dll, but when your NuGet package is installed into a .NET project, Microsoft.Data.Services.Client.dll is referenced instead.

Generally, a package like this should use the same assembly name on all platforms (the APIs do need to be compatible between the platforms too though).