Xamarin.Forms And The Case of Failed NuGet Packages – Part 2

Most enterprise mobile apps require enterprise-level authentication mechanism. In that case, people use tried and tested Active Directory Authentication Library (ADAL) or Microsoft Authentication Library (MSAL). ADAL is in GA and it works fine with cross-platform mobile apps built using Xamarin. However, MSAL is in ‘preview’ and it offers nightly builds to try out. I wanted to try the latest nightly build (ver: 1.1.1-alpha0417) as it uses updated Android Support Package and old preview bits of MSAL (ver: 1.1.0-preview) were not compatible with latest  Xamarin.Forms anymore. Here, I was trying to build one app over holidays and I got stuck on one interesting issue. Let’s discuss it in this blog post.

The Problem:

When you create a blank Xamarin.Forms app, it automatically references Xamarin.Forms NuGet along with all the required dependencies.

At this time, when you’ll try to install MSAL, you may get stuck at this issue of versioning.

The reason being Xamarin.Forms NuGet requires a specific version of Android Support Packages whereas Microsoft Authentication Library requires anything above Ver. 25.3.1.

The Solution:

Sometimes, things are very simpler than it looks. I spent a lot of time on solving this issue but was unable to fix it. Thanks to my friend Nish, who helped me with his ‘ problem-solving skills’ and we got this working.

The solution is simple:

  1. Remove all NuGet packages from Android project. For the sake of it, close and restart Visual Studio.
  2. Open the solution and Install MSAL NuGet package first.
  3. After installing MSAL NuGet, install Xamarin.Forms NuGet package.

Bingo!

Now you can build Xamarin.Forms apps with Microsoft Authentication Library. If you want to know more about how to use the SDK, follow the blog post here on Xamarin blog.

Even though I’m talking about Xamarin.Forms and MSAL here, this blog post is very much applicable wherever you’re trying to use any NuGet package which has updated dependency on Android Support Package.

Setup info:
Visual Studio Enterprise 2017 Preview (15.5.2)
Xamarin (4.8.0.753)
Xamarin.Forms (2.5.0.121934)
Microsoft Authentication Library (1.1.1-alpha0417)

Namaste,
Mayur Tendulkar

 

Advertisements

#365 Admin

I carpool to work with Dev. We enjoy our ~45 mins. ride and while traveling we listen to 80’s/90’s songs (If given a chance he would kill me for my choice of songs Smile) and also talk about various things at our day-to-day job and how those can be automated. One of the thing that we discussed was basic – User Management. E.g. adding a user, resetting password, etc.… So, we thought about enabling IT admins to manage their Active Directory remotely.

Recently, I was working on a project where we had to use Azure Active Directory for user management. And I thought it can add value if ported on mobile. So – #365 Admin.

Using this tool, IT admins can browse through users, reset their password or add a new user. This is v1.0 release and I’m planning to add more features and release updates once in a month or as and when ready/required.

Thanks to Girish, Aviraj and Vittorio for all their support while building this app.

The app is certified in the store and will be available in general in coming weeks.

Thanks,
Mayur Tendulkar