[msbuild] Ignore .DS_Store files when cloning asset catalogs (#1776)

Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=52851

The problem here is that the .DS_Store file was included in
the .csproj file but did not exist on disk, so when we went
to clone that file into the obj/ dir before running actool
on it, File.Copy() would fail because the file did not
actually exist.

Since these files are worthless anyway, we can safely ignore
them.

Also added logic to verify that files exist before copying
them in order to report a better error than an exception
stack trace.
This commit is contained in:
Jeffrey Stedfast 2017-02-27 16:12:23 -05:00
Родитель ae047281a3
Коммит e6d037ef5a
1 изменённых файлов: 20 добавлений и 4 удалений

Просмотреть файл

@ -297,6 +297,10 @@ namespace Xamarin.MacDev.Tasks
for (int i = 0; i < ImageAssets.Length; i++) {
var vpath = BundleResource.GetVirtualProjectPath (ProjectDir, ImageAssets[i], !string.IsNullOrEmpty (SessionId));
// Ignore MacOS .DS_Store files...
if (Path.GetFileName (vpath).Equals (".DS_Store", StringComparison.OrdinalIgnoreCase))
continue;
// get the parent (which will typically be .appiconset, .launchimage, .imageset, .iconset, etc)
var catalog = Path.GetDirectoryName (vpath);
@ -336,6 +340,10 @@ namespace Xamarin.MacDev.Tasks
var clone = false;
ITaskItem item;
// Ignore MacOS .DS_Store files...
if (Path.GetFileName (vpath).Equals (".DS_Store", StringComparison.OrdinalIgnoreCase))
continue;
foreach (var catalog in clones) {
if (vpath.Length > catalog.Length && vpath[catalog.Length] == '/' && vpath.StartsWith (catalog, StringComparison.Ordinal)) {
clone = true;
@ -344,17 +352,25 @@ namespace Xamarin.MacDev.Tasks
}
if (clone) {
var path = Path.Combine (intermediateCloneDir, vpath);
var dir = Path.GetDirectoryName (path);
var src = ImageAssets[i].GetMetadata ("FullPath");
if (!File.Exists (src)) {
Log.LogError (null, null, null, src, 0, 0, 0, 0, "File not found: {0}", src);
return false;
}
var dest = Path.Combine (intermediateCloneDir, vpath);
var dir = Path.GetDirectoryName (dest);
Directory.CreateDirectory (dir);
File.Copy (ImageAssets[i].GetMetadata ("FullPath"), path, true);
File.Copy (src, dest, true);
// filter out everything except paths containing a Contents.json file since our main processing loop only cares about these
if (Path.GetFileName (vpath) != "Contents.json")
continue;
item = new TaskItem (path);
item = new TaskItem (dest);
ImageAssets[i].CopyMetadataTo (item);
item.SetMetadata ("Link", vpath);
} else {