Now this is regarding the mysterious build error, “UnpackLibraryResources” task failed and the “MTouch” task failed, which unfortunately occurs out of nowhere in Xamarin Forms projects…
It all started…
So sometimes when I try to build and run my perfect Xamarin Forms project in Visual Studio, by the way which has no compilation issues, suddenly breaks down with a compilation error saying “UnpackLibraryResources” task failed and the “MTouch” task failed…
This was a complete puzzle to me, since there were no errors in the code, and this never occurred with any small scale project solutions, only with those massive enterprise scale projects at work.
I tried to look for a solution…
So I tried clean and rebuild, reopen Visual Studio, and blah blah many things.
So one last destination I tried was restarting Windows and re-opening Visual Studio, which actually worked!
It got me thinking, may be this has to do something with the resource usage of the PC, may be the build process is getting disturbed by some system activity in the background.
then I found this…
So I opened up Task Manager, and kept an eye on it, while running the compile and rebuild of my project.
I stumbled upon a crazy observation, whereas every time the above error occurs and the build fails, the Disk usage was showing up as below in the Task Manager.
And then time during the following error I noticed the same Disk usage as well.
Its very rare that VS could cause such a massive disk usage during build and run, and even if it did, why would the build process fail in such manner?
Reason behind this…
So I took a look at the Processes tab in the Task Manager and noticed that “Microsoft Compatibility Telemetry” process was hogging up the Disk usage, which is apparently the process that comes built into Windows 10 to collect and send our Usage Data to Microsoft.
And believe me this process was dominating the whole Read and Write usage of the Disk, that it was spiked up to over 90% disk usage only for this process. 😮
Now I don’t have any problem with Microsoft collecting my personal usage data for the reason of “improving their product” (which is what they say at least), but if it’s disturbing my day to day work, then you’re crossing a line! lol
So I killed the above process and re-ran my build,
BOOM! IT WORKED! 😀
And then another time the same issue occurred, I took a look at the Task Manager and noticed that my Anti-Virus which is “Kaspersky was running a scheduled Rootkit Scan” and it was hogging up the Disk usage over 90%!
So I cancelled the scan process and re-ran my build,
BOOM! IT WORKED! 😀
So now you know….
So as of my above experience you can clearly see that those build errors occur due to
excessive usage of Disk’s Read and Write by other Processes…
and it’s somehow disturbing the Build process for obvious reasons.
Now I’m not saying the above errors occur only for this specific reason, but in case if you couldn’t find a reason, then you may have to look into this aspect as I did! 😉
There you have it, I just shared my experience with yol, hope it may help someone!
Cheers! Stay awesome Devs!
Udara Alwis OUT!