This weekend I planned to set up a Portable Class Library (PCL) with shared code between our Windows 8 and Windows Phone projects. Since async isn’t supported on Windows Phone 7 by default, the first task was adding the Async Targeting Pack. This enables projects targeting .NET 4.0 or Silverlight 5 to use the async language features. A newer version on NuGet also includes Silverlight 4 and Windows Phone 7.5. So my first task was to add this latest version through NuGet, but I got greeted with following error message:
Could not install package 'Microsoft.Bcl 1.0.11-beta'. You are trying to install this package
into a project that targets '.NETPortable,Version=v4.0,Profile=Profile4', but the package does
not contain any assembly references that are compatible with that framework.
For more information, contact the package author.
If you look at this list of framework profiles, you’ll see that Profile 4 equals to .NET 4.5, Silverlight 4 and Windows Phone 7 while the bcl package requires Windows Phone 7.5 (or SKD 7.1). After changing the PCL project properties I still had a similar error message and trying to add JSON.NET gave me an error message as well. Digging a bit deeper I found out that I still had NuGet 2.0 while you’ll need NuGet 2.1 (or higher) for PCL support.
Conclusion
Make sure that you have the latest NuGet version installed and check that your Portable Class Library target frameworks are similar or higher than those required by the package.