Every Xamarin user has encountered the the strange problems and circumstances where Xamarin builds stop working correctly. Due to a myriad of reasons including Visual Studio, Xamarin bugs, copious caching, nuget issues, and the complex nature of what Xamarin is doing, it stops working and starts giving strange errors.

This is typified by things such as red squiggly lines under InitializeComponent, intellisense stops working, code changes won’t take, and odd build errors such as:

  • The “OutputPath” parameter is not supported by the “XamlGTask” task.
  • The “XamlGTask” task could not be initialized with its input parameters.
  • “Xamarin.Forms.Build.Tasks.GetTaskAbi” task could not be loaded

On iOS code changes may not “take,” Visual Studio Mac refuses to debug, or the debugger cannot connect.

Here are some things to try, ordered by what to do first:

First:

  1. Close Visual Studio or Visual Studio Mac.
  2. Ensure that the bin and obj subdirectories are in the .gitignore.
  3. Delete all of the obj and bin directories in the project subfolders.
  4. Reopen Visual Studio or Visual Studio Mac.
  5. Reload the project.
  6. Rebuild All.

Second

  1. Save a backup or do a git stash.
  2. Whilst in Visual Studio, use “Manage Nuget Projects For Solution” in Visual Studio for Windows to ensure:
    • All versions of Xamarin Forms are the same across projects.
    • All Android libraries are the same across versions.
  3. Carefully inspect the nuget package manager output for implicit nuget package resolution. This may cause incompatibilities. (see: Two Xamarin Nuget Gotchas
  4. Close Visual Studio or Visual Studio Mac.
  5. Ensure that the bin and obj subdirectories for each project are in the .gitignore.
  6. Delete all of the obj and bin directories in the project subfolders.
  7. Delete the .vs folder.
  8. Delete all versions of the app from emulators and devices.
  9. Close all emulators.
  10. Reopen Visual Studio or Visual Studio Mac.
  11. Reload the project.
  12. Rebuild All.
  13. Close Visual Studio (yes close it!)
  14. Reopen Visual Studio
  15. Load the project
  16. Rebuild

Third

  1. Save a backup or do a git stash if you haven’t already.
  2. Make a copy of any packages.config files to refer back to.
  3. Remove all Nuget Packages.
  4. Close Visual Studio.
  5. Delete the packages subdirectory.
  6. Open Visual Studio.
  7. Refer to step 2, add the required nuget packages back in. Do not add the latest version of Xamarin Forms unless you absolutely intend to do so. (See Xamarin “Rules” below.)
  8. Close Visual Studio or Visual Studio Mac.
  9. Ensure that the bin and obj subdirectories are in the .gitignore.
  10. Delete all of the obj and bin directories in the project subfolders.
  11. Delete the .vs folder.
  12. Reopen Visual Studio or Visual Studio Mac.
  13. Reload the project.
  14. Rebuild All.
  15. Close Visual Studio (yes close it!)
  16. Reopen Visual Studio
  17. Load the project
  18. Rebuild.

If all else fails..

Presuming the Third solution has failed, uninstall visual studio, and reinstall. Don’t install the latest version as there may be unfound bugs.

Here are some rules we follow:

  1. Save a copy, git checkin, or git stash before upgrading nuget versions of packages.
  2. Do not upgrade Visual Studio, or Xamarin, in the middle of a project unless there is good reason.
  3. Do Upgrade Visual Studio, Xamarin, Android SDKs when there are at least a couple days to spare, there are no impending releases, and the current release or intended Visual Studio/Xamarin has had a couple of weeks for bug reports and responses to flow in.

Latest Issues Will Be Here:

  • https://forums.xamarin.com/
  • https://github.com/xamarin/xamarin-android/issues
  • https://github.com/xamarin/XamarinComponents/issues
  • https://github.com/xamarin/Xamarin.Forms/issues
  • https://github.com/xamarin/xamarin-macios/issues
  • https://www.reddit.com/r/xamarindevelopers/

Request Help Here:

  • https://github.com/xamarin/xamarin-macios/issues
  • https://www.reddit.com/r/xamarindevelopers/
  • https://stackoverflow.com/ (Before you post, be sure to do a search first, and add the appropriate tags.)