Bug 29144 - Android application fails to build
Summary: Android application fails to build
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: 4.20.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: dean.ellis
Depends on:
Reported: 2015-04-16 04:43 UTC by Alexey Pelykh
Modified: 2015-04-16 11:44 UTC (History)
2 users (show)

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

Diagnostic build log (1.63 MB, text/plain)
2015-04-16 11:26 UTC, Alexey Pelykh
Diagnostic build log (without error) (2.08 MB, text/plain)
2015-04-16 11:29 UTC, Alexey Pelykh

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 or GitHub 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:

Description Alexey Pelykh 2015-04-16 04:43:36 UTC
Description of Problem:
Conditional ProjectDir set to MSBuildProjectDirectory breaks project build

Steps to reproduce the problem:
1. Create Android application project
2. Add MSBuildTasks from NuGet
3. Change PropertyGroup with MSBuildCommunityTasksPath to
    <ProjectDir Condition=" '$(ProjectDir)' == '' ">$(MSBuildProjectDirectory)</ProjectDir>
4. Try to build application

Actual Results:
Build fails with "AndroidManifest file does not exist (DemoApp.Android)"

Expected Results:
Application builds normally

How often does this happen? 
100% reproduce.

Additional Information:
Issue raises due to
<ProjectDir Condition=" '$(ProjectDir)' == '' ">$(MSBuildProjectDirectory)</ProjectDir>
Comment 1 dean.ellis 2015-04-16 11:24:31 UTC
could you post the diagnostic output of the build please? It might give us some hints as to where the problem is occurring.
Comment 2 Alexey Pelykh 2015-04-16 11:26:27 UTC
Created attachment 10786 [details]
Diagnostic build log
Comment 3 Alexey Pelykh 2015-04-16 11:29:41 UTC
Created attachment 10787 [details]
Diagnostic build log (without error)

This is build log with the line mentioned above changed
    <!-- https://bugzilla.xamarin.com/show_bug.cgi?id=29144 -->
    <!--<ProjectDir Condition=" '$(ProjectDir)' == '' ">$(MSBuildProjectDirectory)</ProjectDir>
Comment 4 dean.ellis 2015-04-16 11:44:27 UTC
OK the problem is that $(ProjectDir) is used in various places in the Android build targets. The propertyGroup you are adding is being added before the 

 <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />

which means none of those properties are defined yet (including the $(MSBuildProjectDirectory) ) as they are defined in the Microsoft.CSharp.targets file whites imported by the Xamarin.Android ones. You basically need to move the PropertyGroup to below the Xamarin.Android.CSharp.targets import. That fixes the issue  for me .