Bug 15901 - Build fails with "ValidateInfoPlist task failed unexpectedly"
Summary: Build fails with "ValidateInfoPlist task failed unexpectedly"
Status: RESOLVED FIXED
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: iOS ()
Version: 1.6.x
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Marek Habersack
URL:
Depends on:
Blocks:
 
Reported: 2013-11-04 08:36 UTC by Øystein Krog
Modified: 2013-11-04 15:37 UTC (History)
4 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Repro case/project (14.18 KB, application/zip)
2013-11-04 09:03 UTC, Øystein Krog
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Øystein Krog 2013-11-04 08:36:13 UTC
When building our project I get the following error:

15>C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.MonoTouch.Common.targets(119,3): error MSB4018: The "ValidateInfoPlist" task failed unexpectedly.
15>C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.MonoTouch.Common.targets(119,3): error MSB4018: System.ArgumentException: Must specify valid information for parsing in the string.
15>C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.MonoTouch.Common.targets(119,3): error MSB4018:    at System.Enum.TryParseEnum(Type enumType, String value, Boolean ignoreCase, EnumResult& parseResult)
15>C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.MonoTouch.Common.targets(119,3): error MSB4018:    at System.Enum.Parse(Type enumType, String value, Boolean ignoreCase)
15>C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.MonoTouch.Common.targets(119,3): error MSB4018:    at Xamarin.MacDev.PropertyListFormat.XmlFormat.Context.ReadObjectHead()
15>C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.MonoTouch.Common.targets(119,3): error MSB4018:    at Xamarin.MacDev.PropertyListFormat.XmlFormat.StartReading(Stream input)
15>C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.MonoTouch.Common.targets(119,3): error MSB4018:    at Xamarin.MacDev.PropertyListFormat.CreateReadContext(Stream input)
15>C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.MonoTouch.Common.targets(119,3): error MSB4018:    at Xamarin.MacDev.PDictionary.FromFile(String fileName, Boolean& isBinary)
15>C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.MonoTouch.Common.targets(119,3): error MSB4018:    at MonoTouch.Tools.Utilities.Utils.GetPlistDocument(String path)
15>C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.MonoTouch.Common.targets(119,3): error MSB4018:    at Xamarin.MonoTouch.Build.Tasks.ValidateInfoPlist.Execute()
15>C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.MonoTouch.Common.targets(119,3): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
15>C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.MonoTouch.Common.targets(119,3): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext()

I did some research on this and I have found the following:

1. The project builds fine in Xamarin Studio and works in both simulator and on device
2. Disabling the ValidateInfoPlist step in the targets file makes the compilation complete successfully on Windows, but remote debugging does not work.
3. Removing some of our "Info.plist" files makes the project build successfully. 
4. Only "binary" Info.plist files cause the crash (These files were committed to our source repository in November 2012, unfortunately the developer who did so is no longer with us so I can't ask him where they stem from).
5. After removing these binary Info.plist files the app still works as before (no changes as far as I can tell).
6. After removing these binary Info.plist files remote debugging started working (we've never been able to get it working even though we've tried a lot).

I took a peek at the source code for the ValidateInfoPlist step (Xamarin.MonoTouch.Build.Tasks.dll) and I think this is the problem:
* PDictionary.FromFile uses PropertyListFormat.Binary.StartReading(), but this throws an exception and there is no try-catch in the call stack to handle this possibility.

I'm not sure why our old binary Info.plist files cause this problem, they may be invalid/corrupt.
If that is the case it would be good if the build system would say so more explicitly and most importantly say which files are at fault. 

Speculation on the reason for the exception: 
From my experience with .net-based binary serialization this might be because a type has been renamed/changed.
The call stack points to a problem with an enum, perhaps an enum member was removed/renamed?

I'll spend a little time on trying to create a repro-case.

Regards
Øystein Krog
Initial Force AS
Comment 1 Dominique Louis 2013-11-04 08:49:55 UTC
Hi Øystein,
  Can you please confirm that you are using MonoTouch 7.0.3 and the 1.6 Alpha?


D.
Comment 2 Marek Habersack 2013-11-04 08:53:32 UTC
Hello Øystein,

You can convert the binary info.plist files to XML ones using your Mac. To do
so, start Terminal.app and run the following command on each of the files (note
that the files will be modified in-place so make backups before modifying
them):

plutil -convert xml1 Info.plist

That should get you going, but it would be great if you could just attach the
binary versions of those files so that we can check whether our Info.plist
processor on Windows is able to read them. Thanks!

Alex, can you take a look at this once Øystein attaches the files
Comment 3 Øystein Krog 2013-11-04 09:01:13 UTC
Dominique: I found this bug when testing the 1.6 alpha + Monotouch 7.0.3.
I just tested 1.8 alpha and 7.0.4 and it seems to have the same problem.

Marek: Ok, I'm not sure why we even have these files, as our main plist and the settins plist are both xml. Are these plists for image resources or something?
Comment 4 Øystein Krog 2013-11-04 09:03:38 UTC
Created attachment 5324 [details]
Repro case/project
Comment 5 Øystein Krog 2013-11-04 09:04:38 UTC
The two binary Info.plist files can be found in this repro project, in Images\Info.plist and Resources\Info.plist
Comment 6 Øystein Krog 2013-11-04 09:10:27 UTC
I tried to convert both files to XML, but it failed:

# oysteinkrog at Oysteins-Mac in /Volumes/SC_Online_trunk_2/Mobile/SwingCatalyst/Apps/ScApp.iOS/Resources [15:08:44]
$ plutil -convert xml1 Info.plist
Info.plist: Property List error: Unexpected character _ at line 1 / JSON error: JSON text did not start with array or object and option to allow fragments not set.

These files may well be corrupt/bad, but if so it is weird that everything seems to work well on OS X.
Comment 7 Marek Habersack 2013-11-04 09:22:30 UTC
(In reply to comment #3)
> Dominique: I found this bug when testing the 1.6 alpha + Monotouch 7.0.3.
> I just tested 1.8 alpha and 7.0.4 and it seems to have the same problem.
> 
> Marek: Ok, I'm not sure why we even have these files, as our main plist and the
> settins plist are both xml. Are these plists for image resources or something?
No, it's just a different storage format. You can use the XML and binary formats exchangeably, they don't carry any inline binary payload in neither form.
Comment 8 Marek Habersack 2013-11-04 09:27:54 UTC
(In reply to comment #6)
> I tried to convert both files to XML, but it failed:
> 
> # oysteinkrog at Oysteins-Mac in
> /Volumes/SC_Online_trunk_2/Mobile/SwingCatalyst/Apps/ScApp.iOS/Resources
> [15:08:44]
> $ plutil -convert xml1 Info.plist
> Info.plist: Property List error: Unexpected character _ at line 1 / JSON error:
> JSON text did not start with array or object and option to allow fragments not
> set.
> 
> These files may well be corrupt/bad, but if so it is weird that everything
> seems to work well on OS X.
They are most certainly corrupted - they aren't Info.plist files at all. They look like combined parts of a PNG file with data from some other image file (?). 

I'm guessing that the problem is that the VS extension is overzealous in finding the .plist files - we process all of them while Xamarin Studio ignores those in Images and Resources folders, possibly in others.
Comment 9 Øystein Krog 2013-11-04 09:32:36 UTC
Ok, I guess the real problem here is really how the extension handles corrupt files then. Having ValidateInfoPlist fail is good really, but it should probably alert the user to what file it failed to parse.
Secondly, I'm pretty sure these files are the reason why remote debugging has never (up until now) worked for us, so it's really good that the VS build system now actually does fail... that said I'm wondering why remote debugging fails if I disable the ValidateInfoPlist step?
Perhaps the OS X debugging server should verify these files as well since they seem to be the reason why the simulator fails to start the app (it just fails silently).
Comment 10 Marek Habersack 2013-11-04 09:45:59 UTC
(In reply to comment #9)
> Ok, I guess the real problem here is really how the extension handles corrupt
> files then. Having ValidateInfoPlist fail is good really, but it should
> probably alert the user to what file it failed to parse.
Indeed, that's a good suggestion. On the other hand, there's a question whether or not the extension should even consider .plist files in Images/ and Resources/ 

> Secondly, I'm pretty sure these files are the reason why remote debugging has
> never (up until now) worked for us, so it's really good that the VS build
> system now actually does fail... that said I'm wondering why remote debugging
> fails if I disable the ValidateInfoPlist step?
> Perhaps the OS X debugging server should verify these files as well since they
> seem to be the reason why the simulator fails to start the app (it just fails
> silently).

I'm only guessing here, but I think it might be because resources and images (the latter more likely) are tested for validity? If the application fails to start because of the then the debugging server has no chance to initialize and so the debugging session is never opened.
Comment 11 Øystein Krog 2013-11-04 09:58:36 UTC
The strange thing is that everything works fine when compiled in Xamarin Studio, both in the sim and on real devices, if this failed in the same manner when compiled in Xamarin Studio everything would be fine..

We had basically given up on Visual Studio-based debugging for a long time, we tried to make it work on the very first day it arrived and every now and then we spent some time trying to make it work, but never successfully.

It's a real shame that we had to go without such a great feature for such a long time, preventing the same scenario for other users would be a nice I think ;P
We use remote debugging all the time now and _love_ it :)
Comment 12 Marek Habersack 2013-11-04 15:36:36 UTC
A fix for this issue was pushed to the 1.8 branch. It is _not_ in the current alpha, it will be part of the next update however.