Bug 16393 - Xamarin.Mono.Touch.Common.targets: InfoPlist task causes command line build to fail.
Summary: Xamarin.Mono.Touch.Common.targets: InfoPlist task causes command line build t...
Status: VERIFIED FIXED
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: iOS ()
Version: 1.8.x
Hardware: PC Windows
: Normal normal
Target Milestone: 3.7
Assignee: vsx
URL:
Depends on:
Blocks:
 
Reported: 2013-11-21 15:54 UTC by Fraser Ruffelll
Modified: 2014-10-01 02:21 UTC (History)
11 users (show)

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


Attachments
Dummy hello world project csproj file with None item missing, and build log with error. (1.71 KB, application/zip)
2013-11-26 08:04 UTC, Fraser Ruffelll
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:
VERIFIED FIXED

Description Fraser Ruffelll 2013-11-21 15:54:32 UTC
On Windows we perform a command line build of our Xamarin.iOS apps to ensure no compilation errors, and to perform static code analysis. This was working fine, but with the latest stable update our build scripts now fail.

I have debugged the failure and determined that in the file Xamarin.Mono.Touch.Common.targets which is imported from each of our csproj files, the task FindInfoPlist in the target "_FindInfoPlist" is failing. It fails if the property InputItems is empty, which it is:

  <Target Name="_FindInfoPlist" Condition="'$(OutputType)' == 'Exe'">
    <FindInfoPlist InputItems="@(None);@(ApplicationDefinition)">
      <Output ItemName="_InfoPlistItem" TaskParameter="InfoPlistItem"/>
    </FindInfoPlist>

    <ValidateInfoPlist InfoPlistItem="@(_InfoPlistItem)" Condition="'@(_InfoPListItem)'!=''"/>
  </Target>

The Items "None" and "ApplicationDefinition" are not ours, and don't appear to be defined before this task is executed (in fact I can't seem to find any definition of ApplicationDefinition conditional or otherwise starting at the csproj).

Adding the attribute 'ContinueOnError=“WarnAndContinue”’ on this task allows the build to continue but we don't want to edit or maintain core Xamarin build scripts.

Version info from Visual Studio: 1.8.365 (8cb9dbd0)
Comment 1 Prashant manu 2013-11-22 02:33:42 UTC
@Fraser, Could you please provide us steps so that we can reproduce it at our end?
Comment 2 Fraser Ruffelll 2013-11-22 10:33:55 UTC
If I create a new dummy Xamarin.iOS project in Visual Studio, the problem does not exist since the generated csproj file contains this line:

  <ItemGroup>
    ...
    <None Include="Info.plist" />
    ...
  </ItemGroup>

Remove the line "<None ..." and you will see the error.

Our existing Xamarin.iOS project files do not have this Item defined (but our Android project files do), and since this is used as input to the FindPlistInfo task, the task fails.

The solution will be for us to update our project files to contain this, but this is a bug if previously generated Xamarin.iOS project files did not generate this Item.
Comment 3 narayanp 2013-11-26 05:58:14 UTC
I have checked this issue with following builds:

All Windows
VS 2012/2013
MTVS 1.8.365
X.iOS 7.0.4.209

I am unable to reproduce this issue. I am not seeing any error after removing "<None ..." from my new created dummy iOS project( .csproj) even when I remove it from my existing dummy project.
Comment 4 Marek Habersack 2013-11-26 06:33:21 UTC
Fraser,

Each Xamarin.iOS application is required to have an Info.plist file - hence why the aforementioned task fails. If you use Xamarin Studio, it will insist on Info.plist existence to a point of generating a default one should it be absent. The Visual Studio add-in doesn't currently do that, but it is very likely we will implement the same behavior in one of the future versions.

Adding Info.plist to your application project will fix this problem.
Comment 5 Fraser Ruffelll 2013-11-26 07:58:09 UTC
@narayanp are you sure? How are you invoking the build? I just removed the Info.plist item from None, and I get "BUILD FAILED" using MSBuild 4.0 on Windows. See the attached zip file for both the *.csproj file and resulting output. Although no errors are reported, the task fails, which in turns causes the build to fail (e.g. any subsequent build steps after the build now don't run).

@marek Thanks, we are aware of the importance of Info.plist and have had one in our project since the beginning :) I believe our csproj initially was created via XS (a long time ago). The Info.plist has always been referenced in our project file by inclusion within the Bundle items, but never by the None item:

  <ItemGroup>
    <BundleResource Include="Info.plist" />
    ...
  </ItemGroup>

Questions:

1) With what version of Xamarin.iOS was the None item introduced?
2) Is there documentation on None and any other Items\Properties of importance to the Xamarin build process?
3) Do we still need the BundleResource to include Info.plist?
4) In the future if changes are made to the build scripts which requires modifications to the project files is there an "upgrade" tool?

Thanks,
Comment 6 Fraser Ruffelll 2013-11-26 08:04:25 UTC
Created attachment 5545 [details]
Dummy hello world project csproj file with None item missing, and build log with error.
Comment 7 Marek Habersack 2013-11-26 08:13:08 UTC
Jeff, can you answer the questions in comment 5? Thanks!
Comment 8 Jeffrey Stedfast 2013-11-26 08:40:17 UTC
Answers:

1) With what version of Xamarin.iOS was the None item introduced?

It's always been there. It simply means not to process the item. Visual Studio has it as well.

2) Is there documentation on None and any other Items\Properties of importance
to the Xamarin build process?

This is a question for the documentation team, not me.

3) Do we still need the BundleResource to include Info.plist?

The Info.plist's Build Action should be None (and has been so for years on Xamarin Studio, at least). I think Xamarin Studio will handle it if it's set to BundleResource as well, but I'd need to confirm that.

4) In the future if changes are made to the build scripts which requires
modifications to the project files is there an "upgrade" tool?

Xamarin Studio has not changed the build scripts in ways that break older setups ever, afaik. At least not in the past 2 years that I've been working on it.

For example, we've replaced the "Content" build action with "BundleResource", but "Content" continues to work just as it always has (which is why we added BundleResource so we could add additional behavior without breaking older projects).

I've never seen or heard of "ApplicationDefinition", so no idea what the msbuild task is doing either. That doesn't exist in Xamarin Studio.
Comment 9 Marek Habersack 2013-11-26 08:50:42 UTC
Fraser, I just want to add a comment to Jeff's answer to question #4 in comment 8 - the MSBuild scripts used by the VS extension are currently NOT guaranteed not to change and relying on their layout or targets/tasks in CI etc is currently unssupported. The reason for this is that we still don't have a fully developed layout for those files (and this is why all our targets are marked as "private" by prefixing their names with _) and we need to be free to turn them upside-down until we're happy with what we have there.

So until we announce that the msbuild support tasks/targets are in their final shape you should expect breakage from time to time.
Comment 10 Marek Habersack 2013-11-26 08:52:38 UTC
Pending answer to question #4 in comment 8, the VS extension might need to add support for Info.plist mentioned in BundleResource should it be supported by XS.
Comment 11 Alan McGovern 2013-11-26 11:03:08 UTC
The correct build action for Info.plist is 'None'. There was a bug in Visual Studio extension whereby it incorrectly reset the Build Action to 'BundleResource' for files under certain circumstances. The odds are high that this bug is what caused the issue for you.

To fix the problem, find the Info.plist file in the Visual Studio 'Solution Explorer', right click on it and select 'Properties'. Finally, change the build action back to None.

We can improve the error messaging for this case and offer a more informative error when no valid Info.plist can be found.
Comment 12 Mohit Kheterpal 2014-09-30 10:31:58 UTC
I have checked this issue and follow following steps :

1. Create iOS project in VS
2. open CSPROJ file and remove line "<None Include="Info.plist" />"
3. save project
4. build via command prompt

It gives error that info.plist file is not found as shown in screencast : http://screencast.com/t/JuQ0OMGd

Please let me know If I have missed something.

As of now, I am reopening this issue.

Environment info : 
Microsoft Visual Studio Professional 2013
Version 12.0.21005.1 REL
Microsoft .NET Framework
Version 4.5.52742

Installed Version: Professional
Xamarin   3.7.178.0 (5092258ec2e1cf6abd805970dea6ee46a50349a1)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android   4.18.0.32 (04399d62cfc00624d575239d1762ea4fd6d012e2)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.iOS   8.2.0.0 (a1f0a7a951a158ce3b9445e387ea737a083ffd79)
Visual Studio extension to enable development for Xamarin.iOS.
Comment 13 Alan McGovern 2014-09-30 12:31:37 UTC
It is incorrect to remove this line. It is required for compilation to succeed.
Comment 14 Prashant manu 2014-10-01 02:21:58 UTC
As per comment 13 we have checked again with "<None Include="Info.plist" />"
in .csproj file and it build correctly with command line.
Screencast for this: http://screencast.com/t/SZhBB6gUzZOv
Hence closing this issue.

Environment Info:
Win 7, VS 2013
Xamarin  3.7.188.0 (830a1477f07719a370cd6f5e905124c0cb2a57c6)
Xamarin.Android   4.18.0.32 (04399d62cfc00624d575239d1762ea4fd6d012e2)
Xamarin.iOS   8.2.0.0 (a1f0a7a951a158ce3b9445e387ea737a083ffd79)
Maverick 10.9.5, XI 8.2.0.190