diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/ConvertResourcesCases.cs b/src/Xamarin.Android.Build.Tasks/Tasks/ConvertResourcesCases.cs index d83db6a3e43..4905d7d2d2c 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/ConvertResourcesCases.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/ConvertResourcesCases.cs @@ -54,11 +54,11 @@ void FixupResources (ITaskItem item, Dictionary acwMap) foreach (string file in xmls) { Log.LogDebugMessage (" Processing: {0}", file); var srcmodifiedDate = File.GetLastWriteTimeUtc (file); - var tmpdest = file + ".tmp"; + var tmpdest = Path.GetTempFileName (); MonoAndroidHelper.CopyIfChanged (file, tmpdest); MonoAndroidHelper.SetWriteable (tmpdest); try { - AndroidResource.UpdateXmlResource (tmpdest, acwMap, + AndroidResource.UpdateXmlResource (resdir, tmpdest, acwMap, ResourceDirectories.Where (s => s != item).Select(s => s.ItemSpec)); // We strip away an eventual UTF-8 BOM from the XML file. diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/CopyAndConvertResources.cs b/src/Xamarin.Android.Build.Tasks/Tasks/CopyAndConvertResources.cs index 16102d253de..b197d50b60b 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/CopyAndConvertResources.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/CopyAndConvertResources.cs @@ -86,11 +86,12 @@ public override bool Execute () var destfilename = p.Value; var srcmodifiedDate = File.GetLastWriteTimeUtc (filename); var dstmodifiedDate = File.Exists (destfilename) ? File.GetLastAccessTimeUtc (destfilename) : DateTime.MinValue; - var tmpdest = p.Value + ".tmp"; + var tmpdest = Path.GetTempFileName (); + var res = Path.Combine (Path.GetDirectoryName (filename), ".."); MonoAndroidHelper.CopyIfChanged (filename, tmpdest); MonoAndroidHelper.SetWriteable (tmpdest); try { - AndroidResource.UpdateXmlResource (tmpdest, acw_map); + AndroidResource.UpdateXmlResource (res, tmpdest, acw_map); if (MonoAndroidHelper.CopyIfChanged (tmpdest, destfilename)) { MonoAndroidHelper.SetWriteable (destfilename); MonoAndroidHelper.SetLastAccessAndWriteTimeUtc (destfilename, srcmodifiedDate, Log); diff --git a/src/Xamarin.Android.Build.Tasks/Utilities/AndroidResource.cs b/src/Xamarin.Android.Build.Tasks/Utilities/AndroidResource.cs index e9bcb993d9b..8ce97de1c03 100644 --- a/src/Xamarin.Android.Build.Tasks/Utilities/AndroidResource.cs +++ b/src/Xamarin.Android.Build.Tasks/Utilities/AndroidResource.cs @@ -9,17 +9,14 @@ namespace Monodroid { static class AndroidResource { - public static void UpdateXmlResource (string filename, Dictionary acwMap, IEnumerable additionalDirectories = null) + public static void UpdateXmlResource (string res, string filename, Dictionary acwMap, IEnumerable additionalDirectories = null) { // use a temporary file so we only update the real file if things actually changed string tmpfile = filename + ".bk"; try { XDocument doc = XDocument.Load (filename, LoadOptions.SetLineInfo); - // The assumption here is that the file we're fixing up is in a directory below the - // obj/${Configuration}/res/ directory and so appending ../gives us the actual path to - // 'res/' - UpdateXmlResource (Path.Combine (Path.GetDirectoryName (filename), ".."), doc.Root, acwMap, additionalDirectories); + UpdateXmlResource (res, doc.Root, acwMap, additionalDirectories); using (var stream = File.OpenWrite (tmpfile)) using (var xw = new LinePreservedXmlWriter (new StreamWriter (stream))) xw.WriteNode (doc.CreateNavigator (), false);