Skip to content

Commit

Permalink
[Xamarin.Android.Build.Tasks] MSBuild target does not properly build …
Browse files Browse the repository at this point in the history
…incrementally

Fixes #2413

We should calculate the values for `_ManagedUpdateAndroidResgenInputs`
in a target rather than at evaluation time. This is so
we can pick up the correct `_AndroidBuildPropertiesCache`.
  • Loading branch information
dellis1972 committed Oct 17, 2019
1 parent ace41bf commit f9892eb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
Expand Up @@ -1137,10 +1137,15 @@ public void BuildAppWithManagedResourceParser()
StringAssert.Contains ("myButton", designerContents, $"{designerFile} should contain Resources.Id.myButton");
StringAssert.Contains ("Icon", designerContents, $"{designerFile} should contain Resources.Drawable.Icon");
StringAssert.Contains ("Main", designerContents, $"{designerFile} should contain Resources.Layout.Main");
Assert.IsTrue (appBuilder.Build (appProj),
appBuilder.BuildLogFile = "build.log";
Assert.IsTrue (appBuilder.Build (appProj, doNotCleanupOnUpdate: true),
"Normal Application Build should have succeeded.");
Assert.IsTrue (appProj.CreateBuildOutput (appBuilder).IsTargetSkipped ("_ManagedUpdateAndroidResgen"),
"Target '_ManagedUpdateAndroidResgen' should not have run.");
appBuilder.BuildLogFile = "designtimebuild.log";
Assert.IsTrue (appBuilder.DesignTimeBuild (appProj, doNotCleanupOnUpdate: true), "DesignTime Application Build should have succeeded.");
Assert.IsTrue (appProj.CreateBuildOutput (appBuilder).IsTargetSkipped ("_ManagedUpdateAndroidResgen"),
"Target '_ManagedUpdateAndroidResgen' should not have run.");

Assert.IsTrue (appBuilder.Clean (appProj), "Clean should have succeeded");
Assert.IsTrue (File.Exists (designerFile), $"'{designerFile}' should not have been cleaned.");
Expand Down
33 changes: 19 additions & 14 deletions src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets
Expand Up @@ -1318,24 +1318,29 @@ because xbuild doesn't support framework reference assemblies.
</ItemGroup>
</Target>

<PropertyGroup>
<_ManagedUpdateAndroidResgenInputs>
$(MSBuildAllProjects);
@(AndroidResource);
@(AndroidBoundLayout);
@(_ReferencePath);
@(_LibraryResourceDirectoryStamps);
@(_AdditonalAndroidResourceCachePaths->'%(Identity)\cache.stamp');
$(_AndroidBuildPropertiesCache);
$(ProjectAssetsFile);
</_ManagedUpdateAndroidResgenInputs>
</PropertyGroup>
<Target Name="_BeforeManagedUpdateAndroidResgen">
<PropertyGroup>
<_ManagedUpdateAndroidResgenInputs>
$(MSBuildAllProjects);
@(AndroidResource);
@(AndroidBoundLayout);
@(_ReferencePath);
@(_LibraryResourceDirectoryStamps);
@(_AdditonalAndroidResourceCachePaths->'%(Identity)\cache.stamp');
$(_AndroidBuildPropertiesCache);
$(ProjectAssetsFile);
$(_AndroidResourcePathsDesignTimeCache);
$(_AndroidLibraryProjectImportsDesignTimeCache);
$(_AndroidLibraryImportsDesignTimeCache);
</_ManagedUpdateAndroidResgenInputs>
</PropertyGroup>
</Target>

<!-- Managed DesignTime Resource Generation -->
<Target Name="_ManagedUpdateAndroidResgen" Condition=" '$(ManagedDesignTimeBuild)' == 'True' "
Inputs="$(_ManagedUpdateAndroidResgenInputs);$(_AndroidResourcePathsCache);$(_AndroidLibraryProjectImportsCache);$(_AndroidLibraryImportsCache);"
Inputs="$(_ManagedUpdateAndroidResgenInputs)"
Outputs="$(_AndroidManagedResourceDesignerFile)"
DependsOnTargets="_CreatePropertiesCache;_ExtractLibraryProjectImports;_CreateAdditionalResourceCache;_ValidateAndroidPackageProperties">
DependsOnTargets="_CreatePropertiesCache;_ExtractLibraryProjectImports;_CreateAdditionalResourceCache;_ValidateAndroidPackageProperties;_BeforeManagedUpdateAndroidResgen">
<MakeDir Directories="$(_AndroidIntermediateDesignTimeBuildDirectory)" />
<!-- Parse primary R.java and create Resources.Designer.cs -->
<GenerateResourceDesigner
Expand Down

0 comments on commit f9892eb

Please sign in to comment.