diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/GetAdditionalResourcesFromAssemblies.cs b/src/Xamarin.Android.Build.Tasks/Tasks/GetAdditionalResourcesFromAssemblies.cs
index 7719f8a7fb6..6a748c5b079 100644
--- a/src/Xamarin.Android.Build.Tasks/Tasks/GetAdditionalResourcesFromAssemblies.cs
+++ b/src/Xamarin.Android.Build.Tasks/Tasks/GetAdditionalResourcesFromAssemblies.cs
@@ -459,7 +459,7 @@ public override bool Execute ()
new XElement ("AdditionalNativeLibraryReferences",
AdditionalNativeLibraryReferences.Select(e => new XElement ("AdditionalNativeLibraryReference", e)))
));
- document.Save (CacheFile);
+ document.SaveIfChanged (CacheFile);
LogDebugTaskItems (" AdditionalAndroidResourcePaths: ", AdditionalAndroidResourcePaths);
LogDebugTaskItems (" AdditionalJavaLibraryReferences: ", AdditionalJavaLibraryReferences);
diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/GetImportedLibraries.cs b/src/Xamarin.Android.Build.Tasks/Tasks/GetImportedLibraries.cs
index 79cfeddefc2..bca2d908a7a 100644
--- a/src/Xamarin.Android.Build.Tasks/Tasks/GetImportedLibraries.cs
+++ b/src/Xamarin.Android.Build.Tasks/Tasks/GetImportedLibraries.cs
@@ -54,7 +54,7 @@ public override bool Execute ()
new XElement ("NativeLibraries", NativeLibraries.Select(e => new XElement ("NativeLibrary", e.ItemSpec))),
new XElement ("Jars", Jars.Select(e => new XElement ("Jar", e.ItemSpec)))
));
- document.Save (CacheFile);
+ document.SaveIfChanged (CacheFile);
}
return true;
diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/ResolveLibraryProjectImports.cs b/src/Xamarin.Android.Build.Tasks/Tasks/ResolveLibraryProjectImports.cs
index 0aec9bd0635..ae418a63ae5 100644
--- a/src/Xamarin.Android.Build.Tasks/Tasks/ResolveLibraryProjectImports.cs
+++ b/src/Xamarin.Android.Build.Tasks/Tasks/ResolveLibraryProjectImports.cs
@@ -122,7 +122,7 @@ public override bool Execute ()
new XElement ("ResolvedResourceDirectoryStamps",
ResolvedResourceDirectoryStamps.Select(e => new XElement ("ResolvedResourceDirectoryStamp", e)))
));
- document.Save (CacheFile);
+ document.SaveIfChanged (CacheFile);
}
assemblyMap.Save (AssemblyIdentityMapFile);
diff --git a/src/Xamarin.Android.Build.Tasks/Utilities/XDocumentExtensions.cs b/src/Xamarin.Android.Build.Tasks/Utilities/XDocumentExtensions.cs
index 5bac4ba45a3..f904f0a11c1 100644
--- a/src/Xamarin.Android.Build.Tasks/Utilities/XDocumentExtensions.cs
+++ b/src/Xamarin.Android.Build.Tasks/Utilities/XDocumentExtensions.cs
@@ -1,4 +1,5 @@
using System;
+using System.IO;
using System.Linq;
using System.Xml.Linq;
using Microsoft.Build.Framework;
@@ -27,6 +28,17 @@ public static string ToFullString (this XElement element)
{
return element.ToString (SaveOptions.DisableFormatting);
}
+
+ public static void SaveIfChanged (this XDocument document, string fileName)
+ {
+ var tempFile = System.IO.Path.GetTempFileName ();
+ try {
+ document.Save (tempFile);
+ MonoAndroidHelper.CopyIfChanged (tempFile, fileName);
+ } finally {
+ File.Delete (tempFile);
+ }
+ }
}
}
diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets
index 283a0ec82f0..4f2c29db0dd 100755
--- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets
+++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets
@@ -1107,9 +1107,21 @@ because xbuild doesn't support framework reference assemblies.
Overwrite="true"/>
+
+ <_ManagedUpdateAndroidResgenInputs>
+ $(MSBuildAllProjects);
+ @(AndroidResource);
+ @(ReferencePath);
+ @(_LibraryResourceDirectoryStamps);
+ @(_AdditonalAndroidResourceCachePaths->'%(Identity)\cache.stamp');
+ $(_AndroidBuildPropertiesCache);
+ $(ProjectAssetsFile);
+
+
+
@@ -1188,7 +1200,7 @@ because xbuild doesn't support framework reference assemblies.
'%(Identity)\cache.stamp');
- $(_AndroidBuildPropertiesCache)
+ $(_AndroidBuildPropertiesCache);
+ $(ProjectAssetsFile);
+ $(_AndroidResourcePathsCache);
+ $(_AndroidLibraryProjectImportsCache);
+ $(_AndroidLibraryImportsCache);