public override bool Execute()
        {
            Log.LogDebugMessage("CalculateAdditionalResourceCacheDirectories Task");
            Log.LogDebugTaskItems("  AdditionalAndroidResourcePaths:", AdditionalAndroidResourcePaths);
            Log.LogDebugMessage("  CacheDirectory: {0}", CacheDirectory);

            if (!AdditionalAndroidResourcePaths.Any())
            {
                return(true);
            }

            var md5 = MD5.Create();

            Directory.CreateDirectory(CacheDirectory);
            var directories = new List <ITaskItem> ();

            foreach (var path in AdditionalAndroidResourcePaths)
            {
                var cacheSubDirectory = string.Concat(md5.ComputeHash(
                                                          Encoding.UTF8.GetBytes(path)).Select(b => b.ToString("X02"))
                                                      );
                var targetDir = Path.Combine(CacheDirectory, cacheSubDirectory);
                directories.Add(new TaskItem(Path.GetFullPath(targetDir).TrimEnd(Path.DirectorySeparatorChar)));
            }
            AdditionalResourceCachePaths = directories.ToArray();

            Log.LogDebugTaskItems("  [Output] AdditionalResourceCachePaths:", AdditionalResourceCachePaths);
            return(!Log.HasLoggedErrors);
        }
예제 #2
0
        public override bool RunTask()
        {
            if (!AdditionalAndroidResourcePaths.Any())
            {
                return(true);
            }

            Directory.CreateDirectory(CacheDirectory);
            var directories = new List <ITaskItem> ();

            foreach (var path in AdditionalAndroidResourcePaths)
            {
                var targetDir = Path.Combine(CacheDirectory, Files.HashString(path));
                directories.Add(new TaskItem(Path.GetFullPath(targetDir).TrimEnd(Path.DirectorySeparatorChar)));
            }
            AdditionalResourceCachePaths = directories.ToArray();

            Log.LogDebugTaskItems("  [Output] AdditionalResourceCachePaths:", AdditionalResourceCachePaths);
            return(!Log.HasLoggedErrors);
        }