Installing ADAL NuGet package for Portable Xamarin project causes an error

Installing ADAL NuGet package for Portable Xamarin project causes an error

When you have a Portable Xamarin project in Visual Studio 2015 and you try to add the NuGet package for ADAL (Microsoft.IndentityModel.Clients.ActiveDirectory) it is possible you will receive an error complaining that the package does not contain any assembly references which are compatible with the targets of your PCL project. The error will be something like this.

“Error Could not install package ‘Microsoft.IdentityModel.Clients.ActiveDirectory 3.13.1’. You are trying to install this package into a project that targets ‘.NETPortable,Version=v4.5,Profile=Profile111’, but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.”

It seems that this is caused by the fact that one of the targeting platforms of your PCL is Windows Phone 8.1. ADAL does not support Windows Phone 8.1. Only removing the Windows Phone 8.1. project from your solution will not do the trick. You still need to remove this target from the PCL project inside your solution.

The following steps explain how to resolve this issue.

Right click on your PCL project and open “Properties”. Go to the tab “Library”. You will notice a list of targeted platforms.

ErrorinstallingADALpackageinpcl2

If you now would change the targeted platforms by removing the target Windows Phone 8.1 you would get an error.

ErrorinstallingADALpackageinpcl3

The problem is that you will not be able to uncheck that specific target before you have removed installed NuGet packages from the PCL project. Right click on the PCL project and select “Manage NuGet packages..”. Make sure you write down which packages are installed before uninstalling them. Uninstall each of the installed packages.

Now again go to the properties of the PCL project and the tab “Library”.

ErrorinstallingADALpackageinpcl2

Press the button “Change” and uncheck the target “Windows Phone 8.1”. Press the “OK” button. Wait a few seconds and the dialog will be gone and the target is removed from the PCL project.

Now you are ready to finalise it by reinstalling each of the uninstalled NuGet packages for the PCL project and install the ADAL NuGet package.

ErrorinstallingADALpackageinpcl5

And there you have it! Your ADAL NuGet package is now installed for your PCL project.

Leave a Reply