Problem adding Microsoft Emotion API to a Xamarin app

When adding the Microsoft.ProjectOxford.Emotion nuget package to a Xamarin iOS project on Visual Studio for Mac you might encounter the following error:

Install-Package Microsoft.ProjectOxford.Emotion
Could not install package 'Microsoft.Bcl.Build 1.0.14'. You are trying to install this package into a project that targets 'Xamarin.iOS,Version=v1.0', but the package does not contain any assembly references or content files that are compatible with that framework.

The reason for this error is that Microsoft.ProjectOxford.Emotion 1.0.336 depends on Microsoft.ProjectOxford.Common >= 1.0.324 which depends on Microsoft.Net.Http >= 2.2.29, which depends on Microsoft.Bcl.Build >= 1.0.14 and 1.0.14 is not compatible with the Xamarin.iOS target. Unknown

It is however a little bit surprising that nuget attempts to install such an old package, especially when it is not compatible. The reason is to be found in the dependency resolution behaviour of nuget, which is described in here.

Nuget by default uses the “lowest applicable version” rule to resolve dependencies and apparently there is no check for wether the “lowest applicable version” also supports the current build target.

Fortunately there is a newer version of Microsoft.Bcl.Build which does support Xamarin, so the solution is to first install the latest version of Microsoft.Bcl.Build separately and then install Microsoft.ProjectOxford.Emotion.

Install-Package Microsoft.Bcl.Build
Install-Package Microsoft.ProjectOxford.Emotion
Microsoft.ProjectOxford.Emotion successfully added.


Leave a Reply