Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ void FixupResources (ITaskItem item, Dictionary<string, string> 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 2 additions & 5 deletions src/Xamarin.Android.Build.Tasks/Utilities/AndroidResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,14 @@
namespace Monodroid {
static class AndroidResource {

public static void UpdateXmlResource (string filename, Dictionary<string, string> acwMap, IEnumerable<string> additionalDirectories = null)
public static void UpdateXmlResource (string res, string filename, Dictionary<string, string> acwMap, IEnumerable<string> 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);
Expand Down