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:

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.


Leave a Reply