XamlCTask fails when building your Xamarin.Forms project

Xamarin.Forms is a game changer that helps to push code reuse to another level for your Xamarin based mobile app projects.

One error that comes up during the building process of a Xamarin.Forms project is this one:

The “XamlCTask” task failed unexpectedly

This post shows you how I fixed this error and got my project going.

Googling around showed me that many people have been boxing with this problem since 2015:

  • https://forums.xamarin.com/discussion/54790/the-xamlctask-task-failed-unexpectedly
  • https://stackoverflow.com/questions/39975859/the-xamlctask-task-failed-unexpectedly-in-xamarin

They indicate that wrongfully setup Xaml pages and moving stuff into different namespaces might be the case. But in my case I didn’t change those things.

If you’re sure that you haven’t been refactoring namespaces or Xaml pages, then chances are that you need to do the following:

  1. Go to Packages > Xamarin.Forms
  2. Right click “Remove Packages > Add Packages…
  3. Reïnstall Xamarin.Forms
  4. Try building your project again

When the template you are using from the clean download of Visual Studio for Mac are too far behind the forms package libraries they get out of sync and you get the stated error.

Hope this helps you smoothen this one out a little faster.

Let me know in the comments below if this worked for you or if you experienced a similar problem